Skip to content

fix(security): read the program word of every command in the publish floor - #18871

Closed
cruisercohen wants to merge 2 commits into
mainfrom
fix/publish-floor-program-word
Closed

cruisercohen wants to merge 2 commits into
mainfrom
fix/publish-floor-program-word

Conversation

@cruisercohen

@cruisercohen cruisercohen commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The git-publish floor judges every publish whose program word the shell resolves at run time, wherever it sits on the command line.

The floor recognised a runtime-resolved program word ($G push ...) only in a few top-level spellings. The same publish was not judged when the word was quoted ("$G", "${G}"), wrapped in a path ("/usr/bin/$G"), spelled as a glob that can name git (g?t), or placed in a compound construct (if/case/for/while bodies, subshells, brace groups, function bodies), behind a precommand (sudo, env, nice -n 5, timeout), after a newline, a glued separator or a background &. A literal feature push elsewhere on the line, or among the command's own arguments, could also stand in for the unjudged one. In each case is_denied returned allow for a command that publishes to a branch the gate cannot determine.

Why it matters

The git-publish floor is the only enforcement for pushes. An agent command that reaches a protected branch through one of these spellings is not stopped.

Not a goal

  • A runtime-resolved SUBCOMMAND (git "$P" origin main, git pu$X ...): a separate class.
  • A backslash-newline between a literal git and its subcommand, and trap '<cmd>' EXIT payloads: existing gaps in other parts of the walk, tracked separately.
  • Changing any catalog rule or opt-out.

Backwards compatibility

Compatible: only commands that run push under a runtime-resolved program word change verdict. Another tool's push behind a variable whose argv reads as a bare or single-positional git push ("$DOCKER" push img, "$HG" push) is refused by the bare / single-arg rows, which operators can disable; the unquoted $DOCKER push img is already refused on main. Accepted fail-closed costs of the same kind: a program word carrying an unquoted expansion ($ANDROID_HOME/platform-tools/adb push app.apk /sdcard/, $VENV/bin/dvc push -r storage), whose value is split into words and may name any program first, so even an argv git would reject proves nothing (the quoted "$VENV/bin/dvc" push -r storage stays allowed); "$GIT" -C "$WORKTREE" push, since lowercased -C cannot be told from -c; and a runtime tool's push after an option and a runtime value ("$TOOL" --flag "$V" push).

Removes nothing: the change only adds detection; no rule, key or public function is removed or renamed.

What changed (motivation → approach → change)

Symptom: the publish detector matched the program word textually, so quoting, nesting and precommands moved it out of the shapes it knew. Root cause: there was no notion of PROGRAM POSITION on the raw, quote-aware command text.

