Skip to content

Decide Whether an Unquoted Directory Option Value Fails Closed in the Write Guard #2977

Closed

Description

@ptr727

Context

A local review of the #2959/#2961 fix found this. It is allowed by develop's guard as well, and the fix leaves it open on purpose. Each shape was found by a classify probe on constructed commands.

An Unquoted Directory Option Value That Word Splitting Splits

The #2959/#2961 fix fails closed on a run-time word among a push's or a commit's global options, but it reads a -C, --git-dir, or --work-tree value as it stands, unquoted too. Word splitting can turn an unquoted value into more options before the subcommand.

  • X='. -c core.hooksPath=/dev/null'; git -C $X commit -m x runs a commit under a hooks-path override.
  • X='x -c core.hooksPath=/dev/null'; git --git-dir=$X commit -m y does the same.

The exemption is kept because an unquoted git -C $W commit and git -C $W push origin <branch> are common agent spellings, and denying them would block ordinary work far more often than the shape above occurs. A value with no subcommand word after it, such as git -C $X, is denied by the fix.

Possible Direction

Decide whether the unquoted directory value is worth failing closed on. If it is, require the value to be split-free, as the fix already does for a commit option's value, and accept the over-denial of an unquoted -C $W on a push or commit.

Activity

  1. ptr727 commented on Oct 14, 2026

    @ptr727
    OwnerAuthor

    A Split Value That Supplies the Subcommand Itself

    CodeRabbit raised a wider form of this on the #2980 promotion. The split value can carry the subcommand and its arguments, so the word the guard reads as the subcommand becomes a trailing argument:

    • D='. commit -n --allow-empty -m'; git -C $D status runs a commit with its hooks skipped, while the guard reads status as the subcommand and never reaches the commit or push checks.
    • D='. push --force origin HEAD:main -o'; git -C $D status hides a forced push the same way.

    A classify probe on constructed commands allows git -C $D status, git -C $D commit -m x, and git -C $D push origin feature/x on both develop's guard (4a0370f) and main's guard (ae63f7b), so this is no allow flip from the #2959/#2961 fix, and the decision this issue asks for covers it too. The reviewer's proposed direction is the one already written above: exempt a directory value only where _split_free holds, keeping -C "$dir" allowed and denying an unquoted -C $dir. That denial now reaches any subcommand, not only a push or a commit, since the hidden one can sit behind status.

  2. added
    script
    decision
    on Oct 14, 2026
  3. ptr727 commented on Oct 14, 2026

    @ptr727
    OwnerAuthor

    Maintainer decision (2026-10-14): fail closed unless split-free. Exempt a -C, --git-dir, or --work-tree value only where _split_free holds, so a literal path and a quoted "$W" stay allowed and an unquoted $W is denied for every subcommand, not only a push or a commit. The deny message should name quoting the variable as the fix. The decision label is removed. The issue stays open for the implementation, which runs as its own guard lane with the develop-versus-branch differential.

  4. removed
    decision
    on Oct 14, 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

    script

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions