Repository navigation
fix(sel): make the audit log owner-only on Windows - #31703
Conversation
|
[operator: bolichen97] Backend Tests (3.12, 2) is red on test_security_gate_liveness.py::test_the_package_stays_within_its_line_budget. This PR does not touch the security package; the red comes from main and is tracked in #31648. Waiting for that fix, then rebasing. |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The gate this PR adds is the third copy of the same inline calling-thread DACL gate. There is no shared symbol it could reuse instead, so this is a note, not a blocker. Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: keep other local Windows accounts from writing the SEL audit log. FIX.
[FIRST-PRINCIPLES-REVIEWED] 288277b Description read[DESCRIPTION-READ] 34117d6aa2b38c6197ba501fdbe97f6867f63058486ffe5efaa97baa76987d77 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this replaces the Notes
[DESIGN-REVIEWED] 288277b Description read[DESCRIPTION-READ] deef6ebec9998925bfe1b167d0f02713eb28040468edb19976ae313f4190a321 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
ff91f77 to
bd9b8f9
Compare
|
Rebased: main moved in docs/system-specs/modules/artifacts.md, learn-cron-dashboard.md, memory-skills-hooks.md, slack-gateway.md, workflows.md since this head went green (a31eccd -> 39717a0); main also carries #31625, which fixes the inherited security line-budget red. CI re-running. [operator: bolichen97] |
|
[operator: bolichen97] Backend Tests (3.12, 7) is red on test_pull_request_target_allowlist.py::test_only_the_allowed_workflows_use_pull_request_target (sensitive-change-review.yml). This PR touches no workflow; the red comes from main and is tracked in #31771. Waiting for that fix. |
bd9b8f9 to
288277b
Compare
|
Rebased: main moved in docs/system-specs/modules/dashboard-token-auth.md, learn-cron-dashboard.md, src/kiro_crew/tips.py, tips_allowlist.py since this head went green (39717a0 -> 7c364bc); main also carries #31803, which fixes the inherited pull_request_target allowlist red (#31771). CI re-running. [operator: bolichen97] |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved for the on-call. Review lanes pass on 288277b, no conflict, no open change request.
(cherry picked from commit d939b8c)
Problem / Motivation
Goal: The SEL audit log (
security_events.jsonl) is owner-only on Windows, not just on POSIX.On Windows,
os.chmod(path, 0o600)only toggles the read-only attribute. The SEL writer insel_append.pyused that call, so the audit log kept whatever DACL it inherited. A log under%TEMP%stays writable bySYSTEMandAdministrators. This is the last open item of the post-icacls cleanup.Why it matters
The audit log is the tamper-evident record of tool calls. Other local accounts should not be able to write it. A log that does not inherit an owner-only DACL (created before the data home was tightened, restored from a backup, or a home whose tightening failed) stays open today.
Not a goal
chmodsite. The one found in the sweep is tracked in platform: redaction allowed-hosts file is not owner-only on Windows #31688.critical=Trueaudit-or-deny semantics: a failed lockdown still warns and the append still lands.What changed (motivation → approach → change)
Each append now locks the live log down with
platform_compat.restrict_to_owner, a real owner-only DACL on Windows andchmod 0o600on POSIX. It runs right afteros.openand beforeos.fdopen, the shapecheck_lockdown_before_publish.pyblesses.The append can run on the event loop, where a DACL write to a network volume could stall on SMB. So it follows the calling-thread rule
write_config_atomicallyset forconfig.json: on the loop on Windows, a volumewindows_acl.volume_is_localdoes not call local (or cannot judge) skips the DACL with a warning.The call carries no
lockdown-okmarker. The lockdown checker's header andKNOWN_UNCONVERTEDnote do not cite SEL as a reviewed exception, andsel.mdstates the rule.Backwards compatibility
Compatible: the log is still written the same way; only its Windows DACL is narrower, and a lockdown failure still only warns.
Removes nothing: no key, path, function or record is removed; the only change to existing behaviour is a stricter DACL on a file the writer already owns.
Tests
test/test_sel_log_lockdown.py::test_windows_append_applies_an_owner_only_dacl(Windows): after one critical append undertmp_path, the DACL is not null and its writers are onlyOWNER RIGHTSand the current user.test/test_sel_log_lockdown.py::test_on_loop_append_skips_a_non_local_volume_and_warns[remote|unknown](Windows; forcingIS_POSIXoff on POSIX would route the SEL chain lock tomsvcrt): on the loop, a non-local or unjudgeable volume skipsrestrict_to_owner, the critical append still lands, and one warning names the skip.test/conftest.pyopts the new module out of the autouse Windowsrestrict_to_ownerstub, like the other real-DACL modules.Proof: PROVEN test/test_sel_log_lockdown.py::test_windows_append_applies_an_owner_only_dacl, test/test_sel_log_lockdown.py::test_on_loop_append_skips_a_non_local_volume_and_warns[remote], test/test_sel_log_lockdown.py::test_on_loop_append_skips_a_non_local_volume_and_warns[unknown] (head 198dd30e8a5f)
Determinism: the new module passed 5 runs in file order and 3 runs in reversed order on Windows,
-n0.test_sel_bindings.py,test_lockdown_before_publish.py,test_workflows_store_lockdown.py,test_sel_edge_cases.py, the flake-pattern ratchet andcheck_lockdown_before_publish.pypass.Manual verification
Windows Server 2025 Datacenter 10.0.26100.
ensure_data_homealready tightened:icaclsshows onlyOWNER RIGHTS:(I)(F)and the user(I)(F), all inherited. So on this host the live log already happened to be owner-only through inheritance.%TEMP%(what the old code left in place):NT AUTHORITY\SYSTEM:(I)(F),BUILTIN\Administrators:(I)(F),OWNER RIGHTS:(I)(F).SecurityEventLogwith this change in the same%TEMP%dir:OWNER RIGHTS:(F)and the user(F), explicit, no inherited ACEs.SYSTEMandAdministrators) and passes with the fix, as theProof:line records.Screenshots / video
N/A -- no frontend change.
Related Issues
Closes #6359
Sibling sweep
Swept: git grep -nE "os.chmod([^)]*0o600" -- src/
Sibling: src/kiro_crew/sel_append.py -- changed here
Sibling: src/kiro_crew/security/redaction_allow.py -- tracked in #31688
Sibling: src/kiro_crew/sel_rotation.py -- not affected -- the rotation lock file holds no data
Sibling: src/kiro_crew/apps/builtins/code_review_sage/sage_lib/store.py -- not affected -- standalone fallback outside the runtime; the runtime path already uses restrict_to_owner
Pattern harvest
Rule candidate: review-prompt
Pattern: a bare
os.chmod(..., 0o600)used as a lockdown is inert on Windows; userestrict_to_ownerunder the calling-thread rule of #6992, as #24585 did for the workflow store.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)