Skip to content

Read Words the Shell Rewrites Before a Push in the Write Guard #2959

Closed

Description

@ptr727

Context

A local review of the #2951 change found these. Each is allowed by develop's guard as well, and none is listed in #2943, #2951, #2957, or #2958. Each was found by a classify probe on constructed commands, with the branch rules given as a test seam.

Words the Shell Rewrites Before Git Reads Them

The guard reads a push from its words as written, while the shell rewrites some of them first.

  • A quote-split word. The raw pre-filter _GIT_PUSH matches git ... push in the text, so git p''ush origin develop and git "pu"sh origin develop never reach the push check. The shell joins each into push, so a push to develop passes under a pull_request rule. The same split hides an include key from _GIT_INCLUDE, as in git -c 'inc''lude.path=/example/config' p.
  • A run-time word as a refspec. git push origin $(echo develop), a backticked form, and B=develop; git push origin $B are read as a branch literally named $(echo, and so on, not as develop.
  • An uppercase GIT. _GIT_PUSH is case-sensitive while _is_git_exe is not, so GIT push origin develop passes. That only matters where the shell resolves GIT to git case-insensitively, as on Windows.

Possible Direction

Fail closed rather than model the expansion: run the pre-filters over the unquoted shell tokens rather than the raw text, deny a push whose refspec or remote word holds a $ or a backtick as unreadable, and match the pre-filter without case.

Activity

  1. added
    script
    on Oct 13, 2026
  2. ptr727 commented on Oct 13, 2026

    @ptr727
    OwnerAuthor

    A later local review pass on the #2951 change found the same class through a backslash-newline. classify folds a backslash-newline into a space, while the shell joins the two halves into one word, so an include key split that way (inc, backslash-newline, lude.path=/example/config) reads to the guard as a -c inc override followed by a subcommand named lude.path=..., and the new include check never sees it. The split-word deny covers a command holding a push word only.

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

    script

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions