字符串命令接口在接收不可信输入时可能造成 sandbox 内命令注入
原文依据:2 处该 Skill 将 `sandbox.exec(command)` 定义为执行完整命令字符串,并展示了 shell 风格命令,但没有同时要求隔离、拒绝或安全编码用户可控参数。
如果使用者生成的代码把请求参数、聊天内容、文件名或其他不可信文本拼入命令字符串,攻击者可能在隔离容器内执行额外命令,读取或修改其中的文件,并利用该容器获准的网络访问。现有证据不表明命令会逃逸到宿主机。
源码确认 `exec` 接收命令字符串,并给出一个固定字符串示例;但没有指示把用户输入拼接进命令,也没有展示任何不可信数据流。因此,仅凭该接口形式不足以认定存在命令注入风险。只有应用后来将未验证的用户输入插入该字符串时,攻击者才可能在 sandbox 内执行额外命令。用户可要求作者说明所有命令参数的来源,并限制为固定命令或经过严格校验的参数。
这项判断针对展示的代码和适用条件,不表示风险已经实际发生。- `await sandbox.exec(command)` takes a **command string** and resolves when the command **finishes**, with buffered `stdout` / `stderr` / `exitCode` (and related fields).- Long-running and streaming work use the **stable** command APIs (`startProcess`, `execStream`, and related helpers)—not the `@next` single-handle model. Open the Commands docs; do not invent `@next` `output()` handles on stable.- **Sessions** can preserve working directory and environment across commands (default session / `enableDefaultSession`, `createSession`). See Sessions docs when state must carry across calls.查看另外 1 个位置
const sandbox = getSandbox(env.Sandbox, "user-123");const result = await sandbox.exec('python3 -c "print(2 + 2)"');// result.stdout, result.exitCode, result.success```