Repository navigation
Flag exec of a shell as opaque; add strict no_shell policy - #67
Merged
Merged
Conversation
cuihtlauac
added a commit
that referenced
this pull request
Nov 17, 2026
PR #67 closed plan-model follow-ups 1-2 (flag exec of a shell as opaque; strict no_shell policy). Record them in the changelog, drop them from the consolidated backlog item and the shell-hatch levers, and note that wrapper-hidden shells (env/nice/timeout, python -c) remain under the env-resolution follow-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
This was referenced Nov 17, 2026
cuihtlauac
added a commit
that referenced
this pull request
Nov 17, 2026
PR #67 closed plan-model follow-ups 1-2 (flag exec of a shell as opaque; strict no_shell policy). Record them in the changelog, drop them from the consolidated backlog item and the shell-hatch levers, and note that wrapper-hidden shells (env/nice/timeout, python -c) remain under the env-resolution follow-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
cuihtlauac
force-pushed
the
feat/no-shell
branch
from
November 17, 2026 19:23
aa064ea to
cda9daf
Compare
cuihtlauac
added a commit
that referenced
this pull request
Nov 18, 2026
PR #67 closed plan-model follow-ups 1-2 (flag exec of a shell as opaque; strict no_shell policy). Record them in the changelog, drop them from the consolidated backlog item and the shell-hatch levers, and note that wrapper-hidden shells (env/nice/timeout, python -c) remain under the env-resolution follow-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
cuihtlauac
force-pushed
the
feat/no-shell
branch
from
November 18, 2026 15:40
cda9daf to
1c61e79
Compare
cuihtlauac
marked this pull request as ready for review
November 18, 2026 15:47
cuihtlauac
added a commit
that referenced
this pull request
Nov 20, 2026
Drive the real daemon through the pty harness for the scenarios left from issue #68: - `a` on a daemon that is not eligible: not offered, no hint, approves once, and the same session is prompted again. - `a` on an eligible daemon: the hint names the session; a later request from that session runs unattended (audit line in the daemon log), while another session is still prompted, checked by ordering: the next prompt block carries that session's request ID. A privileged request from the granted session is still prompted, without `a`. - `a` on a privileged request denies, and nothing reaches sudo. - An unanswered prompt times out, the command does not run, and termios is restored. This waits the real 60 s, so it is #[ignore]d rather than adding a prompt-timeout setting to the human gate. Harness: `expect_within` (expect with a caller-chosen deadline) and `daemon_log`. A mutant that makes the grant daemon-wide fails a_grant_is_keyed_by_session. The --no-shell scenario goes with the feature in PR #67. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
Close the `exec sh -c` loophole: an Exec leaf (or flat-pipeline stage) whose program is a shell interpreter (sh/bash/dash/zsh/…, by name, path, or canonical resolved binary, with or without -c) is now flagged opaque at the prompt exactly like an explicit `shell` op. The decision lives in `push_leaf`, the one place every leaf is created, so the prompt and the policy read the same bit. Add the strict mode `protocol.rs` already promised: `policy.no_shell` in hosts.json, or `--no-shell` / `--allow-shell`, rejects any request with an opaque stage before prompting (ahead of the TUI, --pkexec and unattended paths). `--no-shell` is forwarded with `--host`; `--allow-shell` is refused there. Wrappers (env/nice/timeout) and other interpreters (python -c) are not detected yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
PR #67 closed plan-model follow-ups 1-2 (flag exec of a shell as opaque; strict no_shell policy). Record them in the changelog, drop them from the consolidated backlog item and the shell-hatch levers, and note that wrapper-hidden shells (env/nice/timeout, python -c) remain under the env-resolution follow-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
Through the pty harness, with the strict mode set by `--no-shell` or by `policy.no_shell` in an owner-private hosts.json: an `exec sh -c` request gets the policy error, and the next structured request is the first prompt drawn on the tty (checked by ordering, not by "no prompt seen"). Disabling the gate makes both tests fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
After rebasing onto the GHSA-xx2m-j9f7-gcmr fix, `unattended_eligible` was read from hosts.json through `load_trusted_policy`, but `no_shell` still used the unchecked `HostsConfig::load()`. Anyone who could write the file could then switch strict mode off without warning. Read the policy once, through the trusted loader, for both settings. An untrusted file fails closed for each: not unattended-eligible, and no_shell on. The warning names both effects. An explicit CLI flag still wins, and the file is read only if a flag is missing. New pty test untrusted_policy_turns_no_shell_on: a 0666 hosts.json saying `"no_shell": false` still gets the opaque request rejected. It fails when an untrusted file leaves no_shell off. Docs: usage.md, changelog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cuihtlauac ALVARADO <cuihtlauac@tarides.com>
cuihtlauac
force-pushed
the
feat/no-shell
branch
from
November 20, 2026 07:30
1c61e79 to
f70684e
Compare
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.
Backlog item #1, sub-items 1 and 2 (plan-model follow-ups). Rebased onto
main(after v1.2.1).Problem
Only an explicit
shellop was flagged opaque at the approval prompt. A plain{"op":"exec","argv":["sh","-c","…"]}(or a flatpipelinestage) put a whole shell on the path but rendered as a tame exec stage. And the "strict policy mode" promised inprotocol.rsdid not exist.Changes
src/executor.rs,push_leaf): a leaf whose program is a shell interpreter (sh,bash,dash,zsh,ksh,mksh,ash,fish,csh,tcsh,yash,posh) is opaque. It is matched by name, by path, or by the canonical resolved binary (catches a renamed symlink), with or without-c, sincebash script.shhides the script too. Because every leaf goes throughpush_leaf, plans and flat pipelines are covered, and the prompt and the policy read the same bit.no_shellpolicy:"policy": {"no_shell": true}inhosts.json, or--no-shell/--allow-shellon the daemon (same tri-state pattern asunattended_eligible). A request with any opaque stage is rejected before prompting, ahead of the TUI,--pkexecand unattended paths. The error names the stage and points to the structured ops.--no-shellis forwarded with--host;--allow-shellis refused there (edit the remotehosts.jsonto loosen it). The file is read through the same owner-private check asunattended_eligible(GHSA-xx2m-j9f7-gcmr). If the check fails, strict mode is on (fail closed), so ahosts.jsonanother user can write cannot switch it off.docs/usage.md"Strict no-shell mode"; MCPexecuteop docs and thePlan::Shelldoc comment updated.Not covered yet: wrappers (
env sh -c,nice bash …) and other interpreters (python -c,perl -e).Tests
tests/no_shell.rs: withno_shell, six opaque shapes (shell op, exec by name/path, shell without-c, a pipe stage, a flat pipeline) are rejected and the prompter is never called; structured requests still run; withoutno_shell, all are prompted.tests/pty_no_shell.rs(pty harness, Automate the manual end-to-end tests by driving the daemon through a pty #68): with--no-shell, withpolicy.no_shellin a 0600hosts.json, and with a 0666 file that says"no_shell": false, anexec sh -crequest gets the policy error, and the next structured request is the first prompt drawn on the tty. Disabling the gate, or letting an untrusted file turn strict mode off, makes the tests fail.policy.no_shellserde defaults.cargo test --release: all pass exceptburst_connections_above_cap_get_busy_response, which fails identically onmain(already skipped in CI).cargo clippy --all-targets: clean.sh opaque — resolves only the shell: /usr/bin/shand runs ony;--no-shellreturns the policy error with no prompt.🤖 Generated with Claude Code