Skip to content

fix: cis regressions — re-apply /etc/issue banners + comprehensive logfile permissions for scan VM#8317

Open
djsly wants to merge 1 commit intomainfrom
fix/cis-etc-issue-overwrite
Open

fix: cis regressions — re-apply /etc/issue banners + comprehensive logfile permissions for scan VM#8317
djsly wants to merge 1 commit intomainfrom
fix/cis-etc-issue-overwrite

Conversation

@djsly
Copy link
Copy Markdown
Collaborator

@djsly djsly commented Apr 15, 2026

Problem

Multiple CIS rules are regressing on Ubuntu VHD builds, blocking every PR on pipeline 119535:

  • CIS 1.6.2/1.6.3 (login banners): apt_get_dist_upgrade --force-confnew overwrites custom /etc/issue and /etc/issue.net banners when base-files package upgrades
  • CIS 6.1.3.1 (22.04) / 6.1.4.1 (24.04) (logfile permissions): Scan VM boot-time daemons (syslog, journal) create new log files with default permissions/ownership that violate CIS rules

Root Causes

/etc/issue (1.6.2/1.6.3)

  1. copyPackerFiles() in pre-install-dependencies.sh copies custom banners early in the build
  2. apt_get_dist_upgrade() runs with --force-confnew, overwriting conffiles with maintainer versions
  3. Custom banners are replaced with default Ubuntu content containing \n \l escape sequences

Logfile permissions (6.1.3.1/6.1.4.1)

  1. cis.sh fixes log permissions during VHD build (runs last among config scripts)
  2. VHD is captured and scan VM boots from it
  3. Boot-time daemons create new log files with wrong permissions/group ownership
  4. CIS benchmark requires: file perms ≤ 0640, dir perms ≤ 0750, group ∈ {root, adm}, owner ∈ {root, syslog}
  5. Previous fix incorrectly treated syslog as a valid group — CIS only allows root or adm

Fixes

Banner fix: Re-copy banners in post-install-dependencies.sh

reapplyBanners() function in packer_source.sh re-copies custom login banners from the packer staging area after all apt operations complete, ensuring banners survive any base-files upgrade.

Logfile fix: Comprehensive permission/ownership fix in cis-report.sh

Runs on the scan VM before the CIS assessor, fixing all four dimensions the benchmark checks:

  • File permissions: at most 0640 (clear execute, group-write, other-all, setuid/setgid/sticky)
  • Directory permissions: at most 0750 (clear group-write, other-all, setuid/setgid/sticky)
  • Group ownership: must be root or adm only (files with other groups like syslog, utmpadm)
  • File ownership: must be root or syslog only (files owned by other users → root)

Impact

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Re-applies custom /etc/issue and /etc/issue.net login banners after Ubuntu apt operations to prevent CIS 1.6.2/1.6.3 regressions caused by base-files conffile overwrites during dist-upgrade.

Changes:

  • Adds a post-apt step in post-install-dependencies.sh to copy the custom local and remote login banners back into place.
  • Documents why apt_get_dist_upgrade --force-confnew can revert the banner files.

Comment thread vhdbuilder/packer/post-install-dependencies.sh Outdated
Comment thread vhdbuilder/packer/post-install-dependencies.sh Outdated
@djsly djsly changed the title fix: re-apply /etc/issue banners after apt dist-upgrade (CIS 1.6.2/1.6.3 regression) fix: CIS regressions — re-apply /etc/issue banners + comprehensive logfile permissions for scan VM Apr 15, 2026
Copilot AI review requested due to automatic review settings April 15, 2026 02:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread vhdbuilder/packer/cis-report.sh Outdated
Comment thread vhdbuilder/packer/cis-report.sh Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread vhdbuilder/packer/cis-report.sh Outdated
Comment thread vhdbuilder/packer/post-install-dependencies.sh
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread vhdbuilder/packer/cis-report.sh Outdated
Comment thread vhdbuilder/packer/cis-report.sh Outdated
Copilot AI review requested due to automatic review settings April 16, 2026 02:39
@djsly djsly force-pushed the fix/cis-etc-issue-overwrite branch from c5e7b94 to a7ce954 Compare April 16, 2026 02:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@djsly djsly force-pushed the fix/cis-etc-issue-overwrite branch from a7ce954 to 9b4d2cc Compare April 16, 2026 18:41
@awesomenix awesomenix enabled auto-merge (squash) April 16, 2026 20:15
@djsly djsly disabled auto-merge April 16, 2026 20:24
Copilot AI review requested due to automatic review settings April 16, 2026 20:39
@djsly djsly force-pushed the fix/cis-etc-issue-overwrite branch from 9b4d2cc to 57b672b Compare April 16, 2026 20:39
@github-actions github-actions bot added the components This pull request updates cached components on Linux or Windows VHDs label Apr 16, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Comment thread vhdbuilder/packer/trivy-scan.sh Outdated
Comment thread vhdbuilder/packer/trivy-scan.sh Outdated
Comment thread parts/common/components.json Outdated
Comment thread .github/renovate.json
Comment thread vhdbuilder/packer/trivy-scan.sh
Copy link
Copy Markdown
Contributor

@awesomenix awesomenix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something changed to downgrade here is that expected?

Re-copies custom login banners from packer staging area after all apt
operations complete in post-install-dependencies.sh, ensuring banners
survive any base-files upgrade that overwrites /etc/issue via
--force-confnew.

Fixes CIS 1.6.2 and 1.6.3 regressions on Ubuntu VHD builds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@djsly djsly force-pushed the fix/cis-etc-issue-overwrite branch from 57b672b to b4a1c56 Compare April 16, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

components This pull request updates cached components on Linux or Windows VHDs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants