hook: refuse a quoted command string passed through a login shell - #508
Conversation
This was referenced Sep 12, 2026
Owner
Author
|
This pull request is part of a Mergify stack:
|
2 tasks
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_b4f81974-f0cc-47e1-bd46-3f4d0b6ad249) |
This was referenced Sep 12, 2026
EdbertChan
added a commit
that referenced
this pull request
Sep 13, 2026
…ody checker on PR #508's live body after the rewrite. Goal: Prove the body passes as published. Motivation: A PATCH that returned 200 is not proof the live body passes. Safety invariant: Read-only; a failed fetch fails the task instead of passing. Verify: exit code 0 and output PR body validation passed. Effectiveness measurement: The same checker the required GitHub check runs passes on the live body, so the PR is no longer blocked on its text. Exit code: 0
3 tasks
`sudo -i` starts the target user's login shell, and that shell parses the remaining arguments a second time. The quoting the first parse consumed is gone by then, so the command string is re-split and its first word becomes the whole command. A handoff script died this way in a user's terminal. Reproduced on a real host, one variable apart: `sudo -u demo -H bash -lc '<body>'` prints the body's output, and the same line with `-i` gives `bash: line 1: set: -c: invalid option`. Newlines are not the trigger, which is what the first reading of the failure got wrong. A multi-line body survives ssh and survives sudo without `-i`. Backtested over 37,015 real Bash commands: 6 hits, all the broken shape. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KU2pPKob4MJ1NqjsfTNyYJ Change-Id: Iacc7d62317959adeb953d4fef0bc9dc222a37430
EdbertChan
added a commit
that referenced
this pull request
Sep 13, 2026
…ody checker on PR #508's live body after the rewrite. Goal: Prove the body passes as published. Motivation: A PATCH that returned 200 is not proof the live body passes. Safety invariant: Read-only; a failed fetch fails the task instead of passing. Verify: exit code 0 and output PR body validation passed. Effectiveness measurement: The same checker the required GitHub check runs passes on the live body, so the PR is no longer blocked on its text. Exit code: 0
EdbertChan
force-pushed
the
stack/EdbertChan/reflect/ui-input-guard-hook-freshness-20260908/count-bogus-didn-t-run-same-class--065043b6
branch
from
September 13, 2026 05:55
b680e2b to
ce9983e
Compare
EdbertChan
force-pushed
the
stack/EdbertChan/reflect/ui-input-guard-hook-freshness-20260908/refuse-quoted-cmd-string-passed-login-shell--acc7d623
branch
from
September 13, 2026 05:55
d76e1e5 to
7d7ef8b
Compare
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_7ae2b92a-d3dc-45f5-af7c-fe78a14d1509) |
Owner
Author
Revision history
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This part checks commands before they run and stops a risky remote handoff that can break for a person.
The problem was a handoff script failing after a login shell changed the command.
The cause was a second parse that removed quoting and split the command string again.
The fix blocks this shape and explains how to avoid it by copying the script and running it by path.
Review Claim
Approve stopping quoted remote command strings that a login shell will parse again, with clear guidance for a safe replacement.
Review Lane
behavior
Review Unit
engine-runtime
Safety Invariant
This adds a fail-open command check, changes no unrelated command shapes, and keeps script-by-path execution allowed. The change is limited to the new guard and its wiring, documentation, and tests.
Slice Rationale
This slice adds one guard with its installation, documentation, and regression fixtures so the behavior and its supported escape hatch are reviewed together.
The existing evidence reports a reproduction on a real host and a backtest over 37,015 real Bash commands with 6 hits, all matching the broken shape.
Non-goals
Test Plan
Test Plan
python3 -m unittest discover -s engine/hooks/remote-payload-collapses/tests -v— unit coverage for blocking and allowed command shapes.python3 tests/test_install.py— installation wiring coverage.set: -c: invalid option.Revert Plan
Revert Plan
gh api -X PATCH repos/EdbertChan/catstack/pulls/508 -F body=@/tmp/pr-body-rewrite/508.md.origCo-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01KU2pPKob4MJ1NqjsfTNyYJ
Depends-On: #507