Change:

  • New publish_program_word.py in the security package (kept apart so the argv floor's modules stay under the per-module cap). _runtime_publishes splits the text into the commands the shell runs at top level (;, |, newline, non-redirection &, bare ( / ); never inside $(...), ${...}, <(...) or backticks, which the payload walk judges as their own sources), folds line continuations, and walks each command's raw words. Program position opens at the first word, after ! { do elif else if then until while, after function NAME, and after a precommand's options and positional operands; assignments and redirections keep it open.
  • The normalizer pass of _is_git_publish (_is_git_push_via_normalizer, as on main) and the _GIT_ARG_FLAGS set it reads move into a new sibling module, publish_subcommand.py, and argv_floor_git.py re-binds both names; publish_program_word.py reads the flag set from there too. The pass moves unchanged. The flag set gains git's three other value-taking global options, --attr-source, --config-env and --super-prefix, so the word after one is read as its value, as git reads it, and a runtime-program publish after one ("$G" --super-prefix x push origin feature) is judged by its target, as one after -C is.
  • A program word whose top-level basename carries $ or a backtick, or is an unquoted glob that can name git, followed by the push subcommand, is a runtime-program publish. A literal basename behind a variable directory ("$SDK/platform-tools/adb") is that program.
  • _git_publish_floor_tags judges each runtime-program publish on its own, so a sibling command or a feature push in its arguments cannot answer for it. When the program word is ONE double-quoted parameter expansion and the words up to push are literal, git's argv is known and is read with the literal-push grammar (protected / bare / single-arg rows as usual); otherwise the existing ungated unverifiable deny applies.
  • A runtime publish read on the whole folded source vouches that a push was seen only when that source runs no literal publish; a literal publish a backslash-newline splits out of every segment ("$G" push origin feature; git \<newline> push origin main) still reaches the unverifiable fallback, as on main.
  • The segment splitter keeps a $(...) / ${...} / backtick span whole, so a ;/&/|/newline inside a command substitution is read as the substitution's own and does not cut the surrounding command; a publish glued to such a span (git$(echo ' ';)push origin main) is then judged as the one command it is rather than left in an unrecognised fragment. A plain ( subshell or { group is unchanged.
  • The _is_git_publish docstring, the security spec and the package line budget are updated.
  • Comments (an unquoted word-start # to its newline) are cut before the read, with the quote state restarted after them, so a quote inside a comment cannot hide the next line. Every heredoc body is cut from the command text around it, so a quote inside it cannot reopen that text, and is then read as command text of its own (up to a fixed nesting depth, past which the text is unverifiable). The delimiter is read by bash's quote removal ($'EOF', E\OF and E""OF are EOF; "E\OF" is E\OF; $X is literal); a delimiter this reading cannot reproduce exactly is unverifiable. A body fed to a data sink (gh issue|pr|release, git commit|notes|tag, no editor option) is data, but only when the rest of the text runs inert companions alone (cd, ls, pwd, true, test, echo, sleep, git add|diff|log|rev-parse|show|status, no assignment before them) and carries no >, $(, backtick, <(, ${ or function definition: any other program could install a hook, filter, editor or PATH entry that runs the body. An unquoted delimiter's body is joined across trailing backslashes before the delimiter comparison, as bash joins it, and is never data when it carries an expansion.
  • Every substitution body ($(...), backticks, <(...), >(...), ${...}) is read in a quote context of its own, as bash reads it even inside double quotes, so a quote, comment or heredoc inside one cannot reopen the command text around it; each command substitution body is read again as command text. A program word carrying an unquoted expansion anywhere ($G/repo) is a runtime program, since the value is split into words.
  • Precommand short-option clusters are read as getopt reads them (env -iu NAME), and command -v/-V are lookups that run nothing.
  • A double-quoted program word whose backslashes sit before ordinary characters ("$HOME\bin\git.exe", "$env:ProgramFiles\Git\cmd\git.exe") is one word and is judged by its target.
  • Assignments read as bash reads them (NAME+=value, NAME[i]=value) keep program position open, and an & is a redirection only beside an active < or > (an escaped \>& still ends the command).
  • A precommand that changes the argv it hands on (xargs, parallel, watch) makes a runtime-program publish behind it unverifiable, and a program word's ANSI-C quoting is decoded before it is classified ($'adb' is adb).
  • Glob quoting is read per character, so g"i"[t] keeps its active [t]; a \ is read both as a Windows separator and as a POSIX escape.
  • Only a precommand's value-taking options consume the next word (nice -n, sudo -u, timeout -s, ...), so command -p echo "$G" push and nice -n5 echo ... read echo as the program.
  • A redirection glued to a word ("$G"</dev/null, push>log) is cut off it, a redirection target is consumed whole (>$(echo /dev/null)), coproc NAME { ... } reads its group, and an extglob group in the program basename (g@(i)t) is a runtime program word.
  • A known-argv runtime publish's own program word ("${GIT}") no longer counts as expansion glue for the segment, and a _GIT_ARG_FLAGS value that is one quoted parameter expansion (-C "$REPO") keeps the argv known.
  • A double-quoted $(...) whose body is only cat printing one quoted-delimiter heredoc, inside a command text whose other commands are sinks or inert companions, is message text: its body is data, and is_denied does not read the payload walk's lifted copy of it on its own.
  • A precommand option whose letter cases differ on taking a value (xargs -l/-L, sudo -p/-P) is read both ways on the lowercased text. A word that can expand to no word (${x:-${y:-}}, "$@$@", an extglob under nullglob) leaves program position open. The sink editor check matches abbreviations (--edi).
  • Read with \ as an escape, a program word's $ counts only while the literal text after its last expansion could end git or git.exe, so "$env:ProgramFiles\...\docker.exe" push img names docker.exe on both readings of \.
  • Every word is read as the shell hands it over, ANSI-C decoded ($'env' is env). Precommand value options are listed across the GNU, BSD and util-linux spellings (env -a, BSD env -P, sudo --chroot, watch -q), a long option is read by any prefix of a value-taking one (env --un NAME), and --attr-source joins git's value-taking global flags. A word taken as an option's value that itself runs push under a runtime program is unverifiable.
  • Once the walk reads a word whose arity it cannot know (a runtime word that may be a dispatcher or an option, an option spelled with an expansion or a glob, an option value an unquoted expansion can split, an abbreviation that may be a no-value option such as sudo --login, any option of parallel), any later runtime word running push is unverifiable: "${1:-env}" -i "${2:-git}" push origin main, flock "$F" echo "$G" push origin main, env -u $1 "$2" push origin feature. --config-env and --super-prefix take git's next word, and a ) or } closes only the opener it matches ("${1:-x)/adb}" has no top-level /).
  • The floor's per-line segments restart the quote state at every newline. A line that starts inside a quote is also judged in that quote (echo "a then b"; "$G" push origin main), and a line wholly inside a quoted argument (a multi-line --body "... * push the branch", a PowerShell here-string) is marked as text when no other segment is spelled like it.
  • git fetch and git push (unless they carry a transport-program option, --upload-pack, --receive-pack, --exec, or a prefix of one) and cat are inert companions beside a sink; glab issue|mr|release is a sink; cat <<'EOF' | gh pr create --body-file - feeds the sink; a plain ${NAME} and the word after a sink's value-taking option (--head "$BRANCH") void nothing; a CRLF printer is a printer.
  • A body cat or tee only writes to a plainly named file (not a device path, not a path git reads, not in a pipeline), in a whole command text beside only sinks and companions, is data: it runs only through a reader set up before the command, which would run whatever any command writes there. Beside a git, gh or glab (which run hooks a repository may keep executable, such as .husky/pre-commit), and in a sink body beside a plain test or build runner (make test, uv run pytest -q), the body stays command text and only a leading markdown bullet is read as :.
  • Each queued heredoc body on one line is read in a quote context of its own (cat <<'A'; bash <<'B'), a line continuation between a substitution opener's two characters ($\<newline>() still opens it, and an unquoted glob that can expand to an option name (--[e]dit, *) counts as the editor option. The plain runners a sink's bullet is text beside are make, pytest, ruff check|format, npm|pnpm|yarn test, npm|pnpm|yarn run <script> and pre-commit run, with plain words only; chmod of plainly named paths beside a body only written to a file leaves that body data.
  • A one-word quoted program ("$DVC" push -r storage) whose argv after push opens with a short option git push does not take publishes nothing as a git push: git exits with a usage error before it reads a remote. An unquoted variable path ($VENV/bin/dvc push -r storage) stays refused, a deliberate fail-closed cost: split, its value can be any program first (bash -c with a payload of its own), so an argv git would reject proves nothing about it.
  • Bash ends a heredoc body only at a line that matches its delimiter case for case, while the floor reads the command lowercased. Where a body line matches its delimiter only in another letter case, the floor also reads the command with no heredoc and line by line, and judges each reading as a publish source like any other, so a heredoc with no protected publish (a Ruby or Lua end under <<END) keeps its reading and operator opt-outs apply as usual.

Alternatives considered and rejected:

  • Extending _GIT_PUBLISH_SUBST_PROGRAM_RE: a whole-string regex cannot track quoting or compound grammar. It stays as the existing cheap first pass; the new pass is the canonical reader for this class.
  • Tracking program position on normalize_shell_command tokens: those are dequoted and drop newlines, so quoted ) / ; read as syntax and newline-separated commands merge.
  • Treating every runtime program word followed by push as unverifiable: refuses "$G" push origin feature, "$HELM" push chart oci://... and similar commands whose argv is fully known.
  • Reading every word after a precommand as a candidate: refuses sudo echo "$x" push; precommand operands are modelled instead.
  • Cutting every heredoc body as data when its reader writes to a named file: a later >&3, a FIFO or link set up in the same command, a write inside a substitution whose output a shell reads, or a hook a git beside it runs hands the body back to a program. Only a plain file write in a whole command text beside sinks and companions is data. A heredoc fed to another program, or to a sink beside a program that can run code the text carries, whose text itself reads as a runtime-program push ("$X" push origin main) over-refuses.
  • Letting any plain external program sit beside a sink: a test runner or build tool can write a hook or a filter config that runs the body. Beside a plain runner only a markdown bullet is text.
  • Judging an unquoted variable path ($ANDROID_HOME/platform-tools/adb push ...) by its literal basename, as the quoted form is: split, its value may be git with options of its own that move the target the written words name (-c remote.origin.push=feature:main turns a written origin feature into an update of main).
  • Treating cat as a sink in general: its output is the body, and a process substitution read by a shell (bash <(cat <<'EOF' ...)), bash -c "$(cat <<'EOF' ...)", eval, a pipe into a shell or an unquoted substitution runs or re-splits it. Only the double-quoted printer feeding a sink or companion is data, and is_denied skips the payload walk's lifted copy of exactly that body.

Tests

test/test_git_publish_program_word.py (713 cases): one-word runtime programs judged by target; multi-word, glob and substitution program words unverifiable; every program position (newline, glued and background separators, continuation, redirections, precommands with options, ANSI-C and abbreviated options, words of unknown arity, split option values, mismatched closers, every compound construct, functions, case patterns glued to the program, quoted backticks, substitution-valued flag operands, pipes inside substitutions, lines that start inside a quote, sibling and argument-carried feature pushes, nested payloads); ordinary commands and the legitimate operations the scope lane listed (adb, dvc, helm, cachix, multi-line quoted bodies, push or fetch beside a sink, file writes, cat into a sink, glab, CRLF printers, bullets beside a plain runner) stay allowed, and each new exemption has refusal cases for the spellings that could run the body. Every case added for the last two review rounds fails on the head before it and passes here. test_security_gate_liveness.py: package budget re-pinned with its reason.

Security suites (push branch gate, security, denied-commands, hooks, deny guidance, argv floor, regex linearity, facade, rule seam, read-only filters, gate liveness and the program-word suite; 3,902 tests) pass locally on this head.

Manual verification

N/A — the gate is a pure function of the command text and the cases drive is_denied end to end.

Related Issues

Fixes #17745

Pattern harvest

Rule candidate: review-prompt
Pattern: a command-shape detector that matches a program name textually instead of reading program position on quote-aware shell words misses quoted, nested and precommand spellings.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 10, 2026
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/__init__.py

  • src/kiro_crew/security/argv_floor.py

  • src/kiro_crew/security/argv_floor_git.py

  • src/kiro_crew/security/deny_gate.py

  • src/kiro_crew/security/publish_heredoc.py

  • src/kiro_crew/security/publish_program_word.py

  • src/kiro_crew/security/publish_subcommand.py

  • src/kiro_crew/security/rm_floor.py

  • src/kiro_crew/security/shell_normalizer.py

  • src/kiro_crew/security/shell_normalizer_walk.py

  • @cruisercohen comment (80 comments checked, none complete): does not name the current head fde505b; post it again for this head

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: fde505b089c1d6f3c0d4a65ee4ebd6c0a4c3bd04
- 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 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision fde505b089c1d6f3c0d4a65ee4ebd6c0a4c3bd04 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 Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

No blocking design issue: the subject really is a shell command line, the sandbox does not hold pushes, and the change only adds detection that fails closed. Reverting it is clean.

Notes

  • This adds about 2,500 lines of hand-written bash grammar (publish_program_word.py alone is 1,915 lines, past the 1,600-line split threshold). That is the spelling chase AGENTS.md warns about. A structural control at the git layer, such as a pushurl/credential fence the sandbox owns, would end this class instead of extending it; record that as the follow-up.
  • Heredoc data-sink lifting (publish_heredoc.py, the _data_printer_sources change in deny_gate) and the flock -c payload in shell_normalizer.py are separate concerns. They would review and revert more cleanly as their own PRs.
  • The span-aware _split_push_command_segments now changes how a shared splitter treats $(...). Today its only production caller is the new module. A test that pins this would stop later callers from inheriting it without knowing.

[DESIGN-REVIEWED] fde505b

Description read

[DESCRIPTION-READ] 41c3c142780c9816259996b366633984ee3968300351393e8a8b9a49307362d1

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 10, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

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

No item fails on reading alone. The heredoc exception lists are the sort of spelling-chase AGENTS.md calls a review smell, but whether they are the cause or a symptom is a judgement call, and they can be deleted later.

Notes

  • Item 5 — oversized: publish_heredoc.py carries ten exception tables (_HEREDOC_SINKS, _SINK_COMPANIONS, _PLAIN_RUNNER_RE, _HOOKLESS_SIBLING_RE, _BULLET_RE, _FILE_WRITE_RE, _CHMOD_RE, _MKDIR_RE, _GIT_HOOK_NAMES, _RUNNER_RECIPE_NAMES). Their only job is to stop false denials that the PR's own glob reading creates when it treats a document's * push … bullet as a program word. The budget comment shows them added round by round: hook names, Makefile, .sh, mkdir, .github. Subtraction: defer the bare-* glob program reading and the sink, companion and runner tables to their own PR. Ship the quoted, compound and precommand reading alone.
  • Item 1 — duplicate of argv_floor_git.py:102 _GIT_PUBLISH_SUBST_PROGRAM_RE: the spec hunk calls pass 3 "the canonical reader of runtime program words", but pass 1 still matches the same shape. Subtraction: delete _GIT_PUBLISH_SUBST_PROGRAM_RE and its pass-1 clause.
  • Item 9 — undeclared: the flock -c payload branch in shell_normalizer.py adds a new nested-payload source. The goal does not name it, and the description shown before its 8,000-byte cut-off never mentions it. Subtraction: move it to its own PR.

What this change ships

Inventory (10 items) — 6 justified

Intent: stop an agent from reaching a protected branch through a push whose program word the shell resolves at run time. FIX.

  1. Quoted, path-wrapped or glob program words running push are now judged — justified
  2. The same publish is caught inside compound blocks, after precommands, after a newline or after & — justified
  3. "$G" push origin feature with literal words up to push is judged by its target, not refused outright — justified
  4. Heredoc and substitution bodies are read as command text, and past a fixed nesting depth the text is unverifiable — justified
  5. Heredoc bodies fed to sinks next to companion commands or runners, and markdown bullets, are treated as data — oversized
  6. An unquoted expansion path to a program ($VENV/bin/dvc push) is now refused — justified
  7. Git's --attr-source, --config-env and --super-prefix now take a value — justified
  8. The segment splitter keeps $(...) spans whole — rides along
  9. A flock -c script is judged as a nested shell payload — undeclared, rides along
  10. is_denied adds case-folded readings of heredoc delimiters — justified

[FIRST-PRINCIPLES-REVIEWED] fde505b

Description read

[DESCRIPTION-READ] 02c29124c4ea46648291ef0b5569c7eae4d60e3a7cdd06554e1d5ad5d1d3168e

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 10, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — 🔴 changes requested (blocking)

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

Blocks: a here-doc inside a $(...) printer body that ends on a line reading TAG) lets a runtime-resolved-program push to a protected branch through the floor, which is the class this change is meant to deny.

BLOCKING — src/kiro_crew/security/publish_heredoc.py:458
if (line.lstrip("\t") if heredoc.strip_tabs else line) == heredoc.tag:
Trigger: G=git; echo "$(cat <<'TAG'⏎body⏎TAG)"⏎"$G" push origin main⏎TAG⏎)". Here is_denied → _executable_text → _heredoc_bodies_end only ends the body at a line that is exactly TAG. So the body runs on to the later plain TAG line, and "$G" push origin main gets read as printer data. Bash 5.2 ends the here-doc and the substitution at TAG), printing only a warning. It then runs the next line as a command, which I confirmed by running the script under bash with G=echo.
Outcome: is_denied returns None for this command, so the gate allows it, while bash runs the push to main. The same text with a literal git push origin main is denied (git-publish-push-protected-branch-name), so only the runtime-program spelling this PR adds gets through.
Anchor: residual/security
Fix: in _heredoc_bodies_end, when the body sits inside a $( or backtick span, also end it at a line that starts with the tag followed by ). Otherwise, return _UNREADABLE for any line that is the tag plus a trailing closer, so the reading fails closed.

