Skip to content

fix(security): read other agent-tool prose fields as text in the deny scan - #23507

Merged
bolichen97 merged 1 commit into
mainfrom
fix/core-prose-deny-scan
Oct 29, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/core-prose-deny-scan

Conversation

@JLargent42

@JLargent42 JLargent42 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: An unattended run (cron, Slack, workflow, heartbeat) can schedule a job, send a message, start a workflow or monitor, or save a lesson whose text merely mentions a step a deny rule covers, the same way #23334 made that work for sub-agent briefs.

The always-on tool-input deny scan reads every text field of a Kiro Crew tool call as a shell command line. After #23334 that is fixed for the spawn tools, but a cron_add whose agent prompt says "if the tree is broken, the usual recovery is a hard reset; ask first", or a send_message that quotes such a step to a person, is still refused on an unattended surface, while the dashboard accepts the same call.

Why it matters

Scheduled and channel-driven agents routinely write prose about git and shell steps into job prompts, notifications and lessons. Refusing those calls breaks the job with nothing actually run, and the user sees a refusal for text that was never going to execute.

Not a goal

  • Loosening any deny pattern, or the scan of real command fields (command, cmd, script, workflow source).
  • Exempting any field that is executed, deployed or used as arguments (artifact content, cron_update, script-job message).
  • Changing what a downstream agent may run: its own tool calls keep their own gate.

What changed (motivation → approach → change)

The scan already has a reviewed allowlist, MCP_DOCUMENT_BODY_FIELDS in src/kiro_crew/platform/tool_paths.py, of fields on Kiro Crew's own servers that are text, not commands. Listed fields skip the command-text rules but keep the sensitive-path check and the size ceiling. This PR adds the remaining prose fields, each checked against its handler:

