Skip to content

fix(guardrails): close remaining block-unresolved-pr-merge target-resolution gaps #8657

Closed

Description

@kyle-sexton

Refs: #8598, #8628

GitHub Security & Cost's pass on #8628 (low) listed these gaps as pre-existing or medium, for a follow-up. Each needs the agent itself to write the command; none is reachable from a public attacker.

Items 1-4 are held by the owner (2026-10-22).

  • 1. Pre-filter on raw text: gh pr mer"ge" 5, VERB=merge; gh pr $VERB, and gh api -X "$M" .../merge skip the hook's merge detection.
  • 2. Host-qualified repo: -R github.com/o/r gets a 404, which takes the fail-open path. Strip the host, and refuse a 404 on a literal target.
  • 3. Repo context changes: GH_REPO=x/y or cd other && makes the hook check the session repo's PR; a closed one exits 0.
  • 4. Unencoded branch: a branch name goes into the pulls head= query unencoded.
  • 5. gh aliases: missing from the hook's KNOWN GAPS list. Done in fix(guardrails): anchor the merge guard's backtick refusal to a gh command word #8844 (df334a95b4): the list names "a gh alias" (plugins/guardrails/hooks/block-unresolved-pr-merge.sh:83).

Done when each has a stay-loud test that fails before its fix (or, for 5, the KNOWN GAPS entry), and the suite stays green.

Activity

  1. added
    needs-triage
    on Oct 20, 2026
  2. github-actions commented on Oct 20, 2026

    @github-actions
    Contributor

    Proposed work class: work-class: scoped
    Basis: automated intake triage; the lanes App applied this class.

    Size: Medium
    Complexity: Medium
    Uncertainty: Knowable
    Flags: none

    Understood: four remaining gaps in the block-unresolved-pr-merge hook need fixes, each with a test that fails before the fix. The gaps are raw-text pre-filter bypasses, host-qualified -R repos failing open on 404, repo-context changes (GH_REPO or cd), and an unencoded branch name in the head= query. Item 5 is already done. They are hardening of an existing hook, and each needs the agent to write the command itself. No decision recorded or missing info blocks this. Likely duplicates: none found among open issues (related: #8598, #8628).

    Automated triage, applied by the lanes App.

  3. added
    needs-human
    and removed
    needs-triage
    on Oct 20, 2026
  4. kyle-sexton commented on Oct 20, 2026

    @kyle-sexton
    MemberAuthor

    Correction: #8628 does not join backslash-newlines (an earlier commit did, and the AI review showed it opens bypasses through comments, quoted heredocs and escaped backslashes). As of 8d8c063, a pr merge or REST merge route continued with a backslash-newline is refused instead, which also closes the in-word continuation case. Item 1's quote and variable obfuscations (mer"ge", VERB=merge; gh pr $VERB, -X "$M") remain open.

  5. kyle-sexton commented on Oct 20, 2026

    @kyle-sexton
    MemberAuthor

    False positive from #8628's backtick refusal (reported by GitHub Security & Cost): a read-only command with no merge was refused.

    jq -r '.autoMode | .. | strings | select(test("Gated PR Merge"))' ~/.claude/settings.json | grep -oE '^[1-6]\. `[^`]*`'
    

    Lowercased, "Gated PR Merge" matches the pr[[:space:]]+merge shape, and the single-quoted grep pattern holds a backtick, so the whole command is refused as a merge. The same refusal hit this comment when it was posted through gh issue comment --body-file - with a heredoc, so any heredoc PR or issue text that mentions the guard's name and uses a backtick is refused too.

    Fix idea: anchor the shape match to a command segment whose argv[0] is gh (after an optional prefix such as env/command), or to a REST or GraphQL merge route, instead of matching anywhere in the text. Trade-off: anchoring re-opens obfuscated spellings (g""h pr merge), already item 1 here, so the fix should keep refusing a backtick plus pr merge when argv[0] can't be resolved. Stay-quiet tests for this command and for a heredoc gh issue comment body must fail before the fix, per the hook-precision convention. Severity: low to medium. Rephrasing costs a turn, and heredoc bodies are a common agent pattern.

  6. kyle-sexton commented on Oct 21, 2026

    @kyle-sexton
    MemberAuthor

    The false positive recorded here on 2026-10-20 (prose naming the guard next to a backtick) is fixed by #8844, merged 2026-10-21 as df334a9. The guard now treats pr ... merge as merge-shaped only when the word before pr is gh or can't be resolved, and the KNOWN GAPS header was brought up to date. Items 1-5 above stay open (hardening, held under #7719).

  7. kyle-sexton commented on Oct 22, 2026

    @kyle-sexton
    MemberAuthor

    This was generated by AI during attend-queue.

    Owner decision (2026-10-22): keep items 1-4 held; item 5 is done in #8844 (df334a95b4), whose KNOWN GAPS list names "a gh alias" (plugins/guardrails/hooks/block-unresolved-pr-merge.sh:83). The body's task list now shows this.

  8. removed
    needs-human
    on Oct 24, 2026
  9. kyle-sexton commented on Oct 24, 2026

    @kyle-sexton
    MemberAuthor

    Released for re-triage under the owner's 2026-10-24 rule: an issue stops for a person only for an intent or vision question, a security call, a host or attended run, or spend outside prepaid credit. The hold label came off and intake triage runs again now; it re-applies a hold, with a numbered question, when one of those applies.

    To hold this issue again, add needs-human (or status: needs-decision) and say why in a comment.

  10. added
    needs-triage
    and removed
    needs-triage
    on Oct 24, 2026
  11. added
    status: ready
    agent-ready
    and removed on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readystatus: ready

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions