Repository navigation
fix(security): exempt the file-search builtin from the curl upload-flag exfil rows - #23845
chenmingwei23 wants to merge 1 commit into
Conversation
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. The exemption requires a host-verified Grep/glob identity and fails closed everywhere else, so the worst case is the false refusal staying where it is today. Notes
[DESIGN-REVIEWED] 37e4456 Description read[DESCRIPTION-READ] f7299d5a3d3516eab6926f7bc3636c5d41e672c9962bd03b9122eb3fbf7f4b3a 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 The exemption is keyed on host-verified tool identity, and issue #23586 plus pinning tests back the defect. It is a point patch: the sibling shell-class rule still judges the same title. Notes
What this change shipsInventory (3 items) — 2 justifiedIntent: let an agent use the built-in Grep/glob tool to search for curl upload-flag text without being refused. FIX.
[FIRST-PRINCIPLES-REVIEWED] 37e4456 Description read[DESCRIPTION-READ] f5894e2c3065e6df9867e0ff74b3a19bcb296a54cfc7638e18922d1faaabb6c7 That sha256 names the PR description this verdict read. 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: |
|
Both findings fixed in bd51de3 (force-with-lease over cf5e919), both now fail closed:
Both are covered by new tests, and the genuine pattern-only file-search exemption still holds. |
Sensitive change review
|
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: This change loosens the gate rather than tightening it. It adds an exemption so the TIGHTENING: None strictly. The only new logic is an early return in the exfil tier ( ADJUDICATED: 14 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: I wrote posix, windows and any rows. The diff makes no new assumption about paths, separators or interpreters: the exemption keys on tool identity and argument shape, and shell command lines never reach it because
There is no platform assumption I could not write a candidate for. UNADJUDICATED: The guard is the
The classifier cannot check these because they are tool calls, not shell lines. One part of the design depends on the host's ACP stamping and is unverified here: an MCP-served or untrusted-identity search tool such as [SCOPE-REVIEWED] 37e4456 |
bd51de3 to
dc1d4a0
Compare
|
Resolved in dc1d4a0 (force-with-lease over bd51de3) by removing the shell-command exception entirely, which is the root both findings targeted.
So neither PATH/LD_PRELOAD nor bare-name resolution is reachable through this PR any more. |
Sensitive change review
|
dc1d4a0 to
cf7bd4d
Compare
Sensitive change review
|
|
Thanks for the probe — fixed at The exemption now requires a positive identity, not just the argument shape: So the
Both carry the flag text in the title and a search-shaped On your second point ( |
Sensitive change review
|
The exfiltration gate's curl body/upload rows match their substring/glob over the
whole command string. The built-in file-search (Grep) tool has no shell command;
its title is LLM-authored prose that can carry the literal, so the rows refused it
even though it uploads nothing.
Fix: the invocation gate skips those rows for a file-search built-in, identified
by its tool kind / argument shape — never by title text, so no title can opt a
shell tool out — and never when a command/cmd argument is recovered
(raw_shell_commands non-empty), so a {command, pattern} frame keeps the full rows.
Every shell-executing tool keeps the full rows. This is the whole change; no
shell-command exception is added.
By design, a command that merely contains the flag text (echo/printf of it) stays
refused, exactly as on main. `date -d @<epoch>` already passes on main via main's
own pre-existing exception and is unchanged here.
3393ad3 to
37e4456
Compare
|
Follow-up — new head Two points surfaced by the review gates on the previous head, both in this diff, are fixed here fail-safe:
The fix and both reviewer-named tests are unchanged in substance; the suite is 17 cases, all green, and isort/black/flake8/mypy are clean. |
|
Follow-up — new head The positive-identity check is strengthened: Coverage of the two kinds you named is unchanged:
plus |
|
Addressed on new head
|
Sensitive change review
|
|
[operator: bolichen97] Continuing this in #31727; thanks for the start. |
A file search for the text `-d @` or `-F x=@` was refused by the exfil gate: with no command, the only text a grep or glob call is judged on is its title, which is the text it searches for, and the curl rows read it as a command line. A call whose host-trusted identity names the grep or glob built-in, with no MCP server and no command of any kind, runs no shell, so the exfil rule no longer judges it. Every other tier still does; an untrusted or MCP-served name, the code built-in and any call carrying a command keep the rule. Builds on #23845.
A file search for the text `-d @` or `-F x=@` was refused by the exfil gate: with no command, the only text a grep or glob call is judged on is its title, which is the text it searches for, and the curl rows read it as a command line. A call whose host-trusted identity names the grep or glob built-in, with no MCP server and no command of any kind, runs no shell, so the exfil rule no longer judges it. Every other tier still does; an untrusted or MCP-served name, the code built-in and any call carrying a command keep the rule. Builds on #23845.
#31727) A file search for the text `-d @` or `-F x=@` was refused by the exfil gate: with no command, the only text a grep or glob call is judged on is its title, which is the text it searches for, and the curl rows read it as a command line. A call whose host-trusted identity names the grep or glob built-in, with no MCP server and no command of any kind, runs no shell, so the exfil rule no longer judges it. Every other tier still does; an untrusted or MCP-served name, the code built-in and any call carrying a command keep the rule. Builds on #23845.
#31727) A file search for the text `-d @` or `-F x=@` was refused by the exfil gate: with no command, the only text a grep or glob call is judged on is its title, which is the text it searches for, and the curl rows read it as a command line. A call whose host-trusted identity names the grep or glob built-in, with no MCP server and no command of any kind, runs no shell, so the exfil rule no longer judges it. Every other tier still does; an untrusted or MCP-served name, the code built-in and any call carrying a command keep the rule. Builds on #23845. (cherry picked from commit de98390)
Problem / Motivation
Goal: stop the built-in file-search (Grep) tool being refused for text that merely appears in its title.
Bug fix: the exfiltration gate's curl body/upload rows match their substring/glob over the whole judged text. A file-search tool call has no shell command; its title is LLM-authored prose that can carry the literal flag text, so the gate refused the search tool even though it runs no shell and uploads nothing (#23586).
Why it matters
A benign file-search for the literal pattern text is blocked, so an agent cannot search the codebase for these flag strings (for example when working on the exfil gate itself). The refusal looks to the agent like a human cancellation.
Not a goal
echo/printfof it) stays refused, exactly as on main.exfil_bash.pyis not changed;date -d @<epoch>keeps passing via main's own pre-existing exception.What changed (motivation → approach → change)
Symptom: a file-search tool call is refused by the exfil tier for its title text. Root cause: the exfil rows are matched against the judged title, and a file-search builtin has no command of its own, so only the title reaches them. Change:
GateFacts.is_file_search_builtinrecognises a file-search builtin by a POSITIVE tool identity and argument shape — never by title text, so no title can opt a shell tool out, and (the stricter part) a call that merely happens to carry apatternargument cannot opt itself in. The exemption fires only when every condition holds: not a shell tool, no recoveredcommand/cmdargument (raw_shell_commandsempty), not MCP-served,call.kind == "search"AND the host-stamped tool name (_meta.kiro.toolName, normalized) is in the new_SEARCH_BUILTIN_TOOL_NAMESset (grep,glob), and the arguments are search-shaped.call.kindis agent-influenced and can only narrow here; the host-stamped tool name is the non-model-authored discriminator, so akind=other/kind=fetchcall that writes apatternargument no longer skips the exfil tier._rule_exfilreturns None only for such a positively-identified search builtin; every other call keeps the full rows.Backwards compatibility
Compatible: the change only ADDS an exemption for a file-search builtin; it rejects/renames/removes nothing main accepts. No public name, config key, or rule id changed, and
exfil_bash.pyand the exfil facade are unchanged from main.Removes nothing: no path is hidden, no record/row deleted, no validator tightened, no key or public function removed — the diff adds one
GateFactsproperty and an earlyreturn Nonein one gate rule.Tests
test/test_exfil_search_tool_carveout_23586.py: a file-search call identified bykind == "search"and thegreptool name is allowed; the same title on a shell tool is refused by the exfil tier; akind=otherframe carrying both a command and a pattern is refused. The positive-identity boundary is pinned by three cases that all stay refused: akind=othercall and akind=fetchcall (the two kinds the probe named) that carry the flag text in the title and a search-shapedpatternargument but no search tool identity, and a shell call that also carries apatternargument.echo/printfof the flag text, plus every upload / wrapper / interpreter / path-qualified form, stay refused. Reverting the gate change makes thekind=otherandkind=fetchboundary cases fail, confirming they pin the defect.Proof: not provable -- the fix is in the invocation gate (
_rule_exfilearly return), not inaudit_bash_exfiltration; the new assertions exercise the fullHookManager.judgepath, and reverting the one-line gate change makes the file-search assertion fail. Classed: other -- gate-layer behaviour exercised through the judge, not a single revertible production hunk prove.py targets.Manual verification
N/A — unit coverage through the real gate (
HookManager.judge) is sufficient; this is a backend-only gate change with no UI.Related Issues
Fixes #23586
Sibling sweep
Swept: git grep -n "is_file_search_builtin|_rule_exfil|_search_deny_target" -- src/kiro_crew
Sibling: src/kiro_crew/hook_runtime/gate_tiers.py:_rule_exfil -- changed here -- the one place the exfil rule runs on a file-search builtin's title.
Siblings: none -- the file-search target (
_search_deny_target) never carried the pattern, so the title path in_rule_exfilwas the only site refusing a search tool for its text.Pattern harvest
Not generalizable: this is a one-off scoping of one tool kind out of one gate rule; the fix is specific to the file-search builtin's title reaching the exfil rows and does not describe a reusable defect class.
CI note
Backend Testsshards 3.12 (4), Windows (4) and macOS (1) report one failure,test/test_governance_policy_viewer.py::TestNoPolicyDefault::test_enterprise_unnamed_scope_reports_the_baseline, withPlatformCompositionError: ... could not fetch the ceiling ... urlopen error ... Name or service not known. This is a runner network/DNS failure reaching the policy source, not a code result: this PR touches no governance/policy code (onlygate_tiers.py,hooks.py, and one new test), and the identical failure appears on unrelated open backend-only PRs. It is main's, left as-is (no rerun). Every other shard and gate is green.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)