Tool Read as text Still fully scanned
cron_add (kirocrew-cron) message (the scheduled agent's prompt) script, command, the rest
send_message / update_message / send_notification text, title, body blocks, url, routing
workflow_run / workflow_author intent source, input, args
monitor_start / monitor_update message banner, target, the rest
learn_add rule, negative category, repo_scope
artifact_post_comment / artifact_reply_comment text slug, parent_id

A script cron job reads message as its arguments, so mcp_document_body_keys in src/kiro_crew/platform/tool_paths.py turns the exemption off for any cron_add call that names script or command (one inline condition, no separate table); with no params passed the exemption is off too. A later row whose field stops being prose when another argument is present must add its condition there in the same change. cron_update and artifact content stay unlisted. llm_helpers_parts/tool_approval.py passes the call's params to the lookup. The security spec (docs/system-specs/modules/security.md) lists the new fields and the exclusions. A refusal still names the rule that matched (from #23334).

Backwards compatibility

Compatible: the change only stops refusing listed prose fields on trusted Kiro Crew tool identities; every call accepted today is still accepted, and mcp_document_body_keys gains an optional params argument.

Removes nothing: no field, key, rule or public function is removed; the scan covers strictly fewer prose strings and the same command strings.

Tests

test/test_llm_helpers_spawn_brief_scan.py gains, for each of the 14 tool fields:

  • prose describing a denied step is allowed;
  • the same step in a non-prose field of that tool is refused, and the refusal names the rule;
  • the same tool on another server keeps the full scan;
  • the field (and not the other one) is listed.

Plus: a cron_add naming script or command keeps message scanned, a command job running the step is refused, the lookup fails closed without params, cron_update is unlisted, a credential path in a prose field is still refused, and artifact content is still scanned. test/test_llm_helpers_mcp_document_body.py pins the full table.

30 new tests fail on #23334's code; all 112 in both files pass with the change, across 5 repeats, reversed order and -n 4.

Manual verification

N/A — the gate is a pure function of the permission event; unit tests drive the real _resolve_permission and audit row.

Related Issues

Closes #23331

Sibling sweep

Swept: every "name": tool entry in src/kiro_crew/mcp_tools/, src/kiro_crew/mcp_cron_tool_list.py and src/kiro_crew/mcp_work.py, reading each string field's handler.
Sibling: src/kiro_crew/mcp_tools/artifacts.py -- not affected -- artifact content can be deployable webapp code, so it stays scanned
Sibling: src/kiro_crew/mcp_cron_tool_list.py -- not affected -- cron_update can retarget an existing script job whose kind the gate cannot see
Sibling: src/kiro_crew/mcp_tools/control_parts/schemas.py -- not affected -- task_run spec stays scanned because it can name a spec file path

Pattern harvest

Rule candidate: review-prompt
Pattern: "a new MCP tool string field that is only stored or handed to a model must be added to MCP_DOCUMENT_BODY_FIELDS with its handler cited, or it is read as a command line by the deny scan"

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • 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

@JLargent42
JLargent42 requested review from a team and KiroCrewCaptain as code owners October 23, 2026 17:13
@JLargent42 JLargent42 self-assigned this Oct 23, 2026
@JLargent42
JLargent42 requested review from chenmingwei23 and removed request for a team October 23, 2026 17:13
Base automatically changed from fix/spawn-brief-deny-scan to main October 23, 2026 17:28
@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 23, 2026
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

@JLargent42
JLargent42 force-pushed the fix/core-prose-deny-scan branch from 6f9c5f8 to c545e11 Compare October 23, 2026 17:51
@JLargent42

Copy link
Copy Markdown
Contributor Author

Retargeted to main after #23334 merged, and rebased once onto main (head c545e11). Related tests and local gates are green on the new head.

@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 8ec5bc57c27624f0f08e6793dc1fddd6ea979a0b and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 8ec5bc5

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 8ec5bc57c27624f0f08e6793dc1fddd6ea979a0b false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 23, 2026
@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 8ec5bc57c27624f0f08e6793dc1fddd6ea979a0b — 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. Each new row is a prose field on Kiro Crew's own tool surface (8 of 8 sampled tool names grepped in src/kiro_crew). The fix reuses the existing MCP_DOCUMENT_BODY_FIELDS allowlist and closes linked issue #23331.

What this change ships

Inventory (9 items) — 9 justified

Intent: let unattended runs schedule jobs, send messages, start workflows or monitors, save lessons and post comments whose text only mentions a denied step, without the deny scan refusing them. This is a FIX.

  1. A cron_add agent prompt that mentions a denied step is no longer refused — justified
  2. send_message/update_message/send_notification text, title and body are read as text — justified
  3. workflow_run/workflow_author intent is read as text — justified
  4. monitor_start/monitor_update message is read as text — justified
  5. learn_add rule/negative are read as text — justified
  6. Artifact comment text is read as text — justified
  7. A cron_add naming script/command, or passed no params, keeps message fully scanned — justified
  8. mcp_document_body_keys gains an optional params argument, with one caller passing it — justified
  9. The security spec lists the new fields and the exclusions — justified

[FIRST-PRINCIPLES-REVIEWED] 8ec5bc5

Description read

[DESCRIPTION-READ] 17af509cf421ec19ad7a9da87cbfdae8f6c5488d2acecf880ccf6769d97b3e25

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 8ec5bc57c27624f0f08e6793dc1fddd6ea979a0b — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: each exempted field is prose handed to a model or a person, every downstream tool call keeps its own gate, and cron_add fails closed when a script job is named.

Notes

  • The cron_add exception is hardcoded inside mcp_document_body_keys. If a second conditional row is ever added, move the condition onto the table row itself rather than adding a second inline special case.

[DESIGN-REVIEWED] 8ec5bc5

Description read

[DESCRIPTION-READ] 519db6540739d68b9267a03a938b706810a0a7496cfc0c4f29208dff508fcff8

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

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 8ec5bc5

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 8ec5bc57c27624f0f08e6793dc1fddd6ea979a0b false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 23, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD (policy: human review required) at c545e11.

This PR narrows what the always-on tool-input deny scan reads as a command line. It adds 11 Kiro Crew tool prose fields to MCP_DOCUMENT_BODY_FIELDS (tool_paths.py#L549-L559). Changes to what the security gate refuses are reserved for a human reviewer.

I found no defect. A cron_add that names script or command keeps the full scan on message, and the lookup fails closed without params (#L611-L614). cron_update and artifact content stay scanned, and cron_update has no script or command field. Exempt fields still get the sensitive-path and size checks. All AI lanes pass, and CI is green. Neither the Design note (future voidable rows need a VOIDED_BY entry) nor the First Principles note (the one-entry table could be inline) has a reply. Both are advisory.

To clear: a maintainer reviews the deny-scan exemptions.

— crew-pr-reviewer (r123)

@JLargent42
JLargent42 force-pushed the fix/core-prose-deny-scan branch from c545e11 to 470e2f3 Compare October 27, 2026 18:59
@JLargent42

Copy link
Copy Markdown
Contributor Author

First Principles note (item 3, one consumer generalized) on c545e119d401c2e897b23a511dfc5688f742a141: fixed in 470e2f36768d7c4c0c2bf1b329f16c17c236ea7b.

Took the subtraction as suggested. MCP_DOCUMENT_BODY_VOIDED_BY is deleted, and mcp_document_body_keys in src/kiro_crew/platform/tool_paths.py now carries the script/command presence check as one inline cron_add condition. Behavior is unchanged: a cron_add naming either key, or a call with no params, still gets no exemption. The security spec (docs/system-specs/modules/security.md) and the PR body now describe the inline condition. Targeted tests (pytest -n 2, 163 in the four deny-scan files and 1,212 across the 22 files that touch tool_paths or _resolve_permission) pass, as do black, isort, flake8, mypy, docs-lint, comment-history and the line cap.

@JLargent42

Copy link
Copy Markdown
Contributor Author

Design note (future voidable rows need a VOIDED_BY entry) on c545e119d401c2e897b23a511dfc5688f742a141: addressed in 470e2f36768d7c4c0c2bf1b329f16c17c236ea7b.

The First Principles note asked for the one-entry table to be inlined, so the table this note refers to no longer exists; the cron_add condition now lives inside mcp_document_body_keys. The rule the note states is kept and written down where a new row gets added: the MCP_DOCUMENT_BODY_FIELDS comment in src/kiro_crew/platform/tool_paths.py and the security spec (docs/system-specs/modules/security.md) both say that a row whose field stops being prose when another argument is present must add that condition to mcp_document_body_keys in the same change, failing closed when params are missing. No row other than cron_add has that shape today.

@JLargent42

Copy link
Copy Markdown
Contributor Author

Re the HOLD at c545e119d401c2e897b23a511dfc5688f742a141 (crew-pr-reviewer r123): both advisory notes now have dispositions.

  • First Principles (one-entry table could be inline): fixed. MCP_DOCUMENT_BODY_VOIDED_BY is removed and the cron_add script/command check is inline in mcp_document_body_keys, same fail-closed behavior.
  • Design (future voidable rows need a VOIDED_BY entry): the table is gone, and the same rule is now stated beside MCP_DOCUMENT_BODY_FIELDS and in the security spec, so a new conditional row has to add its condition to the lookup.

New head: 470e2f36768d7c4c0c2bf1b329f16c17c236ea7b. The exempted field set is unchanged. Targeted tests and local gates pass; CI is re-running. The human review of the deny-scan exemptions stays with a maintainer.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Oct 27, 2026
@JLargent42
JLargent42 force-pushed the fix/core-prose-deny-scan branch from 470e2f3 to 8ec5bc5 Compare October 28, 2026 23:32
@JLargent42

Copy link
Copy Markdown
Contributor Author

Rebased once onto main with operator approval (head 8ec5bc57c27624f0f08e6793dc1fddd6ea979a0b, was 470e2f36768d7c4c0c2bf1b329f16c17c236ea7b), to get a fresh merge ref for the SAST diff-only scan, which hit its 15-minute cap three times on the old one.

  • The rebase was clean. git range-diff shows the commit's patch is identical to 470e2f36, so the First Principles and Design dispositions and the HOLD reply above apply unchanged to this head.
  • Local checks on this head: the targeted deny-scan tests (232 passed, pytest -n 2), the wider tests touching tool_paths / _resolve_permission (1,743 passed, 1 skipped), flake8, isort, black, mypy, comment-history, the line cap and docs-lint all pass. semgrep 1.78.0 with CI's config set passes on the diff with no findings.
  • The human review of the deny-scan exemptions stays with a maintainer.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 28, 2026

@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.

This PR adds 11 Kiro Crew tool prose fields (cron_add message, send_message/update_message/send_notification text, workflow intent, monitor message, learn_add rule/negative, artifact comment text) to MCP_DOCUMENT_BODY_FIELDS, so the deny scan stops reading them as shell command lines. It follows the pattern from PR #23334 and closes issue #23331.

What I verified:

  • cron_add keeps the full scan on message when the call names script or command, and when params are missing (fail closed). kirocrew-cron is the real server name in mcp_cron_tool_list.py.
  • cron_update and artifact content stay scanned. The issue listed both as candidates, and the PR body gives a sound reason to leave each out, matching the issue's own "leave out anything a handler executes".
  • Exempt fields keep the sensitive-path and size checks, and command fields (script, command, workflow source, blocks) keep the full scan.
  • Duplicate check: no other open or merged PR touches these rows, and main does not have the fix yet. The issue is assigned to the PR author.
  • All CI checks and AI lanes are green, and the Design and First Principles notes have dispositions.

No blocking findings. Nice work keeping the exemption table reviewed row by row with each handler cited.

AI-assisted review (Kiro), posted for bolichen.

@bolichen97
bolichen97 merged commit 32c6fb7 into main Oct 29, 2026
108 of 109 checks passed
@bolichen97
bolichen97 deleted the fix/core-prose-deny-scan branch October 29, 2026 01:38
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 29, 2026
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.

Deny scan reads other core-tool prose fields (cron_add message, send_message text, workflow_run intent) as commands

3 participants