docs: explain how to opt in to allowing the system temp directory#1339
Merged
Conversation
Add a collapsible section to the README (and zh mirror) describing how to allow reads/writes under the system temp directory via permission config, instead of enabling it by default. Documents the security risk, why /tmp comes up (models commonly use it as scratch space), and the macOS caveat that /tmp symlinks to /private/tmp and os.tmpdir() resolves under /var/folders, since permission patterns match the literal path. Co-authored-by: MiMo-Code <noreply@mimo.xiaomi.com>
Make the risk disclaimer explicit: the setting has known risks and is used at the user's own risk; recommend it only for single-user controlled environments or inside a container; the user is responsible for the configuration and for any problem arising from temp-dir reads/writes. Co-authored-by: MiMo-Code <noreply@mimo.xiaomi.com>
Permission checks match the literal path with no symlink resolution, so a model writing /tmp/... is matched against /tmp/** directly — the macOS /private/tmp and os.tmpdir() forms are not seen by the permission layer. Drop them from the default example and remove the macOS note. Also keep the "at your own risk" statement to a single mention in the opening bold sentence rather than repeating it in the body. Co-authored-by: MiMo-Code <noreply@mimo.xiaomi.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Documents how a user can opt in to allowing reads/writes under the system temp directory (
/tmp), instead of enabling it by default. No code or default-behavior changes — this is README-only (a collapsible<details>block under Configuration, mirrored inREADME.zh.md).中文:说明用户如何主动放行系统临时目录
/tmp的读写,而非默认开启。不改任何代码或默认行为,仅在 README 的 Configuration 章节加一个可折叠<details>小节,并同步中文版。Background — why this supersedes #1335
The earlier #1335 (closed) auto-allowed
/tmpby default by injecting temp-dir globs intowhitelistedDirs. Review consensus: we should not silently widen the permission posture out of the box. The permission layer is deliberately a backstop, and external-directory access is opt-in by design — changing that default for everyone is the wrong trade for a convenience win.So the direction flipped: keep the default exactly as-is (temp-dir access still prompts via
external_directory), and instead teach the user how to opt in if they decide it's worth it in their environment. The guidance lives in the README rather than the docs site (packages/web/.../permissions.mdx) because the mdx docs are largely unmaintained and the README is where users actually look.中文:此 PR 替代已关闭的 #1335。#1335 默认放行 /tmp,review 共识是不应开箱即静默放宽权限——权限层有意作为 backstop,外部目录访问按设计就是 opt-in。因此方向反转:默认完全不变(临时目录仍会询问),改为用文档引导用户在自己认为合适时主动开启。引导放在 README 而非 mdx 文档站,因为 mdx 基本不再维护,README 才是用户实际查看处。
What the doc explains
external_directory, temp dir included. MiMoCode does not silently widen permissions./tmpis singled out. Most models reach for the temp dir as scratch space (quick scripts, throwaway data), so it's the external directory users most often want to allow. This matches common model behavior.{ "permission": { "external_directory": { "/tmp/**": "allow" } } }中文:文档说明了——默认行为不变且有意为之;为何单独提 /tmp(多数模型把它当临时空间,符合常见模型行为);最小化的 opt-in 配置;已知风险与免责声明(临时目录共享可写,自动放行扩大攻击面,"风险自负",仅建议单人可控环境或容器内使用)。
Why
/tmp/**alone is sufficient (verified, not assumed)A natural worry on macOS:
/tmpis a symlink to/private/tmp, andos.tmpdir()resolves to/var/folders/.../T— so would a rule keyed on/tmp/**miss the real path? I traced the actual write/read path to confirm it does not:tool/write.ts:36-39— the incomingfile_pathis only checked forpath.isAbsolute/ joined with the session cwd. Norealpath/ symlink resolution. A model writing/tmp/foo.pykeeps the literal string/tmp/foo.py.tool/external-directory.ts:29— on non-Windows,full = target(the literal path), andInstance.containsPath(full)decides "outside the worktree."project/instance.ts:121-125—containsPathusesAppFileSystem.contains, a plain string-prefix comparison. No realpath.external_directoryask then evaluatespath.dirname(full) + "/*", i.e./tmp/*, against the rule.util/wildcard.tscompiles*→.*with the dotallsflag, so a single*crosses/and/tmp/**matches arbitrarily deep paths.Conclusion: the permission layer sees the literal
/tmp/...string the model passed, before the filesystem resolves the symlink. The/private/tmpand/var/folders/...forms only arise when a tool itself passes an already-resolved path (e.g. something that callsos.tmpdir()directly), which is the uncommon case. Putting those forms in the default example would be misleading, so the doc uses just/tmp/**(which is also exactlyos.tmpdir()on Linux) and omits a macOS caveat to avoid noise.中文:在 macOS 上
/tmp是指向/private/tmp的软链、os.tmpdir()解析为/var/folders/.../T,自然会担心/tmp/**是否会漏掉真实路径。我实地追踪了写/读链路确认不会:工具拿到的路径不做 realpath(write.ts:36-39),external-directory 用字面路径(:29)和纯字符串前缀比较(instance.ts:121-125),且*在 dotall 下可跨/(wildcard.ts)。因此权限层看到的是模型传入的字面/tmp/...,发生在文件系统解析软链之前。/private/tmp、/var/folders/...只在工具自身传入已解析路径(如直接调用os.tmpdir())的少数情况出现。把这些写进默认示例反而误导,故默认只用/tmp/**(Linux 上也正是os.tmpdir()),并省去 macOS 注意事项以免增加噪音。Scope
README.md+README.zh.mdonly. No code, no default-permission change, no new dependency.Supersedes #1335 (closed).
Co-authored-by: MiMo-Code noreply@mimo.xiaomi.com