Repository navigation
fix(security): make security audit scan session transcripts - #27257
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Sensitive change review
|
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the audit now reads the session transcripts it was meant to check, and an empty scan no longer reports clean. Notes
[DESIGN-REVIEWED] 5b09753 Description read[DESCRIPTION-READ] 0a5d2ae3dabec4b299edf27219c9e642b648f6ff7ad596f426a9f15c3ccb94ba 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The fix is aimed at the cause: the audit read the wrong folder. Each added piece supports the frozen Goal of reading the newest transcript rows and never calling an unread scan clean. What this change shipsInventory (8 items) — 7 justifiedIntent: let an owner who runs
[FIRST-PRINCIPLES-REVIEWED] 5b09753 Description read[DESCRIPTION-READ] 004255ad5704b6371ccf9e50511da154e5b7dffabfa4ee7dd257b27261eb4852 That sha256 names the PR description this verdict read. 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: |
Security Scope Review -- ✅ PASSWhich legitimate operations does Verdict basis: adjudicated, zero confirmed regressions. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: PASS Reason: The patch leaves the tool-call deny composite ( TIGHTENING: ADJUDICATED: 17 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: posix and windows.
UNADJUDICATED: The guard is
None of this can be expressed as a gate refusal, so it doesn't block. [SCOPE-REVIEWED] 5b09753 |
738bf7a to
01a93ca
Compare
|
|
Sensitive change review
|
01a93ca to
5faac82
Compare
|
|
Sensitive change review
|
5faac82 to
322d459
Compare
|
Rebased: main moved in docs/system-specs/modules/security.md since this head went green (2d57650 -> e666f7a); CI re-running. Same push fixes two backend reds on 5faac82: |
Sensitive change review
|
Sensitive change review
|
Sensitive change review
|
|
New head 3b82e51. GPT's upheld finding on 070b784 was real and narrow: a folded tool call kept its first row's time, so a call approved after another transcript gained newer rows fell out of the newest 100. Both sites it named are fixed. A later row of the call now moves the entry to the newest end and gives it that row's time, so eviction follows the same order. A new test fails on 070b784 and passes here. Nothing else changed. The line budget is +107 over main (34,074). Backend shard 7's red on the last head was a pip download timeout in setup, not a test. |
Sensitive change review
|
Sensitive change review
|
Sensitive change review
|
Sensitive change review
|
|
Thanks for this PR. It now conflicts with main. Could you rebase onto the latest main and resolve the conflicts? That also brings in #29623, which raises the time limit in |
Sensitive change review
|
|
HOLD for human review at This PR rewrites I found no concrete defect on this head. Rows stream through What clears this: a maintainer's review of the audit behaviour change. — crew-pr-reviewer (r146) |
Sensitive change review
|
Sensitive change review
|
Sensitive change review
|
Sensitive change review
|
Sensitive change review
|
Sensitive change review
|
|
Security Scope Review on head e1dbaf1 needs a maintainer override, please. Its first run on this head could not finish: the publish step hit the GitHub API rate limit and published a failure without a verdict. The rerun at 00:40 UTC adjudicated the change as a pass with zero confirmed regressions, but the per-head floor keeps the earlier failure. Candidates, validation and adjudication on all three platforms passed. This is the third head where a rate-limited first run left that hold. The change itself is unchanged since the earlier passes. I will not push again for this. |
Sensitive change review
|
|
Security Scope Review on head 49bc5f5 needs a maintainer override, please. Every real lane on this head passed: candidates, validation, and adjudication on all three platforms. Only the final publish step failed, because it hit the GitHub API rate limit, and the per-head floor now holds that failure. The change is the same as the earlier heads that passed. I will not push or rerun for this. |
Sensitive change review
|
Sensitive change review
|
bolichen97
left a comment
There was a problem hiding this comment.
Approving 5b09753 as maintainer. All 112 checks pass. Fixes #27254.
What I checked:
kirocrew security auditnow readssessions/*.jsonl, where transcripts actually live, instead of the oldhistorydirectory. It still matches with the existingaudit_bash_command/SUSPICIOUS_BASH_PATTERNS, so no new pattern and no new refusal. It is a read-only report.- An empty or missing sessions folder now says nothing was scanned instead of printing "No suspicious tool usage found", and an unreadable file is a finding. So a clean result means rows were actually read.
- Tool rows take their command from
meta.inputthrough the tool gate's own extractor (shell_command_from_tool_params). Only the kinds that cannot run a shell are skipped, and the up to three rows of one call fold into one entry by a digest oftool_call_id. - Memory stays bounded. Each file keeps only its newest
last_nentries with a capped snippet, and the merged list is cut tolast_nby rowts, with the file mtime as fallback. - Printed file names, warnings and snippets go through
safe_terminal_line, so transcript text cannot drive the terminal.
Auto-merge is already set by the author, so I am not setting it.
Problem / Motivation
Goal:
kirocrew security auditchecks the newest session transcript rows and never calls a scan clean when it read nothing.The audit read
~/.kiro/crew/history/, the Slack observe-mode channel buffer, not~/.kiro/crew/sessions/. It never saw an agent transcript, so it always printed "✅ No suspicious tool usage found in recent history."Why it matters
An owner who runs the audit gets a clean result that checked nothing. A flagged shell command in a transcript is never reported. Runtime command gating is not affected; only this report is wrong.
Not a goal
audit_bash_commandflags.sessions/archive/.What changed (motivation → approach → change)
The audit pointed at the wrong folder and read each file from its head. It now reads
sessions/*.jsonl.tsscan_historyinsecurity/memory_audit.pyreads the transcript row shape: assistant text, and the shell command in a tool row'smeta.input, read withshell_command_from_tool_params, a thin wrapper inagent_sdk/__init__.pyover the tool gate's own extractor, souse_awspayloads count too. A tool row whose ACPkindcan never run a shell command (read, edit, delete, move, search, think, fetch, switch_mode) is not read as a command; for any other kind, an input stored cut off (not valid JSON) is audited as its text. The rows of one tool call share atool_call_idand fold into one entry, ascompaction_keepfolds them; a later row of the call moves the entry to the newest end with that row's time, so a call approved after newer rows still counts as recent. It reads records throughjsonl_util.bounded_records, skips the metadata header, audits each row as it reads it, and keeps only the row's time, warning and a 200-character snippet, keyed by a fixed-size digest of its call id, so memory stays bounded. It returns(findings, rows_scanned)socli_commands_security.pycan tell "read nothing" from "clean", and the CLI says whether transcripts were absent or held nothing. Each finding prints on one line, a small readability tidy-up. Thesecurity.mdspec line names the new behaviour.Backwards compatibility
Compatible: the CLI verb, its flags and its exit codes keep their meaning.
scan_historyhas one production caller, updated here.Removes nothing: the audit reads a different folder and reports more; no option, key or record goes away.
Tests
test_security_stream_redaction.py::TestScanHistory: tool-row commands (Bash,use_awsand cut-off shell oruse_awsinputs), the newest rows of a long file, rows picked by timestamp across files (offset-free legacytsread as local time, atsahead of its file mtime, boundary-year stamps), an unreadable file or one past the JSON parser limits as a finding, the empty and missing folder; one call over three rows is one finding and one slot; a call approved after another transcript gained newer rows still counts as recent; areadrow is not audited while anotherrow is; akindof the wrong type does not stop the scan; a file removed mid-scan is skipped; a huge flagged row is kept as its bounded snippet.test_cli_commands_coverage_agent_security.py: a seeded transcript under a temp data home gives one finding and exit 1; an empty home prints the not-scanned line, not the green check; transcripts holding no rows print "held no rows to audit", not "none found".test_scan_memory_stores.py: the empty-home audit now asserts the not-scanned line instead of the old clean line.test_security_gate_liveness.py: thesecuritypackage line budget rises by 107 from main's 34,894 to 35,001 for this change (the net linesmemory_audit.pyadds), with a note naming what grew.TestScanHistoryclass passed 3 runs in a row. The tests usetmp_pathand fixed timestamps only.Proof: PROVEN test/test_cli_commands_coverage_agent_security.py::TestSecurityCli::test_audit_reads_session_transcripts, test/test_cli_commands_coverage_agent_security.py::TestSecurityCli::test_audit_with_no_transcripts_says_nothing_was_scanned, test/test_cli_commands_coverage_agent_security.py::TestSecurityCli::test_audit_of_transcripts_with_no_rows_does_not_say_none_were_found, test/test_scan_memory_stores.py::TestAnInstallWithNoNamedStoresIsUnchanged::test_a_clean_global_lessons_file_leaves_the_verdict_clean, test/test_security_stream_redaction.py::TestScanHistory::test_budget_spans_files_newest_first (head 5b09753)
Manual verification
N/A — unit coverage sufficient: the CLI tests run the real
_securityaudit path against files on a temp data home.Related Issues
Fixes #27254
Sibling sweep
Swept: git grep -nE 'config_dir() / "history"' -- src/
Siblings: none -- no other reader treats the channel-history folder as session transcripts
Pattern harvest
Not generalizable: one CLI verb pointed at the wrong data folder; no other audit reads that folder.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)