Repository navigation
Description
Description
An explicit session or agent shell deny is enforced by the registered shell tool, but not by session-attributed human shell execution, direct shell creation, or command-template interpolation.
Reproduced on untouched upstream dev at 0cc819142f0c6d614f9548e7fc2bcbecd6fd934b, fetched and tested on 2026-11-10. For each deny case, the real permission service rejects the same session and command with Permission.BlockedError, yet the non-tool entry point succeeds and creates a harmless marker file. The actual HTTP handler also returns 200 and creates the marker despite the stored session deny. Client-side plugin readiness was awaited before testing.
Plugins
No third-party plugins. The built-in configuration shell plugin was active. Tests use the real session, agent, permission, shell, template and HTTP-handler implementations; only model scheduling is disabled so no model request is needed.
OpenCode version
Upstream dev commit 0cc819142f0c6d614f9548e7fc2bcbecd6fd934b; private repository-required Bun 1.4.4. This is source qualification, not a claim about a release binary.
Steps to reproduce
-
In an isolated workspace configured to use Bash, create a session with this stored rule:
{ "action": "shell", "resource": "*", "effect": "deny" } -
Submit
!echo qualification-marker > markerto that session. Alternatively, invoke itsSession.shellpath directly in a core integration test. -
Separately, send
POST /api/shellwith the matching URL-encodedlocation[directory]query and this body, replacing the two placeholders:{ "command": "echo qualification-marker > marker", "cwd": "<absolute fixture directory>", "metadata": { "sessionID": "<denied session ID>" } } -
Invoke a command template that interpolates the same shell command. Repeat with the deny rule on the selected agent instead of the session.
-
Compare with the registered shell tool using the same session and command.
Expected: session-attributed execution consults the shell permission before spawning; explicit denial prevents the marker in every case.
Observed: user/API/template execution creates the marker for both session and agent denies. The shell tool blocks both deny controls. Four allow controls execute normally. The focused core reproduction has six expected no-marker assertion failures and six passing controls; the HTTP reproduction has one additional no-marker assertion failure, with no fixture/JUnit errors.
The relevant distinction is in shell.ts: non-tool callers provide no permission callback. Template interpolation calls AppProcess.run directly in command.ts.
Related: upstream-54842 proposes shell-hook attribution, but not this non-tool permission check; upstream-61645 discusses broader race-safe admission. This report is limited to explicit deny enforcement, not terminal/PTY coverage or the historical interactive-ask allegation in upstream-56470. The current hook also lacks session attribution and a supported refusal contract, limiting plugin workarounds; that is separate from the demonstrated permission inconsistency.
Screenshot
Not applicable: the reproduction checks a marker file and the HTTP result without a UI.
Operating System
Windows x64, using Bash for the marker command.
Terminal
Headless core integration tests and the actual ServerFetch HTTP dispatcher; no UI or external listener required.
Tested upstream
Fresh upstream dev 0cc8191 (2026-11-10T00:20:41Z), rechecked current at 00:32:21Z; Bun 1.4.4/Windows. Real Permission.assert rejects matching session/agent shell deny, yet user/API/template routes create the fixed marker in all 6 cases. Tool deny controls block 2/2; allow controls pass 4/4. Actual HTTP shell.create returns 200 and creates marker despite stored session deny. Production source and lockfile unchanged; no terminal or ask-decline coverage.
Activity
neriousy commentedon Nov 10, 2026
Triage test: this is what the bot would post. Posted by a script, not by the bot.
Thanks for the detailed write-up and the source reproduction.
You're asking for explicit session and agent
shelldeny rules to apply to every shell command tied to a session, not just the agent's shell tool. That covers!commands typed by a person,POST /api/shell, and!`…`interpolation in command templates.Your findings match the code. However, the current behaviour looks intentional rather than a bug. The docs describe permissions as controlling what tools can do during a session, and
SECURITY.mddescribes them as a way to keep you aware of what the agent does, not as a security boundary. Commands a person runs (directly, through the API, or through a template they wrote) aren't currently covered. Extending deny rules to them is a reasonable request, so I've filed this as a feature request for the maintainers to consider.As you noted, a plugin can't do this today. The
shellcreate.beforehook doesn't receive the session ID and has no supported way to refuse a command, and template interpolation doesn't go through that hook at all. These plugin API additions would make it possible:shell.create.beforeRelated issues:
external_directoryask skipped for shellprovider.usedeny not enforced