read/edit rules and managed file policies are skipped by the shell, MCP/plugin tools and --file
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 48/100
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- TypeScript
- Étoiles
- 230k
- Forks
- 31.3k
- Merge moyen
- 5 h 32 min
- PR mergées (30 j)
- 453
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de anomalyco/opencode
-
area/desktop platform/macos status/repro-plausible type/bug version/v2
Difficulté 1/5 1-3 heures Accessibilité débutants 88/100
anomalyco/opencode#67064 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 Une demi-journée Accessibilité débutants 82/100
anomalyco/opencode#67009 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
area/web type/feature version/v2
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
anomalyco/opencode#67001 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
skills: a Claude-compatible SKILL.md that fails to parse is dropped without any logPeut-être pris @liwenjie200543 l’a pris il y a 2 jours. Ouvertearea/plugins platform/linux reproduced type/bug version/v2
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
anomalyco/opencode#66970 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
tui: Mermaid renderer displays <b>/<strong> tags literally and ignores \n line breaksPeut-être pris @argszero l’a pris il y a 2 jours. Ouvertearea/tui platform/wsl status/repro-simulated type/bug version/v2
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
anomalyco/opencode#66773 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de anomalyco/opencode
Issues similaires
-
enhancement feature/signals self-driving team/self-driving
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
PostHog/posthog#144208 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
bug good first issue web
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
triage: not actionable
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
oxc-project/oxc#30518 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
bug Claude useability
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
wazuh/wazuh-dashboard-plugins#9751 ·
Les mainteneurs répondent en général sous 1 jour