Repository navigation
fix(security): read a bare stdin-interpreter heredoc as code, not shell - #22631
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 |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that the stack-only base runs Fast Gate and the floor suites once the PR is retargeted to [DESIGN-REVIEWED] 14eb5d4 Description read[DESCRIPTION-READ] 737eb7de67b909d97b43358396fd25218162010f1782994b8c6efe2dab95d20c 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 frozen Goal still promises case 2, but that work moved to #22649. Confirm that What this change shipsInventory (4 items) — 4 justifiedIntent: let an agent write a doc or fixture through a quoted
[FIRST-PRINCIPLES-REVIEWED] 14eb5d4 Description read[DESCRIPTION-READ] a0535827d91cde354cad32df7ca43660ecf60b9cf25b053bbe624373b3223649 That sha256 names the PR description this verdict read. 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 TIGHTENING: Nothing in this change is stricter. It relaxes the argv row floor in ADJUDICATED: 16 candidates, 0 confirmed newly-refused PLATFORM COVERAGE:
[SCOPE-REVIEWED] 14eb5d4 |
518fd4f to
542c3fd
Compare
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
|
self-added: yes
|
|
[operator: bolichen97] Security Scope Review on |
|
[operator: bolichen97] Sensitive change review: a draft for a maintainer who is not the author. The author does not sign it. To use it, paste the block below into an Approve review on head |
|
[operator: bolichen97] Sensitive change review: a draft for a maintainer who is not the author. The author does not sign it. To use it, paste the block below into an Approve review on head |
|
|
|
HOLD at 14eb5d4. This PR changes what the argv row floor refuses: a text that is a single quoted bare Other blockers:
To clear: a maintainer reviews the floor change, the PR is retargeted to — crew-pr-reviewer (r116) |
Problem / Motivation
Goal: The argv row floor judges a heredoc body by what reads it: interpreter code is not read as shell, and a body written to a file that the command names again is read as commands.
On the #21584 head, two things go wrong (#22332):
python3 -is read as shell. A Python string that mentions a row's words is refused. Main allows it:Why it matters
Case 1 refuses ordinary agent work: writing a doc or a test fixture with a Python heredoc. Case 2 lets a re-spelled destructive command through the floor whose job is to catch it. The maintainer ruled (on #22332) for one design over more case-by-case allowlist patches.
Not a goal
'$(…)'inside an unquoted heredoc, which the payload walk reads as single-quoted. It is the same on the fix(security): read command-literal deny rows off the argv, not one spelling #21584 head for every program (cat,bash); it is reported on argv row floor: heredoc-as-data rule over-refuses interpreter heredocs, misses file-then-run #22332, not fixed here.What changed (motivation → approach → change)
This PR ships case 1 only. Case 2 is moved to #22649: matching the written file's name refused ordinary write-then-use flows (Security Scope Review), and a separate tool call gets past it anyway (Design Review). Nothing here is allowed that the #21584 head refuses, except the one case below.
python3 - <<'EOF' … EOF(orpython3,node,nodejs) and nothing else<<EOF)bash -c/eval<input, pipe or non-ASCII openerperl,ruby,bash -sSymptom → cause: the floor sorted heredocs by the opener's program word, and every program that is not
git,gh,catorteehad its body read as shell.Change in
security/argv_row_floor.py: a bare stdin interpreter counts as a non-shell reader under strict conditions:-Each condition closes a bypass a reviewer found: a rebound name, a parent frame, a shell-expanded body, or the reader and the shell closing the body on different lines (a backslash-newline, an escaped delimiter, a NUL). The security spec describes the rule, and the package line budget grows by 111 lines.
Backwards compatibility
Compatible: the only verdict that changes is one refusal becoming an allow, for a text that is a single quoted bare
python3/nodeheredoc. Nothing that works today stops working.Removes nothing: no rule, pattern, pass or opt-out is removed.
Tests
test/test_argv_row_floor.py, 41 new cases:python3 -case from argv row floor: heredoc-as-data rule over-refuses interpreter heredocs, misses file-then-run #22332,python3with no-,python3 - a b,node -, and output redirects after the delimiter.-cbefore or after the delimiter (also behind2>/dev/null),node … -e, a script path,-u -,| sh,sudo,X=1,<x,bash -s, perl and ruby backticks../python3,ln -s /bin/sh python3,python3() { sh; },export PATH=…, same-linehash -p, a variable-spelledhash -p, a later command, and an exported function aroundbash -coreval.$( )behind Python quotes), a backslash-newline in a quoted body (<<'EOF'and<<-'EOF'),<<'E\OF'and mixed-quote delimiters, a NUL in the closing line, and a\x1for no-break space on the opener line.The 5 allowed cases are red on the parent head
aa2fb16c8dand green here. The 36 refused cases are already refused there; they pin that nothing new gets through. All 253 existing tests pass unchanged. Determinism: repeats under-n2, and once serially in a seeded shuffled, reversed order. A probe set of 30 inputs run on both heads differs only on the bare interpreter cases.Manual verification
N/A: unit coverage is sufficient. The floor is a pure function of the command text. Each allowed shape was also run under bash with a harmless marker in place of the command: the body went to Python, never to the shell.
Related Issues
Closes #22332
Part of #16475
Pattern harvest
Not generalizable: the defect is this floor's own choice to sort a heredoc by the opener's program word. The fix narrows that rule for one reader; there is no wider code shape to lint for.
Sensitive change review
Draft for a maintainer who is not the author. The author does not sign it.
python3/nodestdin heredoc.os.system). This floor never read interpreter semantics; the inline-payload tier and the sandbox own that, as on main.is_deniedonly.Checklist