read/edit rules and managed file policies are skipped by the shell, MCP/plugin tools and --file
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- TypeScript
- 星标
- 230k
- 派生
- 31.3k
- 平均合并
- 5 小时 32 分钟
- 30 天内合并 PR
- 453
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
anomalyco/opencode 的其他 Issue
-
area/desktop platform/macos status/repro-plausible type/bug version/v2
难度 1/5 1-3 小时 新手友好度 88/100
anomalyco/opencode#67064 · 4 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 82/100
anomalyco/opencode#67009 · 2 条评论 ·
维护者通常 1 天内回复
-
area/web type/feature version/v2
难度 2/5 1-3 小时 新手友好度 78/100
anomalyco/opencode#67001 · 3 条评论 ·
维护者通常 1 天内回复
-
skills: a Claude-compatible SKILL.md that fails to parse is dropped without any log可能已有人在做 @liwenjie200543 于 2 天前认领。 未关闭area/plugins platform/linux reproduced type/bug version/v2
难度 2/5 1-3 小时 新手友好度 72/100
anomalyco/opencode#66970 · 4 条评论 ·
维护者通常 1 天内回复
-
tui: Mermaid renderer displays <b>/<strong> tags literally and ignores \n line breaks可能已有人在做 @argszero 于 2 天前认领。 未关闭area/tui platform/wsl status/repro-simulated type/bug version/v2
难度 2/5 1-3 小时 新手友好度 82/100
anomalyco/opencode#66773 · 4 条评论 ·
维护者通常 1 天内回复
查看 anomalyco/opencode 的全部 Issue
相似的 Issue
-
enhancement feature/signals self-driving team/self-driving
难度 2/5 1-3 小时 新手友好度 78/100
PostHog/posthog#144208 · 1 条评论 ·
维护者通常 1 天内回复
-
bug good first issue web
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
triage: not actionable
难度 2/5 1-3 小时 新手友好度 66/100
oxc-project/oxc#30518 · 1 条评论 ·
维护者通常 1 天内回复
-
bug Claude useability
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 70/100
wazuh/wazuh-dashboard-plugins#9751 ·
维护者通常 1 天内回复