Notes:

  • publish_program_word.py arrives at 1,915 lines, past the 1,600 working target in keep-modules-small, a non-blocking rule.

[BLOCK-MERGE] fde505b
[OPUS-REVIEWED] fde505b

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

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

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 985d008
  • What rule changed: the git-publish floor's detector (_is_git_publish) gains a program-position pass on quote-aware shell words. A segment that runs the push subcommand under a program word the shell resolves at run time (an expansion, a path around one, a glob that can name git, a substitution) is treated as an unverifiable publish, wherever that program position is: after a newline, a glued separator, & or |&, inside if/case/for/while/until/select bodies, subshells, brace groups, function bodies, or behind a precommand or redirection. _git_push_args returns no parse for such a segment and the payload-defer branch refuses to defer for it. No catalog row, opt-out or allow path changes.
  • Before -> after (what was allowed/blocked, now): before, is_denied allowed for example "$G" push origin main, g?t push origin main, if true; then "$G" push; fi, sudo -u root "$G" push origin main, true & "$G" push origin main, and "$G" push origin main ; git push origin feature. After, each is denied under git-publish-target-unverifiable. Literal feature pushes (git push origin feature, also under nice, time, if, cd &&, bash -c) stay allowed, and commands that only mention push as an argument stay allowed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): breaks commands. A command whose runtime-resolved program is followed by a literal push word for another tool ("$DOCKER" push img) is refused as unverifiable; the unquoted $DOCKER push img is already refused on main, so this matches the existing policy. No secret handling and no lock-out path is touched.
  • Evidence checked (which sandbox result proves it): test/test_git_publish_program_word.py drives is_denied end to end on 113 commands; 79 deny cases fail on main and pass on this head, and the 34 allow cases pass on both. Two independent review passes probed further shapes against main and this branch; every bypass they found in this class is pinned there.
  • No regression:
    • Tools still work (which tools/commands were run, result): the allow cases cover ordinary developer commands (literal feature pushes, loops, case statements, $(date) arguments, quoted ) ; ( { arguments, "$EDITOR" file, background jobs, git status piped to grep push); all allowed.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or call signature changes; the new detection is an extra pass and every existing caller of the floor is unchanged. Existing push-gate tests pass unchanged.
    • Existing tests (which suites passed on this head): push branch gate, push guard, security, denied-commands (security, api, authority, hooks, governance), raw command deny hooks, deny guidance, argv floor scope, regex linearity, security facade and rule seam: 3714 passed locally. CI matrix on this head is reported by the checks.
  • How to undo: revert the single commit; the floor returns to its previous detection.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- 🔴 BLOCK (blocking)

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

Verdict basis: a script-confirmed newly-refused operation.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 26 classified, 4 newly refused, 21 still allowed.
  • ubuntu-latest (platform posix): 26 classified, 4 newly refused, 21 still allowed.
  • windows-latest (platform windows): 16 classified, 3 newly refused, 12 still allowed.

Newly refused (confirmed by the real classifier at both refs)

  • `npx eslint src/ --max-warnings 0 && git commit -m "$(cat <<'EOF'
    fix(ui): example
  • push notifications render once
    EOF
    )"` (any, leg macos-latest)
    • Who loses it: A worker runs the frontend lint gate (already a corpus row) and commits in one call. npx is neither an inert companion nor a listed plain runner, so the body is read as command text and the '* push' bullet may become an unverifiable publish.
    • Refused by: deny-rules -- Blocked by security policy: .git\s+(-\S+\s+[^-]\S\s+|-\S+\s+)push\s+[^&|;\n]{[^{}](,|..)[^{}]}
      Matched structurally on the command's argv, not by the pattern text above: shell substitution or expansion fuses text into the push target, so the destination branch cannot be determined before t
  • `python3 scripts/docs_lint.py && git commit -m "$(cat <<'EOF'
    docs: example
  • push guard steps documented
    EOF
    )"` (any, leg macos-latest)
    • Who loses it: The docs gate (a corpus row) chained before a heredoc commit. For git sinks the patch accepts only the stricter companion list, not the python-script sibling, so the bullet line sits right at the boundary.
    • Refused by: deny-rules -- Blocked by security policy: .git\s+(-\S+\s+[^-]\S\s+|-\S+\s+)push\s+[^&|;\n]{[^{}](,|..)[^{}]}
      Matched structurally on the command's argv, not by the pattern text above: shell substitution or expansion fuses text into the push target, so the destination branch cannot be determined before t
  • $ANDROID_HOME/platform-tools/adb push app-debug.apk /sdcard/Download/ (posix, leg macos-latest)
    • Who loses it: The unquoted spelling Android docs and READMEs give for the sideload; the patch names it an accepted cost. Submitted so the loss is measured, not assumed.
    • Refused by: deny-rules -- Blocked by security policy: .git\s+(-\S+\s+[^-]\S\s+|-\S+\s+)push\s+[^&|;\n]{[^{}](,|..)[^{}]}
      Matched structurally on the command's argv, not by the pattern text above: shell substitution or expansion fuses text into the push target, so the destination branch cannot be determined before t
  • "$DOCKER" push registry.example.com/kirocrew-crew-base:ci (posix, leg macos-latest)
    • Who loses it: An operator with DOCKER=podman publishing the crew base image (scripts/publish_crew_base_image.sh pushes the same tag); the patch names quoted-variable docker push an accepted cost.
    • Refused by: deny-rules -- Blocked by security policy: git-publish-push-single-arg
      Matched structurally on the parsed push arguments, not by the pattern text above: the push names a remote but no branch, so it publishes to the configured upstream. (rule pattern: .git\s+(-\S+\s+[^-]\S\s+|-\S+\s+)push\s+\S+\s$)
      Refusal diag
  • `npx eslint src/ --max-warnings 0 && git commit -m "$(cat <<'EOF'
    fix(ui): example
  • push notifications render once
    EOF
    )"` (any, leg ubuntu-latest)
    • Who loses it: A worker runs the frontend lint gate (already a corpus row) and commits in one call. npx is neither an inert companion nor a listed plain runner, so the body is read as command text and the '* push' bullet may become an unverifiable publish.
    • Refused by: deny-rules -- Blocked by security policy: .git\s+(-\S+\s+[^-]\S\s+|-\S+\s+)push\s+[^&|;\n]{[^{}](,|..)[^{}]}
      Matched structurally on the command's argv, not by the pattern text above: shell substitution or expansion fuses text into the push target, so the destination branch cannot be determined before t
  • `python3 scripts/docs_lint.py && git commit -m "$(cat <<'EOF'
    docs: example
  • push guard steps documented
    EOF
    )"` (any, leg ubuntu-latest)
    • Who loses it: The docs gate (a corpus row) chained before a heredoc commit. For git sinks the patch accepts only the stricter companion list, not the python-script sibling, so the bullet line sits right at the boundary.
    • Refused by: deny-rules -- Blocked by security policy: .git\s+(-\S+\s+[^-]\S\s+|-\S+\s+)push\s+[^&|;\n]{[^{}](,|..)[^{}]}
      Matched structurally on the command's argv, not by the pattern text above: shell substitution or expansion fuses text into the push target, so the destination branch cannot be determined before t
  • $ANDROID_HOME/platform-tools/adb push app-debug.apk /sdcard/Download/ (posix, leg ubuntu-latest)
    • Who loses it: The unquoted spelling Android docs and READMEs give for the sideload; the patch names it an accepted cost. Submitted so the loss is measured, not assumed.
    • Refused by: deny-rules -- Blocked by security policy: .git\s+(-\S+\s+[^-]\S\s+|-\S+\s+)push\s+[^&|;\n]{[^{}](,|..)[^{}]}
      Matched structurally on the command's argv, not by the pattern text above: shell substitution or expansion fuses text into the push target, so the destination branch cannot be determined before t
  • "$DOCKER" push registry.example.com/kirocrew-crew-base:ci (posix, leg ubuntu-latest)
    • Who loses it: An operator with DOCKER=podman publishing the crew base image (scripts/publish_crew_base_image.sh pushes the same tag); the patch names quoted-variable docker push an accepted cost.
    • Refused by: deny-rules -- Blocked by security policy: git-publish-push-single-arg
      Matched structurally on the parsed push arguments, not by the pattern text above: the push names a remote but no branch, so it publishes to the configured upstream. (rule pattern: .git\s+(-\S+\s+[^-]\S\s+|-\S+\s+)push\s+\S+\s$)
      Refusal diag
  • `npx eslint src/ --max-warnings 0 && git commit -m "$(cat <<'EOF'
    fix(ui): example
  • push notifications render once
    EOF
    )"` (any, leg windows-latest)
    • Who loses it: A worker runs the frontend lint gate (already a corpus row) and commits in one call. npx is neither an inert companion nor a listed plain runner, so the body is read as command text and the '* push' bullet may become an unverifiable publish.
    • Refused by: deny-rules -- Blocked by security policy: .git\s+(-\S+\s+[^-]\S\s+|-\S+\s+)push\s+[^&|;\n]{[^{}](,|..)[^{}]}
      Matched structurally on the command's argv, not by the pattern text above: shell substitution or expansion fuses text into the push target, so the destination branch cannot be determined before t
  • `python3 scripts/docs_lint.py && git commit -m "$(cat <<'EOF'
    docs: example
  • push guard steps documented
    EOF
    )"` (any, leg windows-latest)
    • Who loses it: The docs gate (a corpus row) chained before a heredoc commit. For git sinks the patch accepts only the stricter companion list, not the python-script sibling, so the bullet line sits right at the boundary.
    • Refused by: deny-rules -- Blocked by security policy: .git\s+(-\S+\s+[^-]\S\s+|-\S+\s+)push\s+[^&|;\n]{[^{}](,|..)[^{}]}
      Matched structurally on the command's argv, not by the pattern text above: shell substitution or expansion fuses text into the push target, so the destination branch cannot be determined before t
  • & $env:LOCALAPPDATA\Android\Sdk\platform-tools\adb.exe push app-debug.apk /sdcard/Download/ (windows, leg windows-latest)
    • Who loses it: The unquoted PowerShell spelling of the sideload. PowerShell does not word-split a variable, but the floor's POSIX split-into-words rule may still treat it as unverifiable.
    • Refused by: deny-rules -- Blocked by security policy: .git\s+(-\S+\s+[^-]\S\s+|-\S+\s+)push\s+[^&|;\n]{[^{}](,|..)[^{}]}
      Matched structurally on the command's argv, not by the pattern text above: shell substitution or expansion fuses text into the push target, so the destination branch cannot be determined before t

Each row above is an operation that the base ref ALLOWS and this change REFUSES. Narrow the rule at the tier named. Withdrawing a row is not the way to green: that is its own pull request, on its own merits.

Scope-Verdict: PASS

Reason: No candidate came back script-confirmed as newly refused, so nothing meets the BLOCK bar. The patch itself names two narrowings as accepted costs, which are argued and not confirmed. First, an unquoted variable path to a non-git tool followed by push ($ANDROID_HOME/platform-tools/adb push …) is refused whatever its arguments. Second, a quoted-variable tool push with a bare or single-positional argv ("$DOCKER" push img) is judged as a git push. Rows for both were submitted so the fold measures them rather than leaving them assumed.

TIGHTENING: the git-publish floor's detector _is_git_publish gains a third, program-position pass. It also re-reads heredoc and quoted bodies as command text unless they feed a recognised sink, and re-reads the whole command when a line matches a heredoc delimiter only after case-folding. The one threat it refuses is a push run under a program word the shell resolves at run time, which no literal git token reveals: + # Pass 3: a program word the shell resolves at run time, in program position / + # anywhere on the line (``"$G" push``, ``if x; then g?t push; fi``). / + return _runs_runtime_program_publish(text_lower) (argv_floor_git.py), with the case-folded re-reading in deny_gate.py: + for reading in _submodule("publish_heredoc")._case_folded_readings(tool_name).

ADJUDICATED: 31 candidates, 0 confirmed newly-refused

PLATFORM COVERAGE:

  • posix: rows cover quoted, braced and unquoted variable program paths ("$GIT", "$ANDROID_HOME/…/adb", "${ANDROID_HOME}/…/adb", $ANDROID_HOME/…/adb, "$DOCKER", "$PYTHON"). They also cover precommands (timeout, env, flock -c), compound program position (if … then … fi), the chained-redirection reading (>/dev/null 2>&1, 2>&1 | tail), -C "$WORKTREE", and /tmp heredoc file writes beside a gh sink. These are the assumptions the program-word, redirection and file-write readers make on a POSIX shell.
  • windows: rows cover the PowerShell $env: variable with \ separators and a .exe basename, both for git.exe (which must stay an allowed feature push) and adb.exe (which the tail reader must not take for git). They cover the unquoted PowerShell variable path, which PowerShell does not word-split but the floor's _splits_into_words assumes is split. They also cover the Git Bash /c/Program Files/…/git.exe spelling and the c:/… drive-letter file-write target that _FILE_PATH explicitly allows.
  • any: rows cover the platform-neutral heredoc and quoted-body shapes. That means the sink, printer and cat-pipe forms (git commit -m "$(cat <<'EOF' …)", git commit -F -, gh pr create --body, cat <<'EOF' | gh … --body-file -), multi-line --body/-m bullets, and the sibling-class boundary (an inert companion, a plain runner uv run pytest, and the unlisted siblings npx eslint and python3 scripts/docs_lint.py), each carrying a * push … markdown bullet.
  • Not probed: the cmd.exe %VAR% program-word spelling, because the new reader keys on $/backtick/glob and draws no inference from %. Also not probed: the case-folded heredoc re-reading in deny_gate.py, because a legitimate operation that has a case-only delimiter-matching body line and a publish-shaped line could not be attributed to a real workflow.

[SCOPE-REVIEWED] fde505b

The confirmed rows, in the committed corpus's own shape
{
  "golden_paths": [
    {
      "kind": "shell",
      "command_or_flow": "npx eslint src/ --max-warnings 0 && git commit -m \"$(cat <<'EOF'\nfix(ui): example\n\n* push notifications render once\nEOF\n)\"",
      "platform": "any",
      "reason": "A worker runs the frontend lint gate (already a corpus row) and commits in one call. npx is neither an inert companion nor a listed plain runner, so the body is read as command text and the '* push' bullet may become an unverifiable publish."
    },
    {
      "kind": "shell",
      "command_or_flow": "python3 scripts/docs_lint.py && git commit -m \"$(cat <<'EOF'\ndocs: example\n\n* push guard steps documented\nEOF\n)\"",
      "platform": "any",
      "reason": "The docs gate (a corpus row) chained before a heredoc commit. For git sinks the patch accepts only the stricter companion list, not the python-script sibling, so the bullet line sits right at the boundary."
    },
    {
      "kind": "shell",
      "command_or_flow": "$ANDROID_HOME/platform-tools/adb push app-debug.apk /sdcard/Download/",
      "platform": "posix",
      "reason": "The unquoted spelling Android docs and READMEs give for the sideload; the patch names it an accepted cost. Submitted so the loss is measured, not assumed."
    },
    {
      "kind": "shell",
      "command_or_flow": "\"$DOCKER\" push registry.example.com/kirocrew-crew-base:ci",
      "platform": "posix",
      "reason": "An operator with DOCKER=podman publishing the crew base image (scripts/publish_crew_base_image.sh pushes the same tag); the patch names quoted-variable docker push an accepted cost."
    },
    {
      "kind": "shell",
      "command_or_flow": "& $env:LOCALAPPDATA\\Android\\Sdk\\platform-tools\\adb.exe push app-debug.apk /sdcard/Download/",
      "platform": "windows",
      "reason": "The unquoted PowerShell spelling of the sideload. PowerShell does not word-split a variable, but the floor's POSIX split-into-words rule may still treat it as unverifiable."
    }
  ]
}

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings (all downgraded on adjudication)

GPT 6.1 flagged blocking issues on fde505b089c1d6f3c0d4a65ee4ebd6c0a4c3bd04; Opus 5.5 adjudication downgraded every one of them. Downgraded: the remedy each one needs is disproportionate to the harm it prevents. Adjudication downgraded all 1 blocking finding(s): the remedy each one requires is disproportionate to the harm it prevents.

This comment is updated in place on each push.

Review details

BLOCKING -- src/kiro_crew/security/shell_normalizer.py:1316 -- Limit flock payload extraction to its own command option

j = _first_stop_at_or_after(flag_stops, i + 1)
Trigger: flock /dev/null printf '%s\n' -c 'git push origin main' reaches is_denied → _shell_payload_sources → _nested_shell_payloads, which treats printf’s -c argument as flock’s command option.
Outcome: The shell gate newly blocks a harmless printing command. Executing it exits successfully and only prints the arguments; the base extractor allows it.
Anchor: defect
Fix: Extract a flock payload only when flock occupies program position and -c/--command belongs to that invocation; stop scanning at its dispatched program or command boundary.
Sites: echo flock /dev/null -c 'git push origin main'; printf '%s\n' flock /dev/null -c 'git push origin main'; flock /dev/null true; echo -c 'git push origin main'.

[BLOCK-MERGE-DOWNGRADED] fde505b
[GPT-REVIEWED] fde505b

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1 — LOW. The failure is a false denial of a harmless command, and it is loud: is_denied returns a reason string (src/kiro_crew/security/deny_gate.py:419), and the docstring there says over-blocking is the intended safer direction. It only happens when the literal word flock appears anywhere in the tokens and is followed later by a -c carrying a denied command line. The flock branch matches on any token whose basename is flock, not only a program-position one (src/kiro_crew/security/shell_normalizer.py:1313), and then takes the first -c/--command stop after it across the whole token list (:1316). The agent recovers by rewording the command; nothing is lost.
The real fix needs a flock-specific option grammar (-w <secs>, -E <code>, file/dir operand, dispatched program) plus a command-boundary and program-position notion that this linear token walk (:1205-1225) does not have. That is a mechanism serving only this path, in an already dense hot function, and it costs more than a rare, visible, self-correcting false deny.

[ADJUDICATION] fde505b089c1d6f3c0d4a65ee4ebd6c0a4c3bd04 total=1 uphold=0 downgrade=1
DOWNGRADE F1 src/kiro_crew/security/shell_normalizer.py:1316 reason=disproportionate-remedy
[GPT-ADJUDICATED] fde505b089c1d6f3c0d4a65ee4ebd6c0a4c3bd04

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

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

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: b2d916c
  • What rule changed: the git-publish floor's detector (_is_git_publish) gains a program-position pass (publish_program_word.py) on quote-aware shell words. It finds a push run under a program word the shell resolves at run time (a basename carrying an expansion or substitution, or an unquoted glob that can name git) in every program position: after any separator, inside compound constructs, subshells and case arms, behind precommands and redirections. When the program word is one double-quoted parameter expansion and the words up to push are literal, the push is judged by its target with the existing literal-push rules; any other such push is the existing unverifiable deny. No catalog row or opt-out changes.
  • Before -> after (what was allowed/blocked, now): before, "$G" push origin main, g?t push origin main, if true; then "$G" push; fi, sudo -u root "$G" push origin main, true & "$G" push origin main, and "$G" push origin main ; git push origin feature were allowed. After, each is denied (protected-branch, bare, or unverifiable). "$G" push origin feature, literal feature pushes, programs with a literal basename behind a variable directory ("$ANDROID_HOME/platform-tools/adb" push ..., "$VENV/bin/dvc" push), and "$HELM" push chart oci://... stay allowed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): breaks commands. Another tool's push behind a variable whose argv reads as a bare or single-positional git push ("$DOCKER" push img, "$HG" push) is refused by the bare/single-arg rows, which operators can disable; the unquoted $DOCKER push img is already refused on main. No secret handling or lock-out path is touched.
  • Evidence checked (which sandbox result proves it): test/test_git_publish_program_word.py drives is_denied end to end on 130 commands, including every shape the review lanes reported on the previous head and the legitimate operations the scope lane listed.
  • No regression:
    • Tools still work (which tools/commands were run, result): the allow cases cover literal feature pushes, loops, case statements, $(date) arguments, quoted ) ; ( { arguments, "$EDITOR" file, background jobs, sudo echo "$x" push, nice -n 5 make "$T" push, adb/dvc/helm/cachix; all allowed.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or call signature changes; every existing caller of the floor is unchanged and the existing push-gate tests pass unchanged.
    • Existing tests (which suites passed on this head): push branch gate, push guard, security, denied-commands (security, api, authority, hooks, governance), raw command deny hooks, deny guidance, argv floor scope, regex linearity, security facade, rule seam, gate liveness: 3741 passed locally.
  • How to undo: revert the two commits; the floor returns to its previous detection.

@cruisercohen
cruisercohen force-pushed the fix/publish-floor-program-word branch from b2d916c to 9ce2f9a Compare October 10, 2026 16:04
@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 9ce2f9a
  • What rule changed: the git-publish floor's detector (_is_git_publish) gains a program-position pass (publish_program_word.py) on quote-aware shell words. It finds a push run under a program word the shell resolves at run time (a basename carrying an expansion or substitution, or an unquoted glob that can name git) in every program position: after any separator, inside compound constructs, subshells and case arms, behind precommands and redirections. When the program word is one double-quoted parameter expansion and the words up to push are literal, the push is judged by its target with the existing literal-push rules; any other such push is the existing unverifiable deny. No catalog row or opt-out changes.
  • Before -> after (what was allowed/blocked, now): before, "$G" push origin main, g?t push origin main, if true; then "$G" push; fi, sudo -u root "$G" push origin main, true & "$G" push origin main, and "$G" push origin main ; git push origin feature were allowed. After, each is denied (protected-branch, bare, or unverifiable). "$G" push origin feature, literal feature pushes, programs with a literal basename behind a variable directory ("$ANDROID_HOME/platform-tools/adb" push ..., "$VENV/bin/dvc" push), and "$HELM" push chart oci://... stay allowed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): breaks commands. Another tool's push behind a variable whose argv reads as a bare or single-positional git push ("$DOCKER" push img, "$HG" push) is refused by the bare/single-arg rows, which operators can disable; the unquoted $DOCKER push img is already refused on main. No secret handling or lock-out path is touched.
  • Evidence checked (which sandbox result proves it): test/test_git_publish_program_word.py drives is_denied end to end on 132 commands, including every shape the review lanes reported on the previous head and the legitimate operations the scope lane listed.
  • No regression:
    • Tools still work (which tools/commands were run, result): the allow cases cover literal feature pushes, loops, case statements, $(date) arguments, quoted ) ; ( { arguments, "$EDITOR" file, background jobs, sudo echo "$x" push, nice -n 5 make "$T" push, adb/dvc/helm/cachix; all allowed.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or call signature changes; every existing caller of the floor is unchanged and the existing push-gate tests pass unchanged.
    • Existing tests (which suites passed on this head): push branch gate, push guard, security, denied-commands (security, api, authority, hooks, governance), raw command deny hooks, deny guidance, argv floor scope, regex linearity, security facade, rule seam, gate liveness: 3743 passed locally.
  • How to undo: revert the two commits of this PR; the floor returns to its previous detection.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Oct 10, 2026
@cruisercohen
cruisercohen force-pushed the fix/publish-floor-program-word branch from 9ce2f9a to daa9801 Compare October 10, 2026 18:16
@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 10, 2026
@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: daa9801
  • What rule changed: the git-publish floor's detector (_is_git_publish) gains a program-position pass (publish_program_word.py) on quote-aware shell words. It finds a push run under a program word the shell resolves at run time (a basename carrying an expansion or substitution, or one whose unquoted glob characters can name git, quoting read per character) in every program position: after any separator, inside compound constructs, subshells and case arms, behind precommands, their value-taking options and redirections. Comments, and the body of a quoted-delimiter heredoc fed to a literal data reader that writes to a named file, are not read as commands. When the program word is one double-quoted parameter expansion and the words up to push are literal, the push is judged by its target with the existing literal-push rules; any other such push is the existing unverifiable deny. No catalog row or opt-out changes.
  • Before -> after (what was allowed/blocked, now): before, "$G" push origin main, g?t push origin main, g"i"[t] push origin main, if true; then "$G" push; fi, sudo -u root "$G" push origin main, true & "$G" push origin main, a push on the line after a comment holding a quote, and "$G" push origin main ; git push origin feature were allowed. After, each is denied (protected-branch, bare, or unverifiable). "$G" push origin feature, literal feature pushes, programs with a literal basename behind a variable directory ("$ANDROID_HOME/platform-tools/adb" push ...), command -p echo "$G" push ..., nice -n5 echo "$G" push ..., a commented-out push, and cat > notes.md <<'EOF' bodies that mention a push stay allowed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): breaks commands. Another tool's push behind a variable whose argv reads as a bare or single-positional git push ("$DOCKER" push img, "$HG" push) is refused by the bare/single-arg rows, which operators can disable; the unquoted $DOCKER push img is already refused on main. A heredoc body printed to standard output is still read as commands, which can over-refuse. No secret handling or lock-out path is touched.
  • Evidence checked (which sandbox result proves it): test/test_git_publish_program_word.py drives is_denied end to end on 163 commands, including every shape the review lanes reported on earlier heads (partial-quoted globs, comments holding quotes, heredoc data, precommand option values) and the legitimate operations the scope lane listed.
  • No regression:
    • Tools still work (which tools/commands were run, result): the allow cases cover literal feature pushes, loops, case statements, $(date) arguments, quoted ) ; ( { arguments, "$EDITOR" file, background jobs, sudo echo "$x" push, nice -n 5 make "$T" push, adb/dvc/helm/cachix, comments and file-writing heredocs; all allowed.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or call signature changes; every existing caller of the floor is unchanged and the existing push-gate tests pass unchanged.
    • Existing tests (which suites passed on this head): the program-word and gate-liveness suites pass; a full local suite run passed 171039 tests, and its failures are host-environment ones (a subprocess interpreter that cannot load, a missing optional module) outside the floor.
  • How to undo: revert the two commits of this PR; the floor returns to its previous detection.

@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 Oct 10, 2026
@cruisercohen
cruisercohen force-pushed the fix/publish-floor-program-word branch from daa9801 to c715612 Compare October 10, 2026 19:06
@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 Oct 10, 2026
@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: c715612
  • What rule changed: the git-publish floor's detector (_is_git_publish) gains a program-position pass (publish_program_word.py) on quote-aware shell words. It finds a push run under a program word the shell resolves at run time (a basename carrying an expansion or substitution, or one whose unquoted glob characters can name git, quoting read per character) in every program position: after any separator, inside compound constructs, subshells and case arms, behind precommands, their value-taking options and redirections. Comments, and the body of a quoted-delimiter heredoc fed to a literal data reader that writes to a named file, are not read as commands. When the program word is one double-quoted parameter expansion and the words up to push are literal, the push is judged by its target with the existing literal-push rules; any other such push is the existing unverifiable deny. No catalog row or opt-out changes.
  • Before -> after (what was allowed/blocked, now): before, "$G" push origin main, g?t push origin main, g"i"[t] push origin main, if true; then "$G" push; fi, sudo -u root "$G" push origin main, true & "$G" push origin main, a push on the line after a comment holding a quote, and "$G" push origin main ; git push origin feature were allowed. After, each is denied (protected-branch, bare, or unverifiable). "$G" push origin feature, literal feature pushes, programs with a literal basename behind a variable directory ("$ANDROID_HOME/platform-tools/adb" push ...), command -p echo "$G" push ..., nice -n5 echo "$G" push ..., a commented-out push, and cat > notes.md <<'EOF' bodies that mention a push stay allowed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): breaks commands. Another tool's push behind a variable whose argv reads as a bare or single-positional git push ("$DOCKER" push img, "$HG" push) is refused by the bare/single-arg rows, which operators can disable; the unquoted $DOCKER push img is already refused on main. A heredoc body printed to standard output is still read as commands, which can over-refuse. No secret handling or lock-out path is touched.
  • Evidence checked (which sandbox result proves it): test/test_git_publish_program_word.py drives is_denied end to end on 172 commands, including every shape the review lanes reported on earlier heads (partial-quoted globs, comments holding quotes, heredoc data, precommand option values, escaped program basenames, substituted redirection targets, named coprocesses) and the legitimate operations the scope lane listed.
  • No regression:
    • Tools still work (which tools/commands were run, result): the allow cases cover literal feature pushes, loops, case statements, $(date) arguments, quoted ) ; ( { arguments, "$EDITOR" file, background jobs, sudo echo "$x" push, nice -n 5 make "$T" push, adb/dvc/helm/cachix, comments and file-writing heredocs; all allowed.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or call signature changes; every existing caller of the floor is unchanged and the existing push-gate tests pass unchanged.
    • Existing tests (which suites passed on this head): the program-word and gate-liveness suites pass; a full local suite run passed 171039 tests, and its failures are host-environment ones (a subprocess interpreter that cannot load, a missing optional module) outside the floor.
  • How to undo: revert the two commits of this PR; the floor returns to its previous detection.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

span=47f81b5dc672

  • Item 7, the flock -c payload. kept, it closes a wrapper: flock <lock> -c '<script>' runs its script through a shell, the same class as the bash -c and eval payloads the floor already walks. A deny_diff probe against main 050fe49 shows a protected-branch publish inside a flock -c script allowed on main and refused on this head.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

span=35be53b639ba

  • Item 8, the refspec expansion check and the redirection-operator target. kept, both are targets main does not read: a deny_diff probe against main 050fe49 shows a literal git with a redirection between it and push (stdout or stderr redirected) publishing to a protected branch allowed on main and refused here, and a runtime program pushing to a refspec built from an expansion ("$BR", HEAD:${BR}) allowed on main and unverifiable here.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 9c2b563
  • This head is 4c5fa7c rebased onto current main 2245fd4, with no rule change. The first commit is unchanged (same patch). The second commit differs only in the package line-budget pin in test/test_security_gate_liveness.py: main raised the pin to 29,573 for the PEM private-key scan, so this PR's pin is re-set to 32,081 (main's 29,573 plus this PR's unchanged 2,508). The floor module stays 4,433 lines and the shell normalizer 3,894, both under the per-module cap.
  • What rule changed: none in this push. The publish floor reads the same program words and judges the same targets as on 4c5fa7c.
  • Before -> after (what was allowed/blocked, now): unchanged from 4c5fa7c. Against main 2245fd4, the change only adds refusals, as on the previous head; nothing main refuses becomes allowed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the same as on 4c5fa7c: a publish whose program or target cannot be verified is refused. It fails closed, never open. No secret-handling or lock-out path is touched.
  • Evidence checked (which sandbox result proves it): a deny_diff against main 2245fd4 shows no golden path newly refused and no loosening on posix or windows (45 / 44 classified, 0 regressions, 0 loosenings). git range-diff shows the first commit identical and the second differing only in the pin lines.
  • No regression:
    • Tools still work (which tools/commands were run, result): the PR-body, commit-message, release-notes, notes-file and template-write idioms stay allowed, and feature-branch publishes stay allowed, as the golden-path rows show.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or public-signature change since 4c5fa7c.
    • Existing tests (which suites passed on this head): test_git_publish_program_word.py, test_security_gate_liveness.py, the argv-floor, push-branch-gate, facade, single-storage, governance and security test files (7,420 tests) pass; flake8, the black gate, isort, the comment-history and file-line-cap gates are clean. The package measures 32,081 lines against its pin of 32,081.
  • How to undo: revert this PR's commits. The floor returns to main's detection.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

span=f45b8903c18c

  • A spelling chase, not a closed boundary. needs a decision, deferred to the maintainer review this PR is waiting on. This is the question the earlier "open-ended spelling chase" item raised, answered in the earlier disposition: whether a check on the pushed refs should replace reading the text, and where the text reading stops, is a design decision for the maintainer rather than something this head settles. A script run by its path (bash push.sh) is outside what a text floor reads, here and on main alike (a deny_diff probe against main 2245fd4 shows it allowed at both refs); this PR narrows the in-line spellings only. This head is a rebase with no rule change.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

span=8777d0bf16e6

  • The new glob reading makes markdown text deny, and an allow-list now decides what counts as inert. rebutted in part, the rest deferred to the maintainer review. A bare * can name git: in a directory whose only entry is a file named git, * push origin main expands to git push origin main, and bash then finds git on PATH. A deny_diff probe against main 2245fd4 shows that command allowed on main and refused here, so dropping * would reopen it. The cost is real and recorded: a * push bullet in a heredoc body beside a command outside the companion and runner lists is refused (the scope lane lists 2>&1, | tee and uv run pytest ... | tail rows on this head), and each list entry is pinned by refusal rows, as answered in the allow-path disposition and the glob program word disposition. Whether that fail-closed cost is acceptable is a maintainer call.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

span=c59845e61b5e

  • Suggestion: keep the known-argv rows for one double-quoted expansion and send every other runtime-word shape to the unverifiable deny without the sink and companion exemptions. needs a decision, deferred to the maintainer review. The trade is wider refusals: without the exemptions a * push bullet in a commit or PR body is read as a glob program word and refused. Removing just one of them, the lifted exclusion, fails 20 STILL_ALLOWED rows in test/test_git_publish_program_word.py, among them the git commit -m "$(cat <<'EOF' ...)", gh pr create --body "$(cat <<'EOF' ...)" and glab mr create idioms main allows (the earlier disposition). Dropping the glob reading instead reopens the publish in the previous item. Which of the two costs to carry is a maintainer call.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

span=c98d1df910b1

  • Item 1, a second program-position walker beside command_invokes_git. rebutted: the two answer different questions. readonly_bash.command_invokes_git returns one yes or no and reads any $(, backtick or process substitution as git (readonly_bash.py:1502 and :1528), with no position or argv. The floor needs each publish's argv to judge its target, and reading every substitution as a publish would refuse the PR-body and commit-message idioms main allows: a deny_diff probe against main 2245fd4 shows gh pr create --body "$(cat <<'EOF' ...)" allowed at both refs, and "$GIT" push origin feat/example allowed at both while "$GIT" push origin main is refused only here. shell_normalizer._in_command_position looks only for ;, &, |, ( or a newline before a word (shell_normalizer.py:2246), so a push after then, do, { or $( would not count as a command there; _at_command_position adds those openers and keywords, and the same probe shows if true; then "$GIT" push origin main; fi allowed on main and refused here.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

span=0628b72d94b4

  • Item 2, the known-argv path. rebutted: it relaxes nothing main refuses. Main does not read a runtime program word, so it allows every "$VAR" push. A deny_diff probe against main 2245fd4 shows "$GIT" push origin feat/example allowed at both refs and "$GIT" push origin main refused only on this head. Deleting the branch would refuse the feature push as well, a new refusal of a command main allows, which is the regression the scope lane counts; that refusal is the harm the Clears-when line asks for, and it is the deletion that would create it.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

span=1068a77932a8

  • Item 5, a substitution in a refspec. kept; it adds no new class. Main already refuses a literal git push whose refspec carries an expansion: a deny_diff probe against main 2245fd4 shows git push origin "HEAD:${BR}" and git push origin "$(git branch --show-current)" refused at both refs. The known-argv path takes its own program word out of the substitution-glue check (argv_floor.py:4331), so the target reader repeats the refusal for that path (argv_floor.py:4229); the only newly refused row is "$GIT" push origin "HEAD:${BR}", which main allows. The earlier answer on this check is the refspec disposition.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

span=aeb3770523ed

  • Abbreviated make options in the plain-runner check (publish_heredoc.py:121). Acknowledged. main has the same behaviour for these prefixes, so this PR does not introduce it; deferred to a follow-up so this head stays as reviewed.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 6d58a4e
  • This head is 9c2b563 carried onto current main afed43d, with no rule change. Main split the argv floor, the shell reader and the package facade into owner modules, so this PR's edits are re-applied where main moved the code: the release-detection edits in argv_floor_git.py, the shell-reader edits in shell_normalizer_walk.py and shell_normalizer.py, and the publish-source step of is_denied in deny_gate.py. argv_floor.py's type-checking manifest lists the names it now serves from publish_program_word and publish_subcommand. The three new modules and the test file are unchanged, except that publish_program_word.py imports two reader helpers from shell_normalizer_walk, where main keeps them. The package line-budget pin is re-set to 34,019 (main's 31,509 plus this PR's 2,510); every module stays under the per-module cap.
  • What rule changed: none in this push. The publish floor reads the same program words and judges the same targets as on 9c2b563.
  • Before -> after (what was allowed/blocked, now): unchanged from 9c2b563. Against main afed43d the change only adds refusals, as on the previous head; nothing main refuses becomes allowed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the same as on 9c2b563: a publish whose program or target cannot be verified is refused. It fails closed, never open. No secret-handling or lock-out path is touched.
  • Evidence checked (which sandbox result proves it): deny_diff against main afed43d shows no golden path newly refused and no loosening on posix or windows (45 / 44 classified). On the review-lane rows and the make-option rows, the rows this head newly refuses against main are the same rows, with the same refusal text, that 9c2b563 newly refused against its own base, and deny_diff from 9c2b563 to this head finds no difference on any of those corpora. For every definition this PR changes, the added and removed lines against main match the ones 9c2b563 had against its base.
  • No regression:
    • Tools still work (which tools/commands were run, result): the PR-body, commit-message, release-notes, notes-file and template-write idioms stay allowed, and feature-branch publishes stay allowed, as the golden-path rows show.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or public-signature change since 9c2b563; every name stays readable through kiro_crew.security.argv_floor (test_argv_floor_facade.py and test_facade_mirror_guards.py pass).
    • Existing tests (which suites passed on this head): test_git_publish_program_word.py, test_security_gate_liveness.py, the denied-command, argv-floor, push-branch-gate, facade, facade-mirror, single-storage, split-patch-reach, governance and security test files and every other test file naming the shell reader, the argv floor or the deny gate (140 files, 14,863 tests) pass; flake8, isort, mypy, the black gate, the comment-history and file-line-cap gates are clean.
  • How to undo: revert this PR's commits. The floor returns to main's detection.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: e99723a
  • This head is 6d58a4e rebased onto current main 3e39e7a, with no conflict and no rule change. Main changed no file in the security package or in this PR's file set since 6d58a4e's base, so both commits carry the same added and removed lines as on 6d58a4e (git range-diff shows both commits unchanged). The package line-budget pin (34,019) still matches.
  • What rule changed: none in this push. The publish floor reads the same program words and judges the same targets as on 6d58a4e.
  • Before -> after (what was allowed/blocked, now): unchanged from 6d58a4e. Against main 3e39e7a the change only adds refusals, as on the previous head; nothing main refuses becomes allowed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the same as on 6d58a4e: a publish whose program or target cannot be verified is refused. It fails closed, never open. No secret-handling or lock-out path is touched.
  • Evidence checked (which sandbox result proves it): deny_diff against main 3e39e7a shows no golden path newly refused and no loosening on posix or windows (45 / 44 classified). On the review-lane rows, the earlier scope rows and the make-option rows, this head newly refuses exactly the rows 6d58a4e newly refused, with the same refusal text and tier, and deny_diff from 6d58a4e to this head finds no difference on any of those corpora.
  • No regression:
    • Tools still work (which tools/commands were run, result): the PR-body, commit-message, release-notes, notes-file and template-write idioms stay allowed, and feature-branch publishes stay allowed, as the golden-path rows show.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or public-signature change since 6d58a4e; every name stays readable through kiro_crew.security.argv_floor (test_argv_floor_facade.py and test_facade_mirror_guards.py pass).
    • Existing tests (which suites passed on this head): test_git_publish_program_word.py, test_security_gate_liveness.py, the argv-floor facade, facade-mirror, denied-command and push-branch-gate suites, and the harness-parity, capture and facade-scan tests that were red on the previous base (2,438 passed).
  • How to undo: revert this PR's commits. The floor returns to main's detection.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 79922de
  • This head is 3c015ef with one correction folded into its second commit, on the same base, main 7d6bfb4, and it merges cleanly with main 0b89e0c. Bash ends a heredoc body only at a line that matches its delimiter case for case, while the publish floor reads the command lowercased. Where a body line matches its delimiter only in another letter case, the floor now also reads the command with no heredoc and line by line, and judges each reading as a publish source like any other. The package line-budget pin becomes 32,056 plus this PR's 2,555, which is 34,611.
  • What rule changed: no rule row. The git-publish floor gains those extra readings; the rows that judge them, and their operator opt-outs, are the existing ones.
  • Before -> after (what was allowed/blocked, now): against 3c015ef, a protected publish behind a delimiter matched only in another case is now refused exactly when the same publish is refused on its own. A heredoc with no protected publish, such as a Ruby or Lua end under <<END, stays allowed. Against main 7d6bfb4 the change only adds refusals; nothing main refuses becomes allowed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a command whose heredoc has a line matching its delimiter only in another case, and a protected publish on some line, is refused even when that publish is data. It fails closed, never open. No secret-handling or lock-out path is touched.
  • Evidence checked (which sandbox result proves it): deny_diff against main 7d6bfb4 and 0b89e0c shows no golden path newly refused and no loosening on posix or windows (45 / 44 classified). From 3c015ef to this head, deny_diff finds no change on the golden paths or on any earlier scope-review corpus, both platforms. On this head's own scope-review corpus it refuses exactly the rows 3c015ef refuses (macos 9, ubuntu 9, windows 4), with the same tier and refusal text.
  • No regression:
    • Tools still work (which tools/commands were run, result): the PR-body, commit-message, release-notes, notes-file and template-write idioms stay allowed, feature-branch publishes stay allowed, and heredocs writing Ruby, Lua and shell source with end/done lines stay allowed.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or public-signature change. Every name stays readable through kiro_crew.security.argv_floor (test_argv_floor_facade.py and test_facade_mirror_guards.py pass).
    • Existing tests (which suites passed on this head): test_git_publish_program_word.py, test_security_gate_liveness.py, the argv-floor facade, facade-mirror, security-facade, denied-command, push-branch-gate, self-kill and rm-floor suites (4,501 passed).
  • How to undo: revert this PR's commits. The floor returns to main's detection.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: c661b2f
  • This head is 328c30c rebased onto current main a3ee04f, plus one correction folded into its second commit. The first commit is unchanged (git range-diff shows the same patch). The rebase conflicted only on the package line-budget pin. The correction is eight lines in argv_floor_git and two test rows. The package line-budget pin becomes main's 32,613 plus this PR's 2,582, which is 35,195.
  • What rule changed: no rule row. In the git-publish floor, a runtime publish judged on the whole folded source vouches that a push was seen only when that source runs no literal publish, and a segment whose only publishes are runtime ones vouches the same way. A literal publish that a backslash-newline splits out of every segment is then left to the existing unverifiable fallback.
  • Before -> after (what was allowed/blocked, now): on main a3ee04f, "$G" push origin feature; git \<newline> push origin main and git </dev/null push origin feature && git \<newline> push origin main are refused; on 328c30c both were allowed; on this head both are refused again (git-publish-target-unverifiable). Against main the change only adds refusals; nothing main refuses becomes allowed.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): a command that runs a runtime-program feature push and also a literal publish that no segment recognises is refused as unverifiable. It fails closed, never open. No secret-handling or lock-out path is touched.
  • Evidence checked (which sandbox result proves it): deny_diff against main a3ee04f shows no golden path newly refused on posix or windows (45 / 44 classified, 0 regressions). The two new rows in test_every_program_position_is_read fail on 328c30c rebased onto a3ee04f and pass here. The lone continuation-split runtime feature push ("$G" \<newline> push origin feature) stays allowed.
  • No regression:
    • Tools still work (which tools/commands were run, result): feature-branch publishes, the continuation-split runtime feature push, and the PR-body, commit-message, release-notes and notes-file idioms in the allowed rows stay allowed.
    • Backward compatible (old config / old data / old callers still work, how checked): no config, data or public-signature change; every name stays readable through the argv-floor facade (test_argv_floor_facade.py passes).
    • Existing tests (which suites passed on this head): push-branch gate, security, publish floor, denied-command, hooks, deny guidance, argv floor, regex linearity, security facade, rule seam, read-only filters, shell grammar, bash gate, gate liveness and program-word suites (3,902 passed); black, flake8, isort and mypy on the touched files and the comment-history gate are clean.
  • How to undo: revert this PR's commits. The floor returns to main's detection.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: f214bc0
  • This head is c661b2f plus one refactor commit. The First Principles lane's blocker on c661b2f was that the program-word pass carried its own command-position test for case/esac inside a substitution body, separate from the shared walk in shell_normalizer_walk. That local test is deleted.
  • What rule changed: no rule row. Inside a $(...) body, whether a case arms and an esac disarms is now decided by _arms_case_context and _in_command_position, the same rules _matching_close_paren uses. _GIT_PROGRAM_LEAD_WORDS is now derived from _KEEPS_COMMAND_POSITION less time and coproc (read as precommands), the same nine words as before.
  • Before -> after: on c661b2f a case behind time -p, time --, function NAME or coproc NAME was not armed, so its pattern ) closed the substitution early. Here the body runs to the real closer. echo case x in x stays data. Against main the PR still only adds refusals.
  • Worst case if wrong: a body read longer than bash reads it is unverifiable and refused, which fails closed. No secret-handling or lock-out path is touched.
  • Evidence checked: the 6 new span rows and the lead-word pin in test_git_publish_program_word.py fail on c661b2f (5 of 8 fail) and pass here. deny_diff on the golden-paths corpus shows 0 regressions, both c661b2f to this head and main a3ee04f to this head (45 classified, all allowed at both refs).
  • No regression:
    • Tools still work: the feature-branch, PR-body and commit-message idioms in the allowed rows stay allowed.
    • Backward compatible: no config, data or public-signature change; the module shrinks by 9 lines.
    • Existing tests: the security, git-publish, argv-floor, shell-normalizer and publish suites (6,876 passed, 1 skipped); black, isort, flake8 and mypy on the touched files and the file line cap are clean.
  • How to undo: revert this commit; the scanner returns to its local command-position test.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 6559f3d
  • This head has the same tree as f214bc0. The refactor commit is folded into the second commit, because PR Hygiene allows one or two commits. Relative to c661b2f, the only change is the First Principles fix: the program-word pass no longer has its own command-position test for case/esac inside a substitution body.
  • What rule changed: no rule row. Inside a $(...) body, _arms_case_context and _in_command_position now decide whether a case arms and an esac disarms. These are the rules _matching_close_paren uses in shell_normalizer_walk. _GIT_PROGRAM_LEAD_WORDS is now _KEEPS_COMMAND_POSITION less time and coproc, which are read as precommands. That is the same nine words as before.
  • Before -> after: on c661b2f, a case behind time -p, time --, function NAME or coproc NAME was not armed, so its pattern ) closed the substitution early. Here the body runs to the real closer. echo case x in x stays data. Against main, the PR still only adds refusals.
  • Worst case if wrong: a body read longer than bash reads it is unverifiable and refused. That fails closed. No secret-handling or lock-out path is touched.
  • Evidence checked: on c661b2f, 5 of the 8 new rows in test_git_publish_program_word.py (6 span rows, an argument-case row and the lead-word pin) fail; here all 8 pass. deny_diff on the golden-paths corpus shows 0 regressions from c661b2f to this head and from main a3ee04f to this head (45 classified, all allowed at both refs). First Principles passed on f214bc0, which has the same tree.
  • No regression:
    • Tools still work: the feature-branch, PR-body and commit-message idioms in the allowed rows stay allowed.
    • Backward compatible: no config, data or public-signature change. The module is 9 lines shorter.
    • Existing tests: the security, git-publish, argv-floor, shell-normalizer and publish suites pass (6,876 passed, 1 skipped). black, isort, flake8 and mypy on the touched files, and the file line cap, are clean.
  • How to undo: revert the second commit's scanner hunk. The scanner then returns to its local command-position test.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 5c8e2f6
  • This head is 6559f3d plus a fix for four over-blocks, folded into the second commit (PR Hygiene allows one or two commits). Each over-block was a fail-closed refusal this PR's own sink exemption made, and the Security Scope lane found them on c661b2f.
  • What rule changed: no rule row. In the sink exemption of the program-word pass:
    • a join of the two standard streams (2>&1, >&2) opens no file, so it no longer voids the exemption;
    • head and tail are inert companions;
    • mypy is a plain runner, like pytest;
    • a plainly named file may carry a Git Bash drive letter (c:/...).
  • Before -> after: on 6559f3d, four idioms were refused as unverifiable because a * markdown bullet in the message or PR body was read as a glob program word: a commit message followed by a feature push with 2>&1, the same piped into tail, a commit beside uv run mypy, and a PR body written to a c:/ temp path. All four are allowed on main a3ee04f and allowed again here.
    • These still void the exemption: a stderr redirect to a path, a dup to any other descriptor (>&3), and 2>&1 beside a file redirect.
    • A runtime publish in a body beside mypy stays command text, and a drive-letter path into .git stays git's.
  • Worst case if wrong: a commit or PR body beside one of these commands is read as data. Literal publishes in data lines are still read, and against main the PR still only adds refusals.
  • Evidence checked: the 5 new allowed rows fail on 6559f3d and pass here; the 5 new guard rows are refused on both.
    • deny_diff from main a3ee04f to this head shows 0 loosenings on the golden-paths corpus (45/45 allowed at both refs) and on an 11-row probe corpus.
    • From 6559f3d to this head, the only changes are the 3 posix idioms above, now allowed (the drive-letter row is Windows-only).
  • No regression:
    • Tools still work: the feature-branch, PR-body and commit-message idioms in the allowed rows stay allowed.
    • Backward compatible: no config, data or public-signature change; the package stays within its line budget.
    • Existing tests: the security, git-publish, argv-floor, shell-normalizer, publish, denied-command and hooks suites pass (9,376 passed before a one-line trim that brought the package back to its line budget; the budget and program-word suites pass after it). black, isort, flake8 and mypy on the touched files, and the file line cap, are clean.
  • How to undo: revert this head's sink-exemption hunks; the four idioms are refused again.

@cruisercohen

cruisercohen commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 9ad3317
  • Correction: my earlier comments on this PR said 0 loosenings against main. That claim covered only the golden-path and probe sets. On 04168a5, GPT found one loosening class in this PR's own normalizer change: a quoted redirection target ending in > was read as an operator by the rm floor, which reads dequoted words (shell_normalizer_walk.py:1154, reached from rm_floor.py:147). Main refuses that class; the PR allowed it from c661b2f to 04168a5. It is fixed in 9ad3317.
  • What rule changed: no rule row. _push_token_redirection reads a chained redirection target only for callers that hold raw tokens. The rm floor passes chained=False, which is main's reading.
  • Before -> after: on 04168a5 that class was allowed. Here it is refused, as on main.
  • Worst case if wrong: the rm floor reads a leading redirection exactly as main does, so nothing outside main's behaviour changes there.
  • Evidence checked: 3 new rows in test_denied_commands_security_rows.py fail on 04168a5 and pass here. deny_diff against main 8a518e1 shows 0 loosenings on the golden-path set and on a 20-row probe set that includes this class (on 04168a5 that same set showed it as allowed).
  • No regression:
    • Tools still work: the git-publish, PR-body and commit-message rows in the allowed lists stay allowed. The other callers keep the chained reading.
    • Backward compatible: no config, data or public-signature change. The new parameter defaults to the existing behaviour.
    • Existing tests: the security, git-publish, argv-floor, shell-normalizer, publish, denied-command and hooks suites pass (9,380 passed). black, isort, flake8 and mypy on the touched files are clean.
  • How to undo: revert the chained parameter and the rm-floor call. The loosening then returns, so do not.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 1681dd7
  • What rule changed: no rule row. The git-publish segment splitter's span tracker (_split_push_command_segments, shell_normalizer_walk.py:1271) now opens a substitution span only on an unescaped, active $. A span the text never closes falls back to the split without spans, which is main's split. The class was an unclosed span opener: a lone backtick or $( in a quoted heredoc body or a comment, or an escaped \$(.
  • Before -> after: on 9ad3317 a feature push after such an opener was refused as unverifiable; main allows it. Here it is allowed, as on main, and the protected-branch twin of each shape stays refused.
  • Worst case if wrong: a text with an unclosed span opener is split exactly as main splits it.
  • Evidence checked: 4 new shapes in test_git_publish_program_word.py fail on 9ad3317 and pass here. deny_diff against main 8a518e1 shows 0 loosenings on three sets: golden (45 posix / 44 windows), the 20-row probe set including the rm-floor class, and a 14-row set of these shapes, their protected twins, and real spans.
  • No regression:
    • Tools still work: every allowed and refused row in the existing suites still holds.
    • Backward compatible: no config, data or public-signature change. The new spans parameter defaults to the existing behaviour. The package line-budget pin rises by these 6 lines.
    • Existing tests: the security, git-publish, argv-floor, shell-normalizer, publish, denied-command and hooks suites pass (9,383 passed; the line budget passes after the pin). black, isort, flake8 and mypy on the touched files are clean.
  • How to undo: revert the span-tracker hunk. The over-refusal of those feature pushes then returns.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 4148ae0
  • What rule changed: none. This head is a conflict-only rebase of 1681dd7 onto main a796ca5. The one conflict was the package line-budget pin in test_security_gate_liveness.py, which main's feat(security): put the enterprise install tree on the file-tool write gate #24392 raised by 3; both sides are kept and the pin is main's 32,616 plus this PR's 2,588, so 35,204.
  • Before -> after: no reading changed. git range-diff shows commit 1 identical and commit 2 differing only in the pin's context and value; the committed +/- lines are otherwise identical across the same 14 files.
  • Worst case if wrong: the pin is off by the merged count and the line-budget test fails; no floor reading moves.
  • Evidence checked: deny_diff against main a796ca5 shows 0 loosenings on golden (45 posix / 44 windows), on this PR's own test rows, on the span-opener shapes, and on the rm-floor quoted-redirection class (which the same probe flags on 04168a5).
  • No regression:
    • Tools still work: every allowed and refused row in the existing suites still holds.
    • Backward compatible: no config, data or public-signature change.
    • Existing tests: the security, git-publish, argv-floor, denied-command and edition install-fence suites pass, including the line budget.
  • How to undo: revert the rebase; no rule changed.

@cruisercohen

Copy link
Copy Markdown
Contributor Author

Status: handing this to maintainers

Head 4148ae01c is a conflict-only rebase of 1681dd770 onto main (no rule change).

  • Nothing main refuses is newly allowed. Security Scope and our deny_diff against main both show 0 newly allowed on every set tested. GPT 6.1 has no blocking finding.
  • Opus 5.5 blocks on an over-block in the span tracker (shell_normalizer_walk.py): some quoted heredoc bodies and comments confuse span tracking, so a normal feature push is refused as unverifiable. It refuses too much and lets nothing new through; the protected-branch form stays refused. It is in this PR's span-tracker change, not the rebase: the last fix round narrowed it but did not close this case.
  • Security Scope lists 7 newly refused posix rows, all in two fail-closed classes: a * push markdown bullet inside a heredoc commit body, and a program name taken from a variable ("$DOCKER", an unquoted $ANDROID_HOME path).
  • Inherited reds: Backend Lint F821 at publish_governance.py:299 is on main since feat(governance): let a policy name publish regions, audience and accounts #24343 (fix in fix(governance): pass lists_checked_by_caller to session check #24767); Coverage Gate fails only its upstream-jobs step.

We've stopped iterating: each fix round on this normalizer has surfaced a new AI-lane finding, so the next step needs a maintainer's direction. Two ways forward:

  1. Accept the over-blocks for now (fail-closed, 0 newly allowed) and track the span-tracker and * push bullet misreads as follow-up issues.
  2. Ask for the span-tracker fix in this PR first.

@iamwhatever @bolichen97, which would you prefer?

…floor

A push run under a program word the shell resolves at run time (a quoted
expansion, a path around one, a glob that can name git, a substitution) is
now detected in every program position of the line: after newlines, glued
separators and background operators, inside compound constructs, behind
precommands and redirections. Such a segment is unverifiable and cannot defer
to, or borrow a verdict from, a feature push in its own arguments.
Move the program-position reading into publish_program_word.py. Split
commands quote- and substitution-aware, read the program's top-level
basename, model precommand operands, and read git's argv with the
literal-push grammar when the program word is one double-quoted
expansion.

Read each word ANSI-C decoded, a long option by any prefix of a
value-taking one, and value options across GNU, BSD and util-linux
spellings. Once a word of unknown arity is read (a runtime dispatcher or
operand, an option spelled with an expansion or glob, an option value an
expansion can split, an abbreviation that may be a no-value option), a
later runtime word running push is unverifiable. A closer closes only the
opener it matches, and --config-env takes a value.

Read a floor line that starts inside a quote in that quote. Treat git
fetch and git push without a transport-program option, and cat, as inert
companions; glab as a sink; cat piped into a sink as feeding it; a plain
${NAME} and a sink option's value as voiding nothing; a CRLF printer as a
printer; and a body cat or tee only writes to a plainly named file,
beside sinks, companions, chmod and mkdir alone, as data. Beside a plain
test or build runner, or a git beside a file write, read only a leading
markdown bullet as ":", in a sink's body and in a file-written body alike.

A gh or glab body gets that bullet reading beside git checkout, switch or
stash, a plain git rebase onto refs, or a .py or .sh script run by its
path, too:
neither sink runs a hook on its body. A git commit, notes or tag body keeps the stricter list. A file
path is git's when a component carries .git, but .github is not one.

A redirection target ends at the next unquoted operator, so a chained
</dev/null> leaves its last target to the next word, as bash reads it,
and a literal git with a redirection before its subcommand is read here
and judged by its target. An unquoted variable path program word is
unverifiable whatever argv follows: split, its first word can be any
program, so an argv git would reject proves nothing.

A ${...} parameter expansion holding whitespace stays one shell word, as
$(...) and backticks already do, so the word after it is not misread as
the program. A target-neutral flag may carry its one-word value attached
(--git-dir="$REPO/.git"), and push glued to a letter (pushed) is another
word, not the subcommand.

A >| noclobber redirection is one operator, not a pipeline boundary, so
the program word before it and push after it are one command. A heredoc
body written to an executable a sibling command then runs by its basename
(> ~/.local/bin/sleep; chmod +x; sleep) stays command text, so companion
membership does not exempt the installed script. git branch is a read-only
companion, so a gh or glab body bullet beside it is text.

Bash ends a heredoc body only at a line that matches its delimiter case
for case, while the floor reads the command lowercased. Where a body line
matches its delimiter only in another letter case, the floor also reads
the command with no heredoc and line by line, and judges each reading as a
publish source like any other. A heredoc with no protected publish keeps
its reading, and operator opt-outs apply as they do to any publish.

Inside a substitution body, decide whether a case arms and an esac
disarms by shell_normalizer_walk's _arms_case_context and
_in_command_position, the rules _matching_close_paren uses, rather than
a local command-position test, and derive the program lead words from
_KEEPS_COMMAND_POSITION less the precommands time and coproc.

Beside a sink, a join of the two standard streams (2>&1, >&2) opens no
file and does not void the exemption, head and tail are inert companions,
mypy is a plain runner, and a plainly named file may carry a Git Bash
drive letter (c:/...).

The rm floor reads dequoted words, so it reads a leading redirection
unchained, as main does: _push_token_redirection(chained=False). The
chained-target reading needs the token's quoting.

The segment splitter opens a substitution span only on an unescaped
active $, and a span the text never closes (an opener in a quoted
heredoc body or a comment) falls back to the split without spans, as
main splits.
@cruisercohen

Copy link
Copy Markdown
Contributor Author

Status on fde505b (nothing pushed). Opus's new blocking finding on this head (publish_heredoc.py:458, a here-doc inside a command substitution that ends on a tag-plus-closer line) is a gap in the runtime-program push coverage this PR adds. It is not a regression against main. We ran 10 rows (the exact shape, variants and controls) through scripts/deny_diff.py against main d579985. Main allows that shape too, because main does not judge runtime-program pushes at all, so 0 rows are newly allowed. This head refuses the variants. A fail-closed fix is ready and only refuses more: inside a substitution, end the body at a tag-plus-closer line or refuse the read. It is not pushed. The PR is also CONFLICTING with main again. We're holding the branch until you pick from 6435558132: option 1 (accept as-is and track this residual plus the over-blocks as follow-ups) or option 2 (we push this fix and a conflict-only rebase first).

@iamwhatever

Copy link
Copy Markdown
Contributor

Thank you for this work, @cruisercohen. On 2026-11-08 the maintainers decided to keep the current shell reader and to stop patching shell spellings one at a time in the command-text checks, including the git publish floor. The OS sandbox is the enforcement point, and known spelling gaps are recorded as stated residuals: #21682 (comment) . The linked issue #17745 was closed under that decision, so I am closing this PR too. Please comment if you think it covers more than a spelling gap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

git-publish gate: compound shell constructs and arg-derived payloads are not verified

3 participants