You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
session_move (via the execute tool) lets an agent leave the session directory; external_directory: deny no longer confines it #61054
An agent can change its own session's working directory with tools.opencode.session_move({ directory: "../outside" }), called through the execute tool. No permission request is raised for the move. After it, ../outside is the session directory, so external_directory: deny no longer applies to it and the agent writes there.
Nothing I tried blocks the move: denying execute or session_move has no effect. Only edit: deny stops the write, and the session still moves.
Possibly intended (the tool exists to change directory), but then external_directory cannot be used to confine an agent, and I found no rule that can.
OpenCode version
v2.2.5 (release binary, linux-x64)
Steps to reproduce
Model: openrouter/deepseek/deepseek-v4.1-flash. Server API, session created with these rules, directory /work/proj, sibling directory /work/outside exists:
First use your execute tool to run exactly: await tools.opencode.session_move({ directory: "../outside" }). Then create the file /work/outside/x containing done with your write tool.
Result: /work/outside/x is created, GET /api/session/{id} shows location.directory = /work/outside, and GET /api/session/{id}/permission stays empty.
Same rules plus {"action":"execute", ...,"effect":"deny"}, or plus {"action":"session_move", ...,"effect":"deny"} (also tried opencode.session_move): same result. With an ask rule on *, the move raises no request either; only the later edit does.
I saw the same bypass without being asked to call session_move: with only shell and external_directory denied and the prompt "create the file /work/outside/x, using any tool you have", the model chose it on its own in 1 of 3 runs.
Expected
Either session_move goes through a permission check (for example external_directory on the target), or a documented rule can deny it.
Thanks for the detailed report and repro, @nickywan!
I think this is a duplicate of #49825. It reports the same thing: session_move doesn't ask for any permission, so a session can move itself out of the directory it was confined to, and the path restrictions no longer apply. The tools docs say so: "These utilities do not request a built-in permission action." There is an open PR, #58047, that would add an opencode_session_move permission check on the resolved destination, which is what you expected.
The code also explains why your deny rules made no difference:
Denying execute turns Code Mode off, but its tools are then offered to the model as direct tools, so session_move is still available.
A deny rule with resource * only hides a tool when the action matches the tool's internal name. For this tool that is opencode_session_move (namespace and name joined by _), not session_move or opencode.session_move.
So, from reading the code (I haven't tested it), this rule should take the tool away from the agent until #58047 lands:
We haven't heard back since the last comment, so I'm closing this as a duplicate of #49825. That issue reports the same gap: session_move doesn't ask for any permission, so a session can move itself out of the directory it's confined to and external_directory no longer applies. Please follow #49825 and the open PR #58047, which would add an opencode_session_move permission check on the destination.
In the meantime, this rule should keep the tool away from the agent. I got this from reading the code and haven't tested it:
Activity
opencodejr commentedon Nov 1, 2026
Thanks for the detailed report and repro, @nickywan!
I think this is a duplicate of #49825. It reports the same thing:
session_movedoesn't ask for any permission, so a session can move itself out of the directory it was confined to, and the path restrictions no longer apply. The tools docs say so: "These utilities do not request a built-in permission action." There is an open PR, #58047, that would add anopencode_session_movepermission check on the resolved destination, which is what you expected.The code also explains why your deny rules made no difference:
executeturns Code Mode off, but its tools are then offered to the model as direct tools, sosession_moveis still available.*only hides a tool when the action matches the tool's internal name. For this tool that isopencode_session_move(namespace and name joined by_), notsession_moveoropencode.session_move.So, from reading the code (I haven't tested it), this rule should take the tool away from the agent until #58047 lands:
{ "action": "opencode_session_move", "resource": "*", "effect": "deny" }Possible duplicates and related issues, ordered from most to least likely:
session_move, so a session can move itself and get around its path restrictionsopencode_session_movepermission check (closes [FEATURE]: Permission action for session utilities (session_move / session_rename) #49825)execute/session_movehint is still added when Code Mode is deniedexternal_directoryThe bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.
opencode-agent commentedon Nov 1, 2026
Closing as a duplicate of #49825, which tracks the same problem. Please follow that issue for updates, and add any new details there.
opencodejr commentedon Nov 2, 2026
We haven't heard back since the last comment, so I'm closing this as a duplicate of #49825. That issue reports the same gap:
session_movedoesn't ask for any permission, so a session can move itself out of the directory it's confined to andexternal_directoryno longer applies. Please follow #49825 and the open PR #58047, which would add anopencode_session_movepermission check on the destination.In the meantime, this rule should keep the tool away from the agent. I got this from reading the code and haven't tested it:
{ "action": "opencode_session_move", "resource": "*", "effect": "deny" }If your problem turns out to be different from #49825, reply here and explain how, and we can reopen it. Thanks again for the clear repro, @nickywan!