Repository navigation
Description
Found during independent verification of #1405. Pre-existing on main — not introduced by that PR.
The invariant
plugins/source-control/bin/source-control-babysit-merge states that it is the allow-rule boundary:
this wrapper is the allow-rule boundary and must not depend on the interpreter behind it
It enforces that by refusing --allow-unpinned-head and every long-option prefix of it. That part works — verified exhaustively:
--allow-unpinned-head rc=2 ... is not permitted through the wrapper
--allow-unpinned-hea rc=2 ... is not permitted through the wrapper
--allow-unpinned rc=2 ... is not permitted through the wrapper
--allow-unpin rc=2 ... is not permitted through the wrapper
--allow rc=2 ... is not permitted through the wrapper
--allo / --all / --al / --a rc=2 ... is not permitted through the wrapper
The gap
The guard is a prefix test:
[[ "$arg" == --a* && "--allow-unpinned-head" == "$arg"* ]]--allow-unpinned-head=true does not satisfy "--allow-unpinned-head" == "$arg"*, because $arg carries the =true suffix. So the wrapper passes it through:
--allow-unpinned-head=true rc=2 usage: babysit_merge.py [-h] [--allowed-owners ALLOWED_OWNERS]
It is still refused — but by argparse, not by the wrapper. That is exactly the dependency the wrapper says it must not have.
Why it is safe today and why that is not enough
The flag is store_true, so argparse rejects an =value spelling outright. The refusal is real. But it is incidental: the moment that flag takes a value — or an equivalent guarded flag is added that does — the wrapper silently stops being the boundary, and nothing fails loudly to say so. The guard would keep passing its existing tests while no longer guarding.
This is a defense-in-depth invariant on the merge path, which is why it is worth closing rather than noting.
Suggested fix
Strip any =value suffix before the prefix comparison, so the guard tests the option name rather than the whole argument. Add cases for --allow-unpinned-head=true, --allow-unpinned=1, and a bare --allow-unpinned-head to the wrappers own test suite, asserting the refusal comes from the wrapper (its exact refusal message) and not from an argparse usage error — asserting only on exit code would pass today for the wrong reason.
Related
No linked issue. Found while verifying #1405.
Activity
kyle-sexton commentedon Jul 26, 2026
This was generated by AI during triage.
Triage
Verification: confirmed by direct source read.
plugins/source-control/bin/source-control-babysit-merge(current
main) carries exactly the guard the issue quotes:[[ "$arg" == --a* && "--allow-unpinned-head" == "$arg"* ]]. This is a pure prefix test in bothdirections —
"--allow-unpinned-head" == "$arg"*requires the full literal to start with$arg,which fails the moment
$argcarries an=valuesuffix (--allow-unpinned-head=trueis not aprefix-match target of the bare flag string). The guard is bypassed at the wrapper layer for that
spelling; the issue's own repro is correct that argparse (not the wrapper) is what actually refuses
it today, because the flag is
store_trueand argparse rejects=valueon a store_true flagregardless. That safety net is real but incidental — verified only one guarded flag exists in this
wrapper today (
--allow-unpinned-head; no other--allow*guard is present), so the exposure iscurrently exactly what the issue describes: dormant unless the guarded flag (or a future one) starts
taking a value.
Classification
Bug(native Issue Type set).priority: medium(already applied, kept as-is) — defense-in-depth invariant on themerge path, currently safe in practice (argparse still refuses the bypassed spelling today), so not
an active exploit; real value fixing it, no hard deadline.
=valuesuffixbefore the prefix comparison) and the exact test additions, with no open design question.
Agent Brief
Type: Bug
Summary: The
source-control-babysit-mergewrapper's guard against--allow-unpinned-head(andprefixes of it) does not recognize the
=valuespelling of the flag, so that spelling passes throughthe wrapper unrefused — currently caught only incidentally, by the downstream interpreter's own
argument parser rejecting an
=valueon a boolean flag, which is exactly the interpreter dependencythe wrapper's own stated purpose says it must not have.
Current behavior: The wrapper's guard is a plain string-prefix comparison between the raw
argument and the guarded flag's literal text. An argument that matches the guarded flag but carries
an
=valuesuffix (e.g.--allow-unpinned-head=true) does not satisfy the prefix comparison ineither direction, so the guard's loop passes it through to the wrapped program unrefused.
Desired behavior: The guard recognizes and refuses the guarded flag's
=valuespelling itself,with the same explicit refusal message and exit behavior as every other refused form — never relying
on the wrapped program's own argument parser to reject it. Stripping any
=valuesuffix before theprefix comparison (so the comparison tests the option name, not the whole argument-plus-value token)
achieves this without weakening the existing prefix-family refusal.
Key interfaces:
"$@"and refuses the protected flagand its prefixes.
Acceptance criteria:
--allow-unpinned-head=true(and other=valuespellings of the guarded flag or itsprefixes, e.g.
--allow-unpinned=1) is refused by the wrapper itself, not by the wrappedprogram's argument parser.
behavior for the
=valuespellings — asserting only a non-zero exit code would pass today forthe wrong reason (the wrapped program's parser, not the wrapper) and would not catch a
regression.
--allow-unpinned-head,--allow-unpinned-hea,--allow, etc.) still refuse correctly — the fix must not narrow theexisting coverage.
Out of scope:
--allow-unpinned-head— none exists in this wrapper today.Labels applied:
agent-ready(autonomous-eligible role label),status: ready.priority: medium,area: security,work-class: scopedunchanged. Role label resolved from tracker defaults —.work-item-tracker.jsoncarries norole_labelsremap.Related: #1405 (the PR whose independent verification surfaced this pre-existing gap).
kyle-sexton commentedon Jul 26, 2026
kyle-sexton commentedon Jul 26, 2026
This was generated by AI during work-loop execution.
Claimed and fixed via #1539 (branch
fix/1522-babysit-merge-wrapper-equals-value-bypass). Reproduced the--allow-unpinned-head=truebypass on unmodifiedorigin/mainfirst (red), confirmed the wrapper let it through to argparse rather than refusing it itself, then fixed by stripping a--flag=valuetail before the prefix comparison. New tests assert the wrapper's own refusal text (not just exit code, since exit 2 is shared with argparse's own errors on this path) for--allow-unpinned-head=true,--allow-unpinned=1, and--allow-unpinned-hea=1, plus no-over-refusal rows for sibling--allow*flags. Full detail and test evidence in the PR.fix(source-control): close the merge wrapper's =value spelling bypass (…