read/edit rules and managed file policies are skipped by the shell, MCP/plugin tools and --file
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 48/100
Rechercherichtung
Start with packages/core/src/shell/permissions.ts, packages/core/src/tool/mcp.ts, and packages/cli/src/run/run.ts to trace how paths bypass read, edit, .env, and external-directory policies. Identify where shell commands, MCP/plugin tools, Code Mode, and --file need the same path checks as the built-in file tools. Done means each route consistently honors the applicable rules or the documentation explicitly states a supported limitation.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Description
Tested on 2.4.2 with opencode run --standalone. read/edit rules, external_directory rules, the built-in .env ask and managed tool.use policies such as read:secret/* are checked by the read, write and edit tools. Other routes reach the same files with no check. Related:
- Shell:
cat, a background shell orpython3 -cread a file thereadtool refuses,printf > filewrites past aneditdeny or ask, andcat .env.d/a.txtgets past the.envask. The shell only checksshellandexternal_directory. The docs do say shell has the host user's authority, but the policy docs listread:*/.ssh/*as blocking "Reading SSH material", and acatgets around that. grep has the same gap (#64059).packages/core/src/shell/permissions.ts:44-59 - MCP tools, plugin tools and Code Mode: an MCP tool is checked only as
<server>_<tool>with resource*, sofiles_read(path)returns a file under areaddeny, the managed policy orexternal_directory: deny, andfiles_writewrites into a denied folder. The same throughexecuteand through a plugin tool that usesfs. The docs say MCP tools match*and plugin tools enforce what they assert, but the file-rule docs don't warn that file rules don't cover tools that take a path.packages/core/src/tool/mcp.ts:63-69 opencode run --fileputs the file into the first model request under areaddeny, the.envask,external_directory: denyand the managed policy: the CLI reads the file itself. Low impact, since the user names the file.packages/cli/src/run/run.ts:171-199
Expected: apply the file rules to the paths these routes use, or say next to the file rules and tool.use file policies that they only cover the built-in file tools.
Plugins
No response
OpenCode version
2.4.2
Steps to reproduce
Project /work (git repo) with secret/a.txt (dummy text) and an empty canary/; /outside/a.txt. Global ~/.config/opencode/opencode.json with a provider and model, plus the permissions given per step. MCP server where used: "mcp": {"servers": {"files": {"type": "local", "command": ["python3", "/home/me/files_server.py"], "codemode": false}}} (any stdio server with read(path) and write(path, content) tools).
- Shell:
[{"action": "read", "resource": "*", "effect": "allow"}, {"action": "read", "resource": "secret/*", "effect": "deny"}]. "Read /work/secret/a.txt with the read tool" -> "Permission denied: read". "Runcat /work/secret/a.txt" -> content returned.[{"action": "edit", "resource": "canary/*", "effect": "ask"}]. "Runprintf hi > /work/canary/a.txt" -> written.- No
permissions;/etc/opencode/opencode.jsonwith{"policies": [{"action": "tool.use", "resource": "read:secret/*", "effect": "deny"}]}. Read tool -> "Blocked by configuration policy";cat /work/secret/a.txt-> content returned.
- MCP and Code Mode:
[{"action": "read", "resource": "secret/a.txt", "effect": "deny"}]and the MCP server. Read tool -> "Permission denied: read". "Call files_read with path /work/secret/a.txt" -> content returned. Same under the managed policy from step 1 instead.[{"action": "external_directory", "resource": "*", "effect": "deny"}]. Read tool on /outside/a.txt -> "Permission denied: external_directory". "Call files_read with path /outside/a.txt" -> content returned.[{"action": "edit", "resource": "*", "effect": "allow"}, {"action": "edit", "resource": "canary/*", "effect": "deny"}], MCP server withoutcodemode: false. "Use execute to call tools.files.write({path: '/work/canary/b.txt', content: 'x'})" -> written.
- The rules from the first case of step 1.
opencode run --standalone --file /work/secret/a.txt "summarize"-> the file text is in the request sent to the model.
Screenshot
No response
Operating System
No response
Terminal
No response
- Vorherrschende Sprache
- TypeScript
- Sterne
- 230k
- Forks
- 31.3k
- Ø Merge
- 5 Std. 32 Min.
- Gemergte PRs (30 T.)
- 453
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus anomalyco/opencode
-
area/desktop platform/macos status/repro-plausible type/bug version/v2
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
anomalyco/opencode#67064 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 82/100
anomalyco/opencode#67009 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
area/web type/feature version/v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
anomalyco/opencode#67001 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
skills: a Claude-compatible SKILL.md that fails to parse is dropped without any logEvtl. vergeben @liwenjie200543 hat das vor 2 Tagen übernommen. Offenarea/plugins platform/linux reproduced type/bug version/v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
anomalyco/opencode#66970 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
tui: Mermaid renderer displays <b>/<strong> tags literally and ignores \n line breaksEvtl. vergeben @argszero hat das vor 2 Tagen übernommen. Offenarea/tui platform/wsl status/repro-simulated type/bug version/v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
anomalyco/opencode#66773 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in anomalyco/opencode
Ähnliche Issues
-
enhancement feature/signals self-driving team/self-driving
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
PostHog/posthog#144208 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug good first issue web
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
triage: not actionable
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
oxc-project/oxc#30518 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug Claude useability
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
wazuh/wazuh-dashboard-plugins#9751 ·
Maintainer antworten meist innerhalb von 1 Tag