黄奕彬

外部精选

Sandboxing

本文来自外部来源,不是黄奕彬的原创文章。本站提供原文入口,并在采集端生成 AI 结构化摘要、解读与中文翻译(如有),一切以原文为准。

阅读原文(zed.dev)
来源
Zed Blog ↗
作者 / 署名
Cameron Mcloughlin、Cameron Mcloughlin
发布日期
本站收录时间
原文域名
zed.dev

以上时间均为北京时间;来源更新时间由来源提供,不代表首次发布时间。

结构化摘要 AI 生成

背景与问题

面向在 Zed 编辑器 agent panel 中使用 AI agent 的开发者。

  • 核心矛盾:手动逐条审批 agent 动作繁琐且牺牲自动化;"YOLO mode" 全放开则 agent 可能在本机或网络可达的机器上大肆破坏。
  • 根源:agent 无法被信任判断动作是否符合用户意愿,作者明确表示尚未解决这一难题。
  • 指令约束不可靠:现代 LLM 大体听指令但无保证,且几乎防不了 prompt injection(如 PR 中被篡改的 AGENTS.md 指示 agent 上传 $MY_SECRET_API_KEY 到攻击者服务器)。

方法或内容

  • Zed 自 1.14 发布起为所有用户默认启用 agent panel 沙箱。
  • 终端与 fetch 工具默认受限:禁止写项目目录之外、禁止写 .git、禁止发起网络请求。
  • agent 可请求临时提权,用户可见所申请的权限及理由;.git 写权限永不允许(防 agent 写出在沙箱外运行的 hooks)。
  • 实现基于操作系统 API:macOS 用 Seatbelt,Linux 用 namespaces(经 Bubblewrap),Windows 用 WSL;非 WSL 的 Windows shell 不支持沙箱。
  • 文章同时论证细粒度规则为何不足,并披露已修复的 "symlink swap" TOCTOU 攻击。

关键发现 / 结果

  • Linux 用户需 $PATH 中有无 setuid 位的可用 bwrap;WSL 用户需在 WSL 环境内满足同样条件。
  • 细粒度规则(如禁 git .*)可被 bash -c 'git ...'、EVIL_CMD="git ..." bash -c $EVIL_CMD、写可执行脚本等方式绕过;对齐良好的 agent 只是指引,遇到稍有水平的攻击者即刻失效。
  • symlink swap 攻击:利用用户点击允许与路径传给 bwrap 之间的时间窗(通常几百微秒),将 /foo/bar 换成指向 /home/alice 的符号链接,配合 --bind /foo/bar /foo/bar 即可写入 authorized_keys;Zed 沙箱已捕获该攻击并 fail-closed(不执行不受信命令)。
  • 沙箱不覆盖:edit 工具、经 ACP 连接的 agent、LSP/MCP 服务器、常规内置终端、外部程序(如 ghostty、VSCode)。
  • create_directory 工具参与权限流程,未授权时可能临时创建目录但会清理。
  • 其余量化数据原文未说明。

结论与意义

  • 沙箱是纵深防御中的一层,显著限制 agent 对机器的行为,但不解决"判断用户是否想要某动作"的难题。
  • 覆盖边界明确:仅限 agent panel 的 terminal 与 fetch 工具;诱导用户在沙箱外执行代码的路径几乎无穷(build.rs + cargo run、改 .bashrc、恶意 procedural macro 经 rust-analyzer 构建、Git submodule hook 配合常规终端 git commit)。
  • 安全前提是沙箱实现无 bug(脚注 2),且沙箱中单个 bug 即可危及用户安全。

AI 解读 AI 生成

方法:按「时空变量」分析(时间 / 空间 / 变量,严格区分包含、相关与因果),对象包括原文作者、署名人员与关键技术及其实际原理;结论用「元反空」(元思考、反思考、空思考、综合)整理。

