Repository navigation
fix: tighten a git publish check - #30774
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change gives a shell command line the Notes
[DESIGN-REVIEWED] a2086ad Description read[DESCRIPTION-READ] c32d407c8b198978ddbffd55cbe6b61ba575a1723b7e8d9840f2e44b91ab186a That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (5 items) — 5 justifiedIntent: stop an agent pushing to a protected branch through
[FIRST-PRINCIPLES-REVIEWED] a2086ad Description read[DESCRIPTION-READ] 36d4d9a1413e085dcc47e217df084c291231a578dc5e2249fe6dab395895d35f That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Security Scope Review -- ✅ PASSWhich legitimate operations does Verdict basis: adjudicated, zero confirmed regressions. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: PASS Reason: The new check refuses only a push whose words before the TIGHTENING: the git-publish argv floor ( ADJUDICATED: 19 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: The diff makes two platform assumptions: posix shells word-split an unquoted
There are 6 windows rows. They probe the UNADJUDICATED: There is a narrowing overlap that I argued but could not confirm with a row. Under the new hunk, a posix push with an unquoted variable before the subcommand is now refused under the non-waivable [SCOPE-REVIEWED] a2086ad |
6ddac49 to
ff5a2ac
Compare
|
[operator: bolichen97]
|
ff5a2ac to
00a68e5
Compare
Refuse one more git push spelling whose destination cannot be determined before it runs, the case reported in the linked issue. Quoting the value keeps the command allowed. Closes #18520
00a68e5 to
a2086ad
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved by Crew Captain for the on-call, who accepted the open items on this PR. Review lanes clean on this head.
buluoray
left a comment
There was a problem hiding this comment.
🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:
APPROVE. This tightens the push check and loosens nothing.
What it does for users: an agent can no longer get a push to a protected branch past the publish check by putting an unquoted variable in a git option before the subcommand. With d='x push origin main', the command git -C $d push origin feature word-splits at run time into a push of main, and main read it as a feature-branch push. That spelling is now refused as unverifiable. The quoted form "$d", a
Evidence:
- src/kiro_crew/security/argv_floor_git.py:425-436: the only change seeds the returned argument list with skipped words before the subcommand that hold an active (unquoted, unescaped) $ not followed by a quote. Nothing is removed from the existing scan; on Windows the list is empty, which is exactly main's behaviour.
- The caller then ungates any returned word holding a $ (argv_floor_git.py:806-814), and deny_gate.py:695-711 refuses an ungated segment with no opt-out. Adding words to the front can only move a segment toward that ungated refusal; I found no path where an extra leading word turns a refusal into an allow.
- The
$'...' exemption matches the shared quote state machine (shell_normalizer_walk.py:501), so a literal ANSI-C path stays one word, while $ '/x/'$d is still caught on its second $. - test/test_push_branch_gate.py: 104 passed on this head, run locally.
- Mutations, one at a time, source restored and the tree clean after each:
- Pre-fix line (empty list instead of the seeded one): test_an_unquoted_expansion_before_the_subcommand_is_unverifiable and test_a_dollar_quote_before_the_subcommand_is_one_word go red.
- Dropping the
$' / $ " exemption: test_a_dollar_quote_before_the_subcommand_is_one_word goes red. - Dropping the Windows exemption: test_powershell_keeps_a_variable_before_the_subcommand_one_word goes red.
- Backwards compatibility: the PR body carries a Breaking: line with a writer sweep, which is the form docs/system-specs/common/take-away-changes.md asks for when the take-away is the purpose of the change. My own sweep of origin/main (outside test) found no skill, script, doc or workflow that puts an unquoted variable in -C, --git-dir or --work-tree ahead of a push.
- Spec: the security.md paragraph matches the code, including the PowerShell carve-out.
- CI: every check green except Sensitive Change Review (waiting for the template below) and the readiness signal that follows it. Design, First Principles, Security Scope, GPT 6.1 and Opus 5.5 lanes pass. Merge-tree against main is clean.
Source-only: I did not run the change against a real bash or PowerShell; the word-splitting and the PowerShell behaviour are read from the shell semantics and the tests, which monkeypatch the platform flag.
Follow-ups (non-blocking): none required for this scope.
Sensitive change review
- Head commit: a2086ad
- What rule changed: the git publish floor's push-argument reader now returns a word before the push subcommand that carries an unquoted $ expansion, so the existing $ check marks the push unverifiable.
- Before -> after (what was allowed/blocked, now): before, git -C $d push origin feature (and git --git-dir=$d push origin feature) was allowed as a feature-branch push on Linux and macOS; now it is refused as git-publish-target-unverifiable. The quoted "$d",
$'...' and $ "..." forms, non-push commands, and every Windows spelling are unchanged. - Worst case if wrong (breaks commands / leaks secret / locks user out): a push that puts an unquoted variable in a git option before the subcommand is refused on Linux or macOS; quoting the variable is the working form. No secret exposure and no lock-out.
- Evidence checked (which sandbox result proves it): the three new tests in test/test_push_branch_gate.py drive the real enforcement point; each guard part was mutated on its own and a named test went red (pre-fix line, the $' exemption, the Windows exemption).
- No regression:
- Tools still work (which tools/commands were run, result): the quoted form and git -C $d status are asserted allowed in the new tests; the full push-gate file passes, 104 tests.
- Backward compatible (old config / old data / old callers still work, how checked): writer sweep of main found no shipped skill, script, doc or workflow writing the refused spelling; Windows reading unchanged by construction (empty list when IS_WINDOWS).
- Existing tests (which suites passed on this head): test/test_push_branch_gate.py locally; all backend, Windows, sandbox and denial-differential CI jobs green on this head.
- How to undo: revert the commit; the reader returns to its previous empty leading list.
|
@bolichen97 heads-up: after this merged, main's test_security_gate_liveness.py::test_the_package_stays_within_its_line_budget fails ('package grew to 34753 lines', budget 34733). This PR added a net 20 lines under src/kiro_crew/security/. #31625 (@buluoray) raises the budget by exactly those 20 lines, test-only, and I posted a VERDICT: APPROVE there. A maintainer approval on #31625 turns every PR's Backend shard 2 green again. |
Problem / Motivation
Goal: A git push whose destination cannot be determined before it runs is refused in the case the linked issue reports.
The publish check could accept a push in one spelling as a feature-branch push while the shell would run it against a different branch.
Why it matters
The publish check is what keeps an agent from pushing straight to a protected branch. A misreading lets that push through.
Not a goal
What changed (motivation → approach → change)
The check read one part of a push command as fixed text, while the shell can turn that part into different words when the command runs. That part now gets the treatment the check already gives such text elsewhere in a push: the push is refused as unverifiable, with no opt-out. Quoting the value keeps the command allowed. On Windows, whose shell does not split that text into words, the check reads the command as it did before. The
src/kiro_crew/securitychange comes with a matching paragraph in the security spec underdocsand one regression test undertest.Backwards compatibility
Breaking: on Linux and macOS, a push written in the spelling the linked issue reports is refused where main allowed it; quoting the value is the working form. Windows is unchanged. Writer sweep on origin/main @ 8a123e1: no shipped skill, script, doc or workflow writes that spelling.
Tests
Three regression tests: the reported spelling is refused as unverifiable; the quoted forms of the same value are still allowed, and an ordinary non-push command still runs; on Windows the same spelling of a feature-branch push stays allowed.
Determinism: 20/20 runs at
-n0, 10/10 at-n 4 --dist loadgroup --max-worker-restart=2beside a sibling test file, and the whole test file green in a shuffled order (seed 16048).Proof: PROVEN test/test_push_branch_gate.py::TestGitPushEnforcement::test_an_unquoted_expansion_before_the_subcommand_is_unverifiable, test/test_push_branch_gate.py::TestGitPushEnforcement::test_a_dollar_quote_before_the_subcommand_is_one_word (head a2086ad)
Manual verification
N/A — unit coverage sufficient: the check is a pure function of the command text, and the test drives it through the real enforcement point.
Screenshots / video
N/A — no user-visible frontend surface.
Related Issues
Closes #18520
Sibling sweep
Siblings: none -- this changes the one place that reads a push's target; other spellings are outside this PR (see Not a goal)
Pattern harvest
Not generalizable: one reading gap in one command check, closed by reusing the posture that check already applies elsewhere.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.