Skip to content

fix(security): stop reading spawn briefs as shell commands in the deny scan - #23334

Merged
bolichen97 merged 1 commit into
mainfrom
fix/spawn-brief-deny-scan
Oct 23, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/spawn-brief-deny-scan

Conversation

@JLargent42

Copy link
Copy Markdown
Contributor

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_run call 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 read always_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

What changed (motivation → approach → change)

The always-enforced scan in _resolve_permission handed 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.

Area Change
src/kiro_crew/platform/tool_paths.py MCP_DOCUMENT_BODY_FIELDS lists the brief fields of kirocrew-core's spawn_run (task, tasks[], tasks[].task), spawn_continue (task), spawn_steer (message) and spawn_sub_agents (agents[].prompt). A field is a dotted path, and name[] steps into list items. split_document_bodies follows 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.py on_decision also receives the refusal reason that the audit row records.
src/kiro_crew/llm_helpers_parts/turn_stream.py on_tool_gate passes that reason to the caller as a fourth argument.
src/kiro_crew/slack/gateway_runtime/cron_verdict.py The cron refusal summary names each refused call's rule, for example spawn_run (Blocked by security policy: <pattern>).
docs/system-specs/modules/ security.md and learn-cron-dashboard.md describe 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, and is_shell must 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's on_tool_gate callback and _resolve_permission's on_decision callback each take one more positional argument (reason). A callback written for the old arity raises TypeError, and the turn swallows and logs it. Writer sweep on origin/main @ 2aa6878: the only production writer is slack/gateway_runtime/cron_turn.py (_GateTally.note, which takes reason with 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 call on_tool_gate with three arguments still work, because note has 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.py pins the following:

  • Each brief shape is allowed.
  • The same brief is refused with the rule named when the identity is untrusted.
  • A shell command carrying the step is still denied.
  • A shell frame, another server, an unlisted core tool and untrusted params are all denied.
  • Non-brief fields (label, cwd, tasks[].model, agents[].agent_or_mode) are still scanned.
  • A credential path in a brief is still denied.
  • The child's own shell call running the step is denied by the hook gate.
  • on_tool_gate receives 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.py pins 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 _GateTally through kiro_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_collect and _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

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 8ae825e8cd88a3ac403824c9023d5b5ef809cd76 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 8ae825e8cd88a3ac403824c9023d5b5ef809cd76 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 ships

Inventory (6 items) — 6 justified

Intent: 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.

  1. A spawn_run brief (task, tasks[], tasks[].task) no longer goes through the command-text deny rules — justified
  2. The same exemption covers the spawn_sub_agents prompt (agents[].prompt) — justified
  3. The same exemption covers spawn_continue task and spawn_steer message, which have the same cause — justified
  4. Body-field rows can now name a dotted path that steps into list items (name[]) — justified
  5. The cron refusal summary names the rule behind each refused call — justified
  6. on_decision and on_tool_gate callbacks take a fourth reason argument, which breaks old callbacks (declared) — justified

[FIRST-PRINCIPLES-REVIEWED] 8ae825e

Description read

[DESCRIPTION-READ] 21b266cf26be3e172bcfcf1a6c83301512354b4878b7c4526aa7844e49cda7f3

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 8ae825e8cd88a3ac403824c9023d5b5ef809cd76 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

No design-level concerns. A spawn brief is a prompt that spawn.py hands to a sub-agent model. The host never runs it as a shell command, and the sub-agent's own tool calls still go through its gate. The exemption keeps the trusted-identity, trusted-params and not-shell checks it already had. The only caller with the old arity is _GateTally.note in cron_turn.py, which is listed and handled.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 8ae825e8cd88a3ac403824c9023d5b5ef809cd76 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 8ae825e

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 8ae825e8cd88a3ac403824c9023d5b5ef809cd76: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 8ae825e8cd88a3ac403824c9023d5b5ef809cd76 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 8ae825e

Verdict parsed from the review's SHA-scoped output markers for commit 8ae825e8cd88a3ac403824c9023d5b5ef809cd76.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 8ae825e8cd88a3ac403824c9023d5b5ef809cd76: <one-sentence reason>

@JLargent42
JLargent42 force-pushed the fix/spawn-brief-deny-scan branch from 96fb8dc to 8ae825e Compare October 23, 2026 06:38
@JLargent42

Copy link
Copy Markdown
Contributor Author

Rebased once onto main for the #23264 Windows fix.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 23, 2026
@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Oct 23, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) October 23, 2026 17:26

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@bolichen97
bolichen97 merged commit 56f0193 into main Oct 23, 2026
152 of 156 checks passed
@bolichen97
bolichen97 deleted the fix/spawn-brief-deny-scan branch October 23, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unattended spawn_run refused when its brief text matches a built-in deny pattern

2 participants