Skip to content

A Trailing Backslash Hides a Loop From the Guard's Wait-Loop Rule #2442

Closed as not planned

Description

@ptr727

Problem

When a command ends in an unescaped backslash, shlex raises "No escaped character", and _shell_tokens in host-setup/agent-safety/claude/gh-write-guard.py falls back to splitting the line on whitespace. That split fuses each ; into the word before it, such as false; and done;, so no loop keyword sits in command position and the loop goes unread. Bash reads the trailing backslash as a literal and runs the loop.

Reproduce (constructed)

Each of these is allowed on develop, and bash runs the loop:

until false; do sleep 1; done; echo \
bash -c 'until false; do sleep 1; done; echo \'
eval 'until false; do sleep 1; done; echo C:\'

bash -c 'for i in 1; do echo RAN; done; echo \' prints RAN.

Done looks like

A trailing unescaped backslash is read as a literal character rather than as a reason to fall back, or the fallback splits operators off words. All three commands above are denied, and a self-test row pins each.

Found by a local strict review pass on the #2080 branch. It predates that branch.

Activity

  1. added
    bug
    agents
    on Oct 6, 2026
  2. ptr727 commented on Oct 8, 2026

    @ptr727
    OwnerAuthor

    Declined per #2517, approved by the maintainer, under GOVERNANCE.md "Trust Boundaries and Hardening Effort": An unquoted trailing backslash beside a wait loop is not a shape an agent session writes, and the failure is a loud hang.

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

    agentsbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions