Skip to content

Honor the Quote Mask in the _runs_as_command Short-Circuit #2310

Closed as not planned

Description

@ptr727

Problem

_runs_as_command in host-setup/agent-safety/claude/gh-write-guard.py decides whether a bash -c wrapper runs. #2117 lets its walk back honor the quote mask, so echo ';' x bash -c '<loop>' runs no shell. Its _opens_command short-circuit before that walk still reads a quoted ; directly before the wrapper as a separator, so this constructed command is denied although no shell runs:

echo ';' bash -c 'until [ -f x ]; do sleep 60; done'

Done looks like

The short-circuit honors the mask where the caller passes one, with a self-test row for the shape above. This is a false deny, not a leak.

Found by a local strict review pass on #2117. It predates that pull request.

Activity

  1. ptr727 commented on Oct 6, 2026

    @ptr727
    OwnerAuthor

    The sleep path has the same false deny, since _sleeps calls _runs_as_command with no quote mask at all:

    while [ -f x ]; do echo ";" sleep 1; done

    Develop denies it, although echo prints the ; and nothing sleeps. The #2080 branch fixed both shapes by passing the mask and honoring it in the short-circuit. Decision #2367 reverted those changes to keep that branch on eval-only paths, so both stay develop's behavior for this issue to fix. The reverted early return also skipped a quoted assignment before a wrapper, which let GIT_PAGER="/bin/cat" bash -lc '<loop>' through. So the fix here honors the mask only for a quoted separator, never for a quoted word that is an assignment or a prefix.

  2. ptr727 commented on Oct 8, 2026

    @ptr727
    OwnerAuthor

    Declined per #2517, approved by the maintainer, under GOVERNANCE.md "Trust Boundaries and Hardening Effort": The guard backstops an agent's own mistakes, and this is a command shape built to defeat it rather than one an agent session writes, so a miss does not realistically occur. See #2517 for the per-issue reason.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions