fix: narrow Ubuntu kernel module deny mitigation#8997
Conversation
AB#38890309 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 241779b3-0dde-4150-81e6-3ff1e5d8508a
There was a problem hiding this comment.
Pull request overview
This PR narrows the “Copy Fail + DirtyFrag + Fragnesia” kernel module deny mitigation so that newly built Ubuntu 22.04/24.04 VHDs no longer bake the modprobe blacklist, while CSE-time enforcement remains for older/unknown Ubuntu kernels and for non-Ubuntu OS streams that still require the mitigation.
Changes:
- Skip baking the vulnerable-module blacklist into Ubuntu 22.04/24.04 VHDs (while still skipping AzureLinux 3.0 non-OSGuard as before).
- Add Ubuntu kernel-version-aware gating in
cse_main.shso runtime deny rules apply only on vulnerable/unknown Ubuntu kernels. - Update VHD content tests, ShellSpec coverage, and E2E validation to reflect the new Ubuntu behavior; harden
semverCompare()’s highest-version extraction.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| vhdbuilder/packer/test/linux-vhd-content-test.sh | Updates VHD content assertions so Ubuntu 22.04/24.04 now expect absence of the blacklist entries (similar to AzureLinux 3.0). |
| vhdbuilder/packer/packer_source.sh | Skips baking modprobe-CIS.conf on Ubuntu 22.04/24.04 to avoid blocking modules on fixed kernels; keeps bake-in for other OS streams. |
| spec/parts/linux/cloud-init/artifacts/cse_main_disable_modules_spec.sh | Adds ShellSpec coverage for the Ubuntu kernel gate and updates the OS gate tests accordingly. |
| parts/linux/cloud-init/artifacts/cse_main.sh | Introduces ubuntuKernelNeedsVulnerableModuleMitigation() and gates runtime module disabling on vulnerable Ubuntu kernels only. |
| parts/linux/cloud-init/artifacts/cse_helpers.sh | Fixes semverCompare() to reliably select the highest version from sorted output. |
| e2e/validators.go | Updates E2E validation to accept “blacklist absent” on fixed Ubuntu kernels while retaining full enforcement checks on vulnerable/unknown Ubuntu kernels and other OSes. |
AB#38890309 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 241779b3-0dde-4150-81e6-3ff1e5d8508a
AB#38890309 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 241779b3-0dde-4150-81e6-3ff1e5d8508a
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Comments suppressed due to low confidence (3)
parts/linux/cloud-init/artifacts/cse_helpers.sh:753
- Same as above: use suffix matches (
*-azure/*-generic) so unknown Ubuntu 24.04 kernel flavors don’t get misclassified as “known” and accidentally skip the mitigation.
case "$kernel_release" in
*-azure*) fixed_kernel="6.8.0-1058-azure" ;;
*-generic*) fixed_kernel="6.8.0-124-generic" ;;
vhdbuilder/packer/cleanup-vhd.sh:46
- Same as above for Ubuntu 24.04 cleanup: match
*-azure/*-genericsuffixes to avoid treating unknown kernel flavors as fixed.
case "$kernel_release" in
*-azure*) fixed_kernel="6.8.0-1058-azure" ;;
*-generic*) fixed_kernel="6.8.0-124-generic" ;;
e2e/validators.go:3176
- Same as above for Ubuntu 24.04 E2E validation: switch to
*-azure/*-genericsuffix matches to keep unknown kernel flavors treated as “unknown” (and therefore requiring the mitigation).
` case "$kernel_release" in`,
` *-azure*) fixed_kernel="6.8.0-1058-azure" ;;`,
` *-generic*) fixed_kernel="6.8.0-124-generic" ;;`,
` esac`,
AB#38890309 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 241779b3-0dde-4150-81e6-3ff1e5d8508a
Remove stale Copy Fail / DirtyFrag / Fragnesia modprobe deny rules at CSE time for Ubuntu kernels that have the fixed kernel versions. This covers fixed-kernel nodes created from older cached VHDs that still carry baked deny rules while keeping mitigation for vulnerable or unknown Ubuntu kernels. AB#38890309 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 241779b3-0dde-4150-81e6-3ff1e5d8508a
|
E2E follow-up:
Pushed Validation run:
Note: 🤖 Generated by GitHub Copilot |
Windows Unit Test Results 3 files 11 suites 52s ⏱️ Results for commit d5aad21. ♻️ This comment has been updated with latest results. |
AB#38890309 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 241779b3-0dde-4150-81e6-3ff1e5d8508a
AB#38890309 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 241779b3-0dde-4150-81e6-3ff1e5d8508a
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
parts/linux/cloud-init/artifacts/cse_main.sh:388
- The fixed-Ubuntu-kernel unblock path (removeVulnerableKernelModuleDenyRules) is executed only in basePrep. On PIS/VHD-cached nodes where /opt/azure/containers/base_prep.complete is baked into the image, basePrep is skipped and nodePrep runs; in that case any stale baked deny rules for algif_aead/esp4/esp6/rxrpc would never be removed, so fixed kernels could remain blocked contrary to the intended behavior. Consider running the Ubuntu mitigation/cleanup gate in nodePrep as well (or refactor into a helper invoked from both phases) so fixed-kernel cleanup happens even when basePrep is skipped.
if isUbuntu "$OS"; then
if ubuntuKernelNeedsVulnerableModuleMitigation; then
disableVulnerableKernelModule "algif_aead" "CVE-2026-31431 (Copy Fail)"
disableVulnerableKernelModule "esp4" "DirtyFrag (xfrm-ESP page-cache write)"
disableVulnerableKernelModule "esp6" "DirtyFrag (xfrm-ESP6 page-cache write)"
disableVulnerableKernelModule "rxrpc" "DirtyFrag (RxRPC page-cache write, bypasses AppArmor userns)"
else
removeVulnerableKernelModuleDenyRules || exit $ERR_MODPROBE_FAIL
fi
AB#38890309 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 241779b3-0dde-4150-81e6-3ff1e5d8508a
|
Addressed the latest Copilot review note about PIS: the Ubuntu mitigation decision is now centralized in Validation rerun on the new commit:
🤖 Generated by GitHub Copilot |
Summary
Narrow the Copy Fail + DirtyFrag + Fragnesia kernel module deny mitigation so future fixed Ubuntu VHDs no longer bake or apply deny rules for
algif_aead,esp4,esp6, andrxrpc, while preserving protection for old or unknown Ubuntu kernels and the non-Ubuntu streams that still need it.Changes
modprobe-CIS.confCIS hardening into future Ubuntu 22.04/24.04 VHDs, but filter and scrub the vulnerable-module deny rules foralgif_aead,esp4,esp6, andrxrpc.semverCompareextraction for kernel-version comparisons.Fixed Ubuntu kernel cutoffs
5.15.0-1116-azure5.15.0-181-generic6.8.0-1058-azure6.8.0-124-genericThe Ubuntu 24.04 cutoff is intentionally conservative; old, unknown, or undetectable Ubuntu kernels remain protected by default.
Testing
shellspec --shell bash spec/parts/linux/cloud-init/artifacts/cse_main_disable_modules_spec.shbash -n vhdbuilder/packer/test/linux-vhd-content-test.shbash -n vhdbuilder/packer/packer_source.shcd e2e && go test ./... -run '^$'GOPROXY=https://proxy.golang.org,direct GENERATE_TEST_DATA=true go test ./pkg/agent...semverComparesmoke test for equal/newer/older kernel versionsNote:
make generatewas attempted first, but the configured Go proxy returned401 Unauthorizedwhile installinggithub.com/onsi/ginkgo/v2/ginkgo@v2.1.1; the documented narrower generation path above completed successfully with the public Go proxy.Related
🤖 Generated by GitHub Copilot