Repository navigation
fix: tighten a self-protection check on shell scripts - #32885
Conversation
Sensitive Change ReviewSensitive files changed:
How to clear this check:
Only the author's comment counts this way. A reviewer can instead |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (5 items) — 5 justifiedIntent: a protected command wrapped in a quoted shell script that starts with an assignment is refused the same way as when it is typed directly. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] d42c280 Description read[DESCRIPTION-READ] 537aaa5c2ad66728643d9f57356bee6e722f32ffe041431e5ca5c7ded4785352 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. This reads a quoted script as a whole command line using the parser that already exists, and it refuses only commands that are already refused when typed directly. It adds no new matcher for a single spelling. Notes
[DESIGN-REVIEWED] d42c280 Description read[DESCRIPTION-READ] 27036e1fa5832b0c04de83040228b892c58804270418bf31bfeec93de4767bce 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 |
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: |
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: |
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: No regression has been confirmed by the script; the harness gave this review no verdicts. The change widens the walk of three floors: credential mint, self-kill and ssh self-target. They now also see a carrier's quoted script that opens with an assignment, read whole. I wrote 22 rows at that edge, but none has a verdict yet. TIGHTENING: ADJUDICATED: 22 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: posix (18 rows). These cover the three carriers the diff names (
windows (4 rows). Three cover Git Bash spelled as UNADJUDICATED: The adjudicated shell-command path is the whole tightening. One gap is on the threat side, not the allow side: the new walk is skipped when a payload goes through [SCOPE-REVIEWED] d42c280 |
6476f2c to
16f79f6
Compare
[operator: bolichen97] AI-assisted, posted on behalf of bolichen97 |
[operator: bolichen97] Maintainer ruling: accept the comment refusal. AI-assisted, posted on behalf of bolichen97 |
16f79f6 to
269ddc5
Compare
|
self-added: yes
[operator: bolichen97] |
A command the self-protection floor refuses when it is typed directly is refused the same way when a quoted shell script passed to a shell carries it. Commands that do not reach a protected command are unaffected. Builds on #13261 by @CrysisDeu. Refs #8544
269ddc5 to
d42c280
Compare
|
Rebased: main moved in docs/system-specs/modules/security.md, src/kiro_crew/security/argv_floor.py, src/kiro_crew/security/argv_floor_self.py, src/kiro_crew/security/deny_gate.py, test/test_security_gate_liveness.py since this head went green (3467dd6 -> 756346d); CI re-running. [operator: bolichen97] |
|
self-added: yes
[operator: bolichen97] |
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 14% chance that this change introduces a defect, above the 12% limit for approving on its own. The self-protection floor now reads a quoted carrier script that starts with an assignment as a whole command line, using new frames added on top of the existing ones. That closes a bypass for the mint, self-kill and ssh-self-target checks (e.g. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
buluoray
left a comment
There was a problem hiding this comment.
Approve on d42c280. Deny-only. The self-protection floor now also reads a quoted -c script that opens with an assignment as a command line of its own, so bash -c 'X=kirocrew; $X token' gets the plain form's refusal. The shared shell walk is unchanged, so git-publish and argv rules read exactly what they read before. No new rule or regex. The branch merges cleanly with main. Decisive lines: src/kiro_crew/security/argv_floor_self.py:192 (_quoted_assignment_scripts), src/kiro_crew/security/argv_floor_self.py:218 (_self_frames, plus its use at :838 and :882), src/kiro_crew/security/argv_floor_ssh.py:935 (_reaches_self_over_ssh) wired at src/kiro_crew/security/deny_gate.py:783, src/kiro_crew/security/shell_normalizer.py:974 (_self_tokens(resolve=False)), test/test_denied_commands_security_kill.py:275, test/test_denied_commands_security_ssh_self.py:418
Problem / Motivation
Goal: A command the self-protection floor refuses when it is typed directly is refused the same way when a quoted shell script handed to a shell carries it.
Part of #8544. Builds on #13261 by @CrysisDeu.
The self-protection floor refuses an agent's attempt to run the commands that would disable its own controls. Some shell scripts that run one of those commands, which the shell runs exactly like the plain form, were allowed while the plain form was refused.
Why it matters
An agent could run a protected command the operator never approved, by putting it inside a shell script the floor did not read the way the shell does.
Not a goal
What changed (motivation → approach → change)
An agent that wraps a protected command in a shell script now gets the same refusal it gets when it types the command directly, so the wrapper no longer slips past the self-protection floor. The self-protection floor in
src/kiro_crew/securityreads each quoted script that opens with an assignment as a whole command of its own, its ssh self-target check included, and keeps every frame it read before, so nothing it refused before is allowed. The shared shell reader returns what it returned before, so the git-publish check and the other command rules read exactly what they read before. The security spec underdocs/describes the reading, regression rows undertest/cover it, and the package line budget intest/is raised to the measured size.Backwards compatibility
Compatible: a command is newly refused only when a shell script it carries, read whole, is a command the self-protection floor already refuses when typed directly; ordinary scripts stay allowed. A script that is only printed reads the way one already does:
echo bash -c 'kirocrew token'is refused today, andecho bash -c 'X=kirocrew; $X token'is refused the same way.Removes nothing: no rule, row or allowed ordinary command is removed, and every command refused on main is still refused.
Tests
Regression rows pair the newly refused scripts (
bash -c,zsh -Cc, a long variable name, apkillthrough a variable, ansshto this host through a variable) with the self-protection rule that refuses their plain form; nearby ordinary scripts (one that assigns a file name, one that connects to another host) stay allowed. With the production change reversed, the five refused rows fail and the allowed rows still pass.Proof: PROVEN 5 regression rows fail with the bug reintroduced: 4 credential-mint and kill rows and 1 ssh self-target row (head af0f35ef5df9)
Manual verification
N/A — unit coverage sufficient: the gate is a pure function of the command text, and the tests call it directly. A side-by-side run of the gate with and without the whole-script reading over 45 command shapes found no command that is refused without it and allowed with it; of the 11 it newly refuses, 10 run a protected command inside a shell script and 1 prints one, which is read as main already reads a printed script.
Related Issues
Part of #8544
Sibling sweep
Siblings: none -- both self-protection readers of a carrier's frames (the argv predicates and the ssh self-target check) are changed here; how the other command-text checks, git-publish included, read a carrier is outside this PR's goal and stays with #21682
Pattern harvest
Not generalizable: the maintainer decision on #21682 keeps this shell reader and stops adding rules for one spelling at a time, so there is no lint or review rule to add.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)