fleet icon indicating copy to clipboard operation
fleet copied to clipboard

CIS macOS: 3 policy/script defects found during benchmark update QA

Open marcusallen97 opened this issue 2 months ago • 2 comments

Fleet versions

  • Discovered: Fleet dev build from main (2026-08-21, post-PR #49815 merge)
  • Reproduced: main @ d68c8f0c47 (2026-09-03, second dev instance)

Web browser and operating system: N/A (server-side policy queries) — test hosts: macOS 14.6, 15.6 (×2 VMs), 26.5.1 (Parallels, Apple Silicon), verified via fleetctl query / fleetctl run-script


Three defects found while QA-ing the macOS CIS benchmark updates in #45644 / PR #49815. Bundled per QA: bugs 1 and 2 are structural false-fails that prevent the affected policies from ever passing natively; bug 3 affects the shipped test/remediation scripts through Fleet's own script execution. Only Bug 1 (on macOS 26) involves a policy this PR added; the others are pre-existing.

💥 Actual behavior

Bug 1 — CIS 5.3.1 "internal APFS volumes encrypted" false-fails on macOS 15 and 26 with FileVault fully ON. Apple ships read-only, sealed asset cryptex volumes (Siri ASR models, PKI trust store) with role="" and filevault=0. The query's role-exclusion list doesn't cover empty-role volumes, so the policy fails on unmodified hosts regardless of encryption state. Confirmed on macOS 26.5.1 (two cryptexes) and on two independent macOS 15.6 VMs (PKI trust-store cryptex), all with System+Data filevault=1. macOS 14.6 has no such volumes and passes correctly. 5.3.1 is a new automated policy on macOS 26 in v1.1.0, so this is immediately customer-visible there. Related: #49818 — the cryptex volumes report Device Location: External in diskutil info, so that issue's planned internal column + scoping 5.3.1 to internal = 1 (item 3 of its plan) would also resolve this false-fail.

Bug 2 — CIS 5.1.7 "no world-writable /Library folders" false-fails on every macOS 14/15 host. The sticky-bit exclusion NOT ((CAST(f.mode AS INTEGER) & 01000) = 01000) is broken: SQLite has no octal literals, so 01000 parses as decimal 1000 (CAST('1777' AS INTEGER) & 01000 → 736, never 1000). /Library/Caches (mode 1777, present on every install) is therefore permanently flagged. macOS 26's file uses a different, correct check (CAST(SUBSTR(f.mode,1,1) AS INTEGER) NOT IN (1,3,5,7)) and is unaffected. Pre-existing — PR #49815 only added the /Library/AppStore exclusion next to this line.

Bug 3 — CIS 2.7.1 test/remediation scripts can't apply preference writes via Fleet's script execution on macOS 14.6 and 26.5.1. sudo -u "$user" defaults write com.apple.dock ... in the shipped CIS_2.7.1_fail.sh/_pass.sh exits with Could not write domain com.apple.dock when run via fleetctl run-script. A launchctl asuser workaround writes only cfprefsd's live cache and never flushes to the on-disk plist that osquery's plist table reads. The identical script works end-to-end on macOS 15.6 — variable isolated to OS version (same server, same orbit 1.59.0, byte-identical scripts). GUI changes work fine on all versions.

🛠️ Expected behavior

  • Bug 1: 5.3.1 passes on a host whose real user/system volumes are all FileVault-encrypted; Apple-managed empty-role asset cryptexes (sealed, read-only, never encryptable) should not count as unencrypted user storage.
  • Bug 2: Sticky-bit directories like /Library/Caches (1777) are excluded, as CIS intends and as macOS 26's variant already does — likely fix is aligning 14/15 to the macOS 26 substring pattern.
  • Bug 3: The shipped test/remediation scripts drive the policy state when executed through Fleet's script feature, or the limitation is documented (affects anyone using these scripts as Fleet remediations on 14/26).

🧑‍💻 Steps to reproduce

These steps:

  • [x] Have been confirmed to consistently lead to reproduction in multiple Fleet instances.
  • [ ] Describe the workflow that led to the error, but have not yet been reproduced in multiple Fleet instances.

Bug 1 (macOS 15 or 26 host, FileVault on):

  1. Apply the 5.3.1 policy from ee/cis/macos-15/cis-policy-queries.yml (or macos-26) to a team containing the host.
  2. Confirm FileVault is genuinely on: SELECT name, role, filevault FROM apfs_volumes; → System + Data filevault=1.
  3. Observe the same output contains ≥1 volume with role="", filevault=0, name like ...SECUREPKITRUSTSTORE_Cryptex (or ..._MACVM_Cryptex for Siri assets).
  4. Run the policy query → 0 rows (fail), and it can never pass. Cross-check via diskutil apfs list -plist on the host: the cryptexes genuinely report Roles = Array {}, sealed, read-only — not a fleetd parsing bug.

Bug 2 (any macOS 14 or 15 host):

  1. Apply the 5.1.7 policy from ee/cis/macos-14/cis-policy-queries.yml (or macos-15).
  2. With no world-writable dirs under /Library, run the policy query → 0 rows (fail).
  3. Diagnostic: the flagged-directories subquery returns exactly /Library/Caches/ (mode 1777).
  4. Root cause check on-host: SELECT CAST('1777' AS INTEGER) & 01000; → 736 (the "octal" literal is decimal 1000).

Bug 3 (macOS 14.6 or 26.x host with a console user logged in):

  1. fleetctl run-script --host <h> --script-path ee/cis/macos-14/test/scripts/CIS_2.7.1_fail.sh
  2. Script exits 1: Could not write domain com.apple.dock; exiting.
  3. Same command against a macOS 15.6 host succeeds and the policy flips to fail — OS-version-dependent.

🕯️ More info (optional)

  • Full QA write-ups with live query transcripts exist in the QA session notes; happy to attach details on request.
  • Bug 1 possible directions: exclude empty-role volumes that are sealed/read-only (needs apfs_volumes schema addition — diskutil exposes the data), or exclude known /System/Library/AssetsV2/... mount-point prefixes (no schema change, more fragile). #49818's internal/external column is a third path that covers it, since the cryptexes report as External.
  • Bug 2 was found incidentally; other octal-literal comparisons across the query sets haven't been audited.
  • Bug 3 in spirit also affects CIS_5.6.sh: dsenableroot -d silently no-ops in Fleet's script channel (Username must be explicitly provided in this shell, exit 0) — the script's final dscl delete AuthenticationAuthority line is what actually flips the policy.

marcusallen97 avatar Sep 03 '26 19:09 marcusallen97

QA Summary

Validated the fixes in PR #52560 for the three CIS macOS defects reported in #52515

Results Table

macOS 14 (Sonoma 14.6)

Check Result Notes
5.3.1 pass state (FileVault on) ✅ 1 row after FileVault re-enabled 09-08; exclusion clause doesn't break a cryptex-free host
5.3.1 fail state (FileVault off) ✅ 0 rows — System/Data still evaluated; new clause doesn't mask real unencrypted volumes
5.1.7 pass state ✅ 1 row with /Library/Caches (1777) present — 14 was never affected by the octal bug (record correction)
5.1.7 fail state (fixture) ✅ Fixture → 0 rows → removed → 1 row, with 14's own query text
2.7.1 fail script via fleetctl run-script ✅ FIXED — exit 0 (was exit 1 Could not write domain); plist wvous-br-corner=6 on disk; policy 0 rows
2.7.1 pass script ✅ Plist restored → 1 row; file ownership mac14:staff after root write (chown works)

macOS 15 (Sequoia 15.6)

Check Result Notes
5.3.1 pass state (FileVault on, PKI cryptex present) ✅ FIXED — 1 row; same host/state returned 0 rows pre-fix (2026-09-03)
5.3.1 fail state (unencrypted volume) ✅ QATestUnencrypted (role="", filevault=0) → 0 rows with cryptex excluded; deleted → 1 row
5.3.1 exclusion specificity ✅ Only the PKI cryptex matches the new clause; requires BOTH empty role and %Cryptex name
5.1.7 pass state ✅ FIXED — 1 row with /Library/Caches (1777) present; previously structurally impossible on 15
5.1.7 fail state (fixture) ✅ Fixture → 0 rows → removed → 1 row — bidirectional for the first time on 15
2.7.1 fail→pass round trip (regression) ✅ Rewritten scripts work end-to-end via fleetctl run-script

macOS 26 (Tahoe 26.5.1)

Check Result Notes
5.3.1 pass state (FileVault on, both cryptexes present) ✅ FIXED — 1 row on the original bug host (Siri ASR + PKI trust store cryptexes, was 0 rows)
5.3.1 fail state (unencrypted volume) ✅ addVolume → 0 rows; deleteVolume → 1 row
5.1.7 pass state (regression) ✅ 1 row; implementation was already correct on 26, untouched by fix
5.1.7 fail state ✅ Original QA fixture evidence stands (0 rows at DB level); query text unchanged by this fix
2.7.1 fail script via fleetctl run-script ✅ FIXED — exit 0, policy 0 rows (previously broken on 26)
2.7.1 pass script ✅ Restored → 1 row; full round trip through the script channel

marcusallen97 avatar Sep 08 '26 14:09 marcusallen97

Policies fail on solid ground sealed volumes hide from sight truth waits for sunlight

fleet-release avatar Sep 21 '26 16:09 fleet-release