时间:何时发生,现在是否仍成立

  • 来源日期为 2026-08-05 08:00(北京时间,Asia/Shanghai);沙箱自 Zed 1.14 发布起默认启用。
  • 内容描述的是该发布时点的行为;按来源日期属新近发布,在 1.14 及紧随其后的版本上仍可能成立。
  • 后续版本是否调整默认规则、平台支持或修复新攻击面,原文未说明。

空间:谁的环境 / 场景

  • 适用对象:Zed 编辑器(1.14 起)agent panel 用户,所有用户默认启用。
  • 平台差异:macOS(Seatbelt);Linux(Bubblewrap/bwrap,需无 setuid 位且在 $PATH);Windows 仅 WSL 环境(WSL 内同样需 bwrap);非 WSL 的 Windows shell 无沙箱。
  • 场景边界:仅约束 agent panel 的 terminal 与 fetch 工具(create_directory 参与权限流程);不覆盖 edit 工具、ACP agent、LSP/MCP 服务器、内置终端及外部程序。

变量:实际改变了什么

  • 行为变更:1.14 起所有用户默认启用沙箱(此前是否有可选沙箱原文未说明;terminal 的细粒度规则此前已存在)。
  • 新增三条默认限制:禁写项目目录之外、禁写 .git、禁网络请求。
  • 新增交互:agent 临时提权须展示权限项与理由;.git 写权限不可申请。
  • 新增环境依赖:Linux/WSL 用户需可用的无 setuid 位 bwrap。
  • 价格、数据、结构等其他变更原文未说明。

区分:包含 ≠ 相关 ≠ 因果

  • 有明确机制/因果证据的:指令约束防不了 prompt injection(AGENTS.md 例子);禁 git .* 的规则可经 bash -c 等具体命令绕过;symlink swap 借 TOCTOU 时间窗把只读目录变成可写(有逐步推演的机制);Zed 沙箱捕获该攻击并 fail-closed(作者陈述,未附技术细节)。
  • 仅是覆盖/范围关系而非因果的:沙箱"覆盖"terminal 与 fetch、"不覆盖" edit/ACP/LSP/MCP/内置终端/外部程序——这是边界陈述,不是因果结论。
  • 无证据断言:"prompt injection 攻击已发生且会更常见"为作者断言,本文未给案例细节;"沙箱安全"以实现无 bug 为前提(脚注 2),未提供审计证据。

