Skip to content

Read Substitutions Inside a Quoted Parameter Expansion or an Unquoted Heredoc Body in the Write Guard #2989

Closed

Description

@ptr727

Context

Found by the local review of the fix for #2976 and #2977. Each shape is allowed by develop's guard and by that fix, found by a classify probe on constructed commands. None is a regression.

Substitutions the Write Guard Still Does Not Read

  • A substitution inside a parameter expansion inside double quotes. echo "${X:-$(git push origin develop)}" and the backtick spelling of the same are allowed, since the double-quote scan skips a ${...} whole. The unquoted echo ${X:-$(git push origin develop)} is denied.
  • A substitution in a heredoc body whose delimiter is unquoted. Bash expands $(...) and backticks in a <<EOF body, while the guard skips every heredoc body that no shell reads. So a commit message written through git commit -F - <<EOF holding a Markdown-style backtick span such as `git push origin develop` runs that push, and the guard allows it. The same holds for x="$(cat <<EOF ... $(git push origin develop) ... EOF)". The quoted <<'EOF' form, the common one, is not affected.

Possible Direction

Fail closed as the rest of this class does. Scan a ${...} body inside double quotes for the substitutions it holds, and read the body of a heredoc whose delimiter is unquoted for its substitutions, as a double-quoted span is read, while leaving a quoted delimiter's body as data.

Activity

  1. added
    pre-existing
    script
    on Oct 14, 2026
  2. ptr727 commented on Oct 14, 2026

    @ptr727
    OwnerAuthor

    A third shape in the same class, from the second local review pass: a command substitution inside arithmetic inside double quotes. echo "$(( $(git push origin develop) ))" is allowed on develop and on the #2976/#2977 fix, since the double-quote scan skips a $((...)) whole. The unquoted echo $(( $(git push origin develop) )) is denied.

  3. ptr727 commented on Oct 15, 2026

    @ptr727
    OwnerAuthor

    Claimed for an engineering-track lane (handoff #3040 resume). Branch: feature/guard-hidden-commands-3010. Predicted file set: host-setup/agent-safety/claude/gh-write-guard.py, host-setup/agent-safety/claude/test_install.py, host-setup/agent-safety/README.md, host-setup/agent-safety/claude/README.md.

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

    pre-existingscript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions