Repository navigation
fix(security): stop reading spawn briefs as shell commands in the deny scan - #23334
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. The brief exemption has an issue behind it (#23329) and tests that fail on the base commit. The rule-naming plumbing has one real reader, and the siblings left unfixed are declared and tracked in #23331. What this change shipsInventory (6 items) — 6 justifiedIntent: let a cron, Slack or workflow turn start a sub-agent whose brief only describes a denied step, and show which rule fired when a call is refused. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 8ae825e Description read[DESCRIPTION-READ] 21b266cf26be3e172bcfcf1a6c83301512354b4878b7c4526aa7844e49cda7f3 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. A spawn brief is a prompt that Notes
[DESIGN-REVIEWED] 8ae825e Description read[DESCRIPTION-READ] 7abd1348f8b91b50dbe921e6f6cf324e63ac4e51bec9649594cf176b64b92f47 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 |
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: |
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: |
96fb8dc to
8ae825e
Compare
|
Rebased once onto main for the #23264 Windows fix. |
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed current head 8ae825e8cd88a3ac403824c9023d5b5ef809cd76 as Tier 2. Deep review found no blocking issue.
Security check: only fixed core spawn brief fields skip command-text scanning. Untrusted identities, shell inputs, and all later tool calls still pass the normal gates. Auto-merge remains subject to branch protection.
Problem / Motivation
Goal: An unattended turn can start a sub-agent whose brief merely describes a step a deny rule covers, and a refusal that does happen names the rule that matched.
On cron, Slack, workflow and heartbeat turns, a
spawn_runcall was refused when its brief text contained words that a built-in deny pattern matches, for example a sentence describing a destructive git recovery step, or one mentioning a copy to this host over ssh. The SEL row readalways_deny_input, and the cron reported only that the call was blocked. The same call was accepted from a dashboard chat.Why it matters
Any scheduled or channel-driven orchestration that delegates to sub-agents can fail on the wording of its own instructions. The job is refused, can count toward auto-pause, and the user cannot tell which rule fired or why the dashboard accepted the same request.
Not a goal
cron_add,send_message,workflow_run, ...). Tracked in Deny scan reads other core-tool prose fields (cron_add message, send_message text, workflow_run intent) as commands #23331.argumentsunwrap for this exemption (knowledge_add_document body exemption never fires on real kiro-cli 2.27 frames #16727).What changed (motivation → approach → change)
The always-enforced scan in
_resolve_permissionhanded every string of an MCP tool's params to the command-text rules. A spawn brief is a prompt for another model. The host never runs it. Whatever the sub-agent runs is its own tool call, which goes through its own permission ladder and hook gate.src/kiro_crew/platform/tool_paths.pyMCP_DOCUMENT_BODY_FIELDSlists the brief fields ofkirocrew-core'sspawn_run(task,tasks[],tasks[].task),spawn_continue(task),spawn_steer(message) andspawn_sub_agents(agents[].prompt). A field is a dotted path, andname[]steps into list items.split_document_bodiesfollows those paths without modifying the params. Only a string at the end of a path is split out.src/kiro_crew/llm_helpers_parts/tool_approval.pyon_decisionalso receives the refusal reason that the audit row records.src/kiro_crew/llm_helpers_parts/turn_stream.pyon_tool_gatepasses that reason to the caller as a fourth argument.src/kiro_crew/slack/gateway_runtime/cron_verdict.pyspawn_run (Blocked by security policy: <pattern>).docs/system-specs/modules/security.mdandlearn-cron-dashboard.mddescribe the listed fields and the callback shape.The exemption keeps the existing bar. The
(server, tool)identity must come from the trusted cache (mcp_identity_trusted), the params must be trusted, andis_shellmust be false. A brief keeps the path tier and the size ceiling. Every other field gets the full scan, and so does every other tool, any other server, any untrusted identity or params, and any shell-classified frame.Backwards compatibility
Breaking:
stream_and_collect'son_tool_gatecallback and_resolve_permission'son_decisioncallback each take one more positional argument (reason). A callback written for the old arity raisesTypeError, and the turn swallows and logs it. Writer sweep on origin/main @ 2aa6878: the only production writer isslack/gateway_runtime/cron_turn.py(_GateTally.note, which takesreasonwith a default). The only other callers are tests, updated here (test/test_llm_helpers_tool_gate.py,test/test_transport_permission_floor.py). Test doubles that callon_tool_gatewith three arguments still work, becausenotehas a default.Reader: src/kiro_crew/slack/gateway_runtime/cron_turn.py:_GateTally.note -- cron -- takes the new reason with a default; covered by test_llm_helpers_spawn_brief_scan.py::TestTheRefusalNamesTheRule
Reader: src/kiro_crew/llm_helpers_parts/turn_stream.py:stream_and_collect -- cron|subagent|app -- sole on_decision caller, updated here
Tests
test/test_llm_helpers_spawn_brief_scan.pypins the following:commandcarrying the step is still denied.label,cwd,tasks[].model,agents[].agent_or_mode) are still scanned.on_tool_gatereceives the rule, and the cron summary names it.On the parent commit, 13 of the 29 tests fail.
test/test_llm_helpers_mcp_document_body.pypins the extended table.Determinism: the new tests use no clock, randomness, network or shared state. The file passed 5 repeats and a shuffled order (a fixed-seed shuffle of the collected items). The shuffle is what caught an import that depended on test order: the file now imports
_GateTallythroughkiro_crew.slack.gateway, as the other cron tests do.Manual verification
N/A. The decision is a pure function of the permission event, and the unit tests drive the real
_resolve_permission,stream_and_collectand_GateTally.Related Issues
Closes #23329
Sibling sweep
Swept: git grep -n "MCP_DOCUMENT_BODY_FIELDS|_extract_tool_input_strings(_tool_input)" -- src/
Sibling: src/kiro_crew/platform/tool_paths.py -- changed here
Sibling: src/kiro_crew/mcp_tools/messaging.py -- tracked in #23331
Sibling: src/kiro_crew/mcp_tools/workflows.py -- tracked in #23331
Sibling: src/kiro_crew/mcp_tools/artifacts.py -- tracked in #23331
Pattern harvest
Rule candidate: review-prompt
Pattern: a security scan that reads a field one model writes for another model (a brief, a prompt) as a command line the host runs
Checklist