对象:作者/署名与关键技术原理

  • 署名:Cameron Mcloughlin(结构化作者字段列出两次,均为该名)。
  • 关键技术与原理(按原文描述):
  1. OS 级沙箱:限制由操作系统强制执行,不依赖 agent 遵守指令。
  2. macOS 用 Seatbelt;Linux 用 namespaces(内核原语,为程序提供对文件系统、设备、用户等的模拟视图),经 Bubblewrap 的 bwrap 实现,如 bwrap --ro-bind / / -- echo hello 创建 namespace 并只读挂载 /。
  3. Zed 通过构造 --bind/--ro-bind 参数授予沙箱内特定目录访问。
  4. Windows 经 WSL 实现,非 WSL shell 不支持。
  5. TOCTOU(time-of-check-time-of-use):symlink swap 攻击的成因。
  6. 脚注解释:build.rs 是 Rust 项目中编译前运行的文件;procedural macro 是操作 Rust 源码的程序(如 #[derive(Serialize)]),可不纯甚至 fork 编译器。

元反空综合结论

  • 元:本质在解决"不可信 agent 在用户机器上执行命令"的约束问题——指令不可靠(prompt injection)、规则可绕过(shell 变体),OS 强制隔离是原文给出的当前最佳答案。
  • 反:最可能失效或有边界的主张——(1) 沙箱仅覆盖 terminal/fetch,其余攻击面(edit、ACP、LSP/MCP、内置终端、外部程序)不设防,且诱导沙箱外执行的路径"几乎无穷"(build.rs、.bashrc、procedural macro、git hook);(2) 安全性以实现无 bug 为前提,而沙箱单个 bug 即安全事故,symlink swap 已证明此类 bug 的现实性;(3) "攻击会更常见"是趋势预测而非已证事实。
  • 空:去掉叙事后剩余的必要事实——Zed 1.14 起 agent panel 的 terminal/fetch 默认受 OS 沙箱约束(三条默认禁令 + 提权审批 + .git 永不可写),平台实现为 Seatbelt/Bubblewrap/WSL,已知 TOCTOU 已修复并 fail-closed。
  • 综合:这是一次有明确边界的真实安全改进,适合作为纵深防御的一层,而非完整防护方案;用户仍须警惕沙箱外的执行路径。

中文译文 AI 生成

Zed 现在支持在 agent 面板内进行沙箱化。

沙箱会限制 agent 在使用终端和 fetch 工具时能够执行的操作。这些限制由操作系统强制执行,并不依赖 agent 去遵循指令。

从 1.14 版本开始,沙箱已对所有用户默认启用。

为什么要沙箱化?

一些用户更喜欢严格控制 agent 被允许做什么,而另一些用户则选择 “YOLO mode”,让 agent 在他们的计算机上为所欲为。

两种做法各有利弊。手动批准/拒绝 agent 的每一个动作可能变得繁琐,并且牺牲了 agent 所提供的部分自动化。另一方面,处于 YOLO mode 的 agent 可能在你的机器(或你在网络上能够访问到的任何机器)上大肆破坏。

这种张力源于一个事实:无法信任 agent 去判断某个动作是否是用户想要的。你可能会失望地得知,我们并不是在宣布已经解决了这个著名的难题。在那之前,沙箱是约束 agent 行为的最佳方式。

Zed 中的沙箱化

在 Zed 中,agent 面板的终端和 fetch 工具¹现在默认处于沙箱中。默认的沙箱规则禁止 agent 在项目目录之外写入、写入 .git,或发起网络请求。

对许多交互来说,这已经绰绰有余。但当它不够时,agent 可以请求权限以临时提升自己的权限。用户将看到:

  • agent 正在请求哪些权限
  • 它们提出请求的原因

注意:agent 不得请求对 .git 的写权限,因为这会使 agent 能够写入在沙箱之外运行的 hooks。

实现

沙箱通过操作系统 API 实现:

  • macOS 使用 Seatbelt
  • Linux 使用 namespaces(通过 Bubblewrap)
  • Windows 使用 WSL
  • Windows 上的非 WSL shell 不支持沙箱

Linux 用户需要确保其 $PATH 中有一个可用的、未设置 setuid 位的 bwrap 二进制文件。WSL 用户需要确保在他们的 WSL 环境内部同样如此。

难道我不能直接告诉我的 agent 不要编辑某些文件吗?

可以,而且很多时候这样就足够了。现代 LLM 相当擅长遵循指令,但这并不能得到保证。指令对于防范 prompt injection 攻击也几乎起不到作用。

也许你在参与一个开源项目,正在审阅某位贡献者的 PR。你打开一个 agent 并问 “review this PR”。然而你并不知道,这个 PR 包含一个被篡改的 AGENTS.md,它指示你的 agent 将 $MY_SECRET_API_KEY 上传到攻击者控制的服务器。

这种事已经发生过,而且只会变得越来越常见。

沙箱的好处在于它们根本不允许访问某些资源²。

那么细粒度规则呢?

一段时间以来,Zed 已支持针对终端工具的细粒度规则。例如,你可以禁止任何匹配 git .* 的命令。既然我们可以发布一套实现相同限制的规则,为什么还要费心做沙箱化呢?

答案是:这根本不可能。一条禁止 git .* 的规则对真心想修改你 .git 文件夹的 agent 几乎起不到阻止作用。它可以:

  • bash -c 'git ...'
  • EVIL_CMD="git ..." bash -c $EVIL_CMD
  • echo 'git @$' > evil_git; chmod +x evil_git; evil_git ...
  • python ...
  • 列表还在继续……

细粒度规则在应对一个对齐良好的 agent 时能很好地充当指导方针。而面对哪怕只是稍微有点手段的攻击者,它们会立刻失效。

沙箱很难做对

沙箱在很多方面与其他软件特性类似,但在几个关键方面有所不同:

  • 单个 bug 就可能危及用户的安全。
  • 即使存在对手,也必须没有任何 bug。

这意味着你不能只是说“哦,这在实践中不会发生”。相反,你需要问:

  • 攻击者能让这种事发生吗?

符号链接交换

一个很好的例子是我一直称之为“符号链接交换”的攻击。请注意,Zed 的沙箱确实能捕获这种攻击并会 fail-closed,也就是说,不受信任的命令不会被执行。

一些背景:在 Linux 上,Zed 的沙箱使用 Bubblewrap 控制文件系统访问。这是一个名为 bwrap 的程序,它允许在一个 “namespace”³内运行命令。最简单的 bwrap 调用可能是:

bwrap --ro-bind / / -- echo hello

这条命令:

  • 创建一个新的 namespace
  • 将真实的 / 以只读方式挂载到 namespace 中的 /
  • 在该 namespace 内运行 echo hello

注意,若没有 --ro-bind / /,这条命令会失败,因为它将找不到 echo。

当 Zed 创建一个能访问特定目录的沙箱时,它会构造一组 --bind 或 --ro-bind 参数传给 bwrap。

符号链接交换攻击的流程如下:

  • 一个恶意 agent 被授予对 /foo 的写权限。
  • 随后它生成两个并行运行的子 agent:
  • 子 agent 1 反复尝试将攻击者的公钥写入 /foo/bar/.ssh/authorized_keys
  • 至关重要的是,它还请求对 /foo/bar 的写权限。用户很可能会同意,因为它已经拥有 /foo,所以看起来是安全的。
  • 子 agent 2 将 /foo/bar 替换为指向 /home/alice 的符号链接
  • 注意,即使沙箱只授予对 /home/alice 的读权限,这一步也可能成功
  • 最初,对 /foo/bar/.ssh/authorized_keys 的写入会失败,因为不存在这样的文件。
  • 然而,在第二个子 agent 的符号链接交换成功后,路径 /foo/bar/.ssh/authorized_keys 就指向了 /home/alice/.ssh/authorized_keys。
  • 但这仍会被沙箱阻止,因为从未授予过对 /home/alice 的写权限。

到目前为止,一切正常。但有一个陷阱!在以下两个时刻之间存在一个短暂的时间窗口:

  • 用户看到提示并点击 “allow” 的时刻
  • 该路径被传递给 bwrap 的时刻

如果符号链接交换发生在这一窗口内,那么:

  • 用户看到的是 /foo/bar 并予以批准
  • /foo/bar 变成了指向 /home/alice 的符号链接
  • Zed 将 --bind /foo/bar /foo/bar 传递给 bwrap

在沙盒内,/foo/bar 被挂载到真实的 /home/alice,并具有写权限。

此时,被沙盒化的程序可以写入 /foo/bar/.ssh/authorized_keys,它实际解析为 /home/alice/.ssh/authorized_keys。攻击者的公钥现在就被这台机器信任了!

这是一个经典的检查时与使用时(time-of-check-time-of-use, TOCTOU)漏洞。如果不加处理,它将允许恶意 agent 获得对其拥有读权限的任意目录的写权限。

在实践中,这个时间窗口极小——基本上只是生成一个子进程所需的时间——通常只有几百微秒。但这还不够好。攻击者可以反复尝试⁴,而且只需要成功一次。

沙盒到底有多安全?

沙盒只是纵深防御策略中的一层。

欲了解更多细节,请查阅我们关于这一主题的文档。

沙盒覆盖了 Zed agent 中的 terminal 和 fetch 工具,但当你使用以下内容时,它无法提供任何保护:

  • Zed agent 中的其他工具,比如 edit 工具。
  • 通过 ACP 连接的 agent
  • LSP 和 MCP 服务器
  • 常规的内置终端
  • 外部程序,比如 ghostty 或 VSCode

恶意 agent 也许无法在 Zed agent 的终端内执行 pwn_my_machine.sh,但如果它能诱骗你在沙盒之外运行它,它可能根本不需要这么做。

例如:

  • 它可以添加一个运行该脚本的 build.rs⁵ 文件。然后,当你在内置终端中运行 cargo run 时,就会在沙盒之外执行那个 build.rs。
  • 如果被授予写入 /home/alice 的权限,它可以编辑你的 .bashrc,让脚本在沙盒之外运行。
  • 它可以使用常规编辑工具修改你的项目,使其包含一个带有恶意过程宏⁶的 Rust crate,该宏会运行这个脚本。随后 rust-analyzer 会在沙盒之外构建并运行这个宏。
  • 如果你的项目包含 Git submodule,它可以安装一个在你提交时运行该脚本的 hook。如果你在常规终端应用中运行 git commit,那么这个 hook 就会在沙盒之外运行。

这份清单几乎无穷无尽。要堵住所有这些,仅靠沙盒本身是不够的。

总结

现在,Zed 的 agent 面板默认启用了沙盒。terminal 和 fetch 工具在操作系统强制施加的限制下运行:agent 不能写入你的项目目录之外的内容,不能触碰 .git,也不能访问网络,除非你授予访问权限。当 agent 需要更多权限时,它必须提出请求,并附上一个你可以评估的理由。

作为安全策略中的一层,它切实地限制了 agent 对你的机器所能做的事情。

脚注

create_directory 工具虽然并不严格处于“沙盒”之中,但它参与了沙盒权限流程。请注意,即使权限尚未被授予,create_directory 工具也可能临时创建所请求的目录,但如果权限未被授予,它会将其清理掉。 ↩

假设沙盒实现中没有漏洞。 ↩

Namespaces 是 Linux 内核提供的核心原语,是沙盒的底层支撑。它们允许创建一个上下文,用户可以在其中运行程序,该程序会获得一个模拟的 OS 环境(即它对文件系统、设备、用户等有着不同的视图)。 ↩

还存在一些可以扩大这个间隙的技术,这会让利用变得更容易。 ↩

build.rs 是 Rust 项目中的一个特殊文件,它会在编译你的程序或库之前运行代码。 ↩

过程宏(procedural macro)是 Rust 的另一个特性,允许编写操纵 Rust 源代码的程序(例如,#[derive(Serialize)] 就是一个过程宏)。虽然它们通常是纯函数,但并不要求如此,甚至可以做一些相当离谱的事情,比如 fork 编译器! ↩

相关文章查看 Zed 团队的类似博客。

在找更好的编辑器?你今天就可以在 macOS、Windows 或 Linux 上试用 Zed。立即下载!

我们正在招聘!如果你对我们博客所涉及的主题充满热情,请考虑加入我们的团队,帮助我们交付软件开发的未来。

展开原文提取正文(采集端自动提取,可能有缺失)

Zed now supports sandboxing within the agent panel. Sandboxing restricts what the agent is able to do when using the terminal and fetch tools. These restrictions are enforced by the operating system and do not rely on an agent following instructions. Sandboxing is enabled by default for all users, starting on the 1.14 release. Why sandboxing? Some users prefer to tightly control what the agent is allowed to do, while others opt for "YOLO mode" and give agents freedom to do anything and everything on their computer. There are advantages and downsides to both approaches. Manually approving/denying each action the agent takes can get tedious, and sacrifices some of the automation which agents provide. On the other hand, an agent in YOLO mode can wreak havoc on your machine (or any machines you can reach over the network). The tension comes from the fact that agents cannot be trusted to determine whether an action is something the user would want. You may be disappointed to learn that we are not announcing that we have solved this famously hard problem. Until we do, sandboxing is the best way to constrain an agent's behavior. Sandboxing in Zed In Zed, the agent panel's terminal and fetch tools1 are now sandboxed by default. The default sandbox rules forbid an agent from writing outside the project directories, writing to .git, or making network requests. For many interactions, this is more than enough. But when it's not, agents can request permission to temporarily escalate their privileges. The user will see:

which privileges the agent is asking for a reason why they're asking for it

Note: The agent may not request write access to .git, since this allows an agent to write hooks that run outside the sandbox.

Implementation Sandboxes are implemented using operating system APIs:

macOS uses Seatbelt Linux uses namespaces (through Bubblewrap) Windows uses WSL

Non-WSL shells on Windows do not support sandboxing

Linux users will need to make sure they have a working bwrap binary without the setuid bit set in their $PATH. WSL users will need to make sure this is true inside their WSL environment. Can't I just tell my agent not to edit certain files? You can, and a lot of the time, that's sufficient. Modern LLMs are pretty good at following instructions, but it's not a guarantee. Instructions also do very little to protect against prompt injection attacks. Perhaps you work on an open source project, and you're reviewing a contributor's PR. You open an agent and ask "review this PR". Little do you know, however, that the PR contains a modified AGENTS.md that instructs your agent to upload $MY_SECRET_API_KEY to a server controlled by the attacker. This has already happened, and it's only going to get more common. The benefit of sandboxes is that they simply do not allow access to certain resources2. But what about fine-grained rules? Zed has supported fine-grained rules for the terminal tool for a while. You can, for example, disallow any command that matches git .*. Why bother with sandboxing when we could ship a set of rules that achieves the same restrictions? The answer is that it's simply not possible. A rule that bans git .* does very little to prevent an agent that really wants to modify your .git folder. It can:

bash -c 'git ...' EVIL_CMD="git ..." bash -c $EVIL_CMD echo 'git @$' > evil_git; chmod +x evil_git; evil_git ... python ... the list goes on...

Fine-grained rules work well as a guideline when dealing with a well-aligned agent. They fall over instantly in the presence of an even vaguely sophisticated attacker. Sandboxes are tricky to get right Sandboxes are similar to other software features in many respects, but differ in a couple of key ways:

A single bug may compromise a user's security. There must be no bugs even in the presence of adversaries.

This means that you can't just say "Oh, this won't happen in practice". Instead, you need to ask:

Could an attacker make this happen?

Symlink swaps A good example of this is what I've been calling the "symlink swap" attack. Note that Zed's sandbox does catch this attack and will fail-closed, meaning that the untrusted command will not be run. Some background: on Linux, Zed's sandbox controls filesystem access using Bubblewrap. This is a program called bwrap which allows running a command within a "namespace"3. The simplest bwrap invocation might be: bwrap --ro-bind / / -- echo hello This command:

creates a new namespace mounts the real / into the namespace at /, read-only runs echo hello within the namespace

Note that, without --ro-bind / /, this command would fail, since it wouldn't be able to find echo. When Zed creates a sandbox with access to specific directories, it constructs a set of --bind or --ro-bind arguments to pass to bwrap. The flow for the symlink swap attack goes like this:

A malicious agent is given write access to /foo. It then spawns two subagents which run in parallel:

Subagent 1 repeatedly tries to write the attacker's public key to /foo/bar/.ssh/authorized_keys

Critically, it also requests write access to /foo/bar. A user is likely to grant this, since it already has /foo, so it seems safe.

Subagent 2 replaces /foo/bar with a symlink to /home/alice

Note that this can succeed even if the sandbox only grants read access to /home/alice

Initially, the writes to /foo/bar/.ssh/authorized_keys fail, since there's no such file. However, after the second subagent's symlink swap succeeds, the path /foo/bar/.ssh/authorized_keys points to /home/alice/.ssh/authorized_keys. But this is still blocked by the sandbox, since write access to /home/alice was never granted.

So far, so good. But there's a catch! There's a small timing window between:

the time when the user is shown the prompt and clicks "allow" the time when the path is given to bwrap

If the symlink swap happens in that window, then:

the user sees /foo/bar and approves /foo/bar becomes a symlink to /home/alice Zed passes --bind /foo/bar /foo/bar to bwrap Within the sandbox, /foo/bar is mounted to the real /home/alice, with write access.

At this point, the sandboxed program can write to /foo/bar/.ssh/authorized_keys, which resolves to /home/alice/.ssh/authorized_keys. The attacker's public key is now trusted by the machine! This is a classic time-of-check-time-of-use (TOCTOU) bug. Left unaddressed, it would allow a malicious agent to gain write access to any directory it has read access to. In practice, the timing window is incredibly small - it's essentially just the time it takes to spawn a subprocess - usually a few hundred microseconds. But that's not good enough. Attackers can repeatedly try4, and they only need to succeed once. How safe is the sandbox? Sandboxes are just one layer in a defense in depth strategy. For more detail, check out our docs on this topic. The sandbox covers the terminal and fetch tools in Zed's agent, but it does nothing to protect you when you use:

Other tools in the Zed agent like the edit tool. Agents connected over ACP LSP and MCP servers The regular built-in terminal External programs like ghostty or VSCode

A malicious agent may not be able to execute pwn_my_machine.sh from within the Zed agent's terminal, but it might not need to, if it can trick you into running it outside the sandbox. For example:

It could add a build.rs5 file that runs the script. Then, when you run cargo run in the built-in terminal, it executes that build.rs outside the sandbox. If given access to write to /home/alice, it could edit your .bashrc to run the script outside the sandbox. It could edit your project using regular editing tools to contain a Rust crate with a malicious procedural macro6 that runs the script. rust-analyzer will then build and run this macro outside the sandbox. If your project contains a Git submodule, it could install a hook that runs the script when you commit. If you run git commit from a regular terminal app, then the hook would run outside the sandbox.

The list is almost endless. Closing everything requires more than what sandboxing alone can provide. Wrapping up Sandboxing is now enabled by default in Zed's agent panel. The terminal and fetch tools run with restrictions enforced by the operating system: agents can't write outside your project directories, can't touch .git, and can't reach the network unless you grant access. When an agent needs more, it has to ask, with a reason you can evaluate. As one layer in a security strategy, it meaningfully limits what an agent can do to your machine. Footnotes

The create_directory tool, while not strictly "sandboxed", participates in the sandboxing permissions flow. Note that, even when permission has not been granted, the create_directory tool may temporarily create the requested directory, but will clean it up if permission is not granted. ↩

Assuming no bugs in the sandbox implementation. ↩

Namespaces are the core primitive provided by the Linux kernel that underpin sandboxes. They allow creating a context in which a user can run a program where it gets a simulated OS environment (i.e. it has a different view of the filesystem, devices, users, etc.). ↩

There are also techniques that can widen this gap, which makes it even easier to exploit. ↩

A build.rs is a special file in a Rust project that runs code before compiling your programor library. ↩

A procedural macro is another Rust feature that allows writing a program that manipulates Rust source code (for example, #[derive(Serialize)] is a procedural macro). While they are typically pure functions, they are not required to be, and can even do some pretty cursed things like forking the compiler! ↩

Related PostsCheck out similar blogs from the Zed team.Looking for a better editor? You can try Zed today on macOS, Windows, or Linux. Download now!We are hiring! If you're passionate about the topics we cover on our blog, please consider joining our team to help us ship the future of software development.

原文入口

阅读原文(zed.dev)

原文将在新窗口打开。收录时间不是内容更新时间;正文、译文与解读的版权归原作者/来源所有,本站仅作个人阅读辅助并保留原文入口;页面时间均为北京时间。

作者/署名来自原文结构化字段(Atom/RSS/HTML meta/JSON-LD;GitHub release 显示的是发布者账号),未经模型补充。

了解来源批准与收录规则