docker-sandboxes-network-credentials
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDocker Sandboxes: Network Policy & Credentials
Docker Sandboxes:网络策略与凭据
Overview
概述
This skill owns (network egress) and (service
secrets and registry credentials). The proxy enforces egress policy and
injects stored credentials on matching domains. Proxy-managed sentinels are
not usable upstream credentials, but OAuth passthrough can expose real
tokens to the sandbox. Egress policy does not protect a real credential
once leaked outside the sandbox; revoke or rotate a leaked credential.
sbx policysbx secret本技能涵盖 (网络出站)和 (服务密钥和注册表凭据)。代理强制实施出站策略,并在匹配的域上注入已存储的凭据。代理管理的哨兵(sentinel)值不能直接作为上游凭据使用,但 OAuth 透传可能会将真实令牌暴露给沙箱。出站策略无法在真实凭据泄露到沙箱之外后保护它;泄露的凭据应被撤销或轮换。
sbx policysbx secretWhen to use this skill
何时使用此技能
Activate this skill when:
- The user wants to allow, deny, or inspect which hosts a sandbox (or all sandboxes) can reach.
- The user wants to give an agent an API key, OAuth token, or other service credential without exposing the raw value inside the sandbox.
- The user wants to pull a private template image or kit from a registry that requires authentication.
- The user is debugging a blocked network request or a credential that isn't being injected.
在以下情况下激活此技能:
- 用户想要允许、拒绝或检查某个沙箱(或所有沙箱)可以访问哪些主机。
- 用户想要给Agent一个 API 密钥、OAuth 令牌或其他服务凭据,但不想在沙箱内暴露原始值。
- 用户想要从需要身份验证的注册表拉取私有模板镜像或工具包(kit)。
- 用户正在调试被阻止的网络请求或未被注入的凭据。
Do not use this skill when
何时不使用此技能
Do not use this skill when:
- The task is running or managing its
docker agent run --sandboxallowlist — usedocker agent sandbox. If the CLI is unclear, establish whether the user runs Docker Agent or standalonedocker-agent-runbefore choosing commands.sbx - The task is creating, reattaching to, or removing a sandbox itself — use
.
docker-sandboxes-lifecycle - The task is declaring secrets/registries/bindings inside a checked-in
file — use
sbxenv.yamlfor the file format (this skill's rules on precedence and injection scope still apply to what that file provisions).docker-sandboxes-env - The task is declaring a kit's own /
credentials:block in apermissions.network:— usespec.yamlfor the schema (this skill's model of what those declarations mean at runtime still applies).docker-sandboxes-kits
在以下情况下不要使用此技能:
- 任务是运行 或管理其
docker agent run --sandbox允许列表 —— 请使用docker agent sandbox。如果 CLI 不明确,请先确认用户运行的是 Docker Agent 还是独立的docker-agent-run,再选择命令。sbx - 任务是创建、重新附加或移除沙箱本身 —— 请使用 。
docker-sandboxes-lifecycle - 任务是在已检入的 文件中声明密钥/注册表/绑定 —— 请使用
sbxenv.yaml了解文件格式(本技能关于优先级和注入范围的规则仍然适用于该文件所配置的内容)。docker-sandboxes-env - 任务是在 中声明工具包自身的
spec.yaml/credentials:块 —— 请使用permissions.network:了解模式(本技能关于这些声明在运行时含义的模型仍然适用)。docker-sandboxes-kits
Core guidance
核心指导
Network policy: global, per-sandbox, and precedence
网络策略:全局、每个沙箱及优先级
- The global network policy must be initialized once before creating the
first sandbox: .
sbx policy init <allow-all|balanced|deny-all>is the recommended starting point (typical dev traffic — AI services, package registries — allowed). This is a one-time setup.balanced - is destructive: it deletes the entire local policy store and stops the daemon and every currently running sandbox. The daemon restarts on the next daemon-backed command. It is not a lightweight way to "start over" or a routine diagnostic step — never propose it as a first troubleshooting move for a single misbehaving rule. Use targeted
sbx policy reset(bysbx policy rm networkor--id) to remove one rule instead; reserve--resourcefor when the policy store itself needs to be rebuilt from scratch, and warn the user that it will stop running sandboxes before running it.sbx policy reset - Add rules with /
sbx policy allow network RESOURCES.sbx policy deny network RESOURCESis a comma-separated list of exact hosts,RESOURCESsingle-label wildcards,*.example.commulti-label wildcards, optional**.example.comsuffixes, CIDR prefixes, or:portfor "all hosts".**bashsbx policy init balanced sbx policy allow network "api.example.com,cdn.example.com" sbx policy deny network ads.example.com - Deny always wins over allow for the same hostname/CIDR when both match. An allowed hostname is not checked against CIDR deny rules for its resolved IP.
- A rule applies globally by default. Pass to scope it to one sandbox's local policy instead:
--sandbox NAMEbashsbx policy allow network --sandbox my-sandbox api.example.com - At creation time only, /
sbx createacceptsbx run(repeatable) to add a per-sandbox deny rule. This is safe to expose even under centralized (org) governance because a local deny can only narrow, never widen, egress — it can never override an org-level allow into a broader grant.--deny-network RESOURCE - Use to test what the current policy would do for a host/URL before it matters, and
sbx policy check network [--sandbox NAME] TARGETto see what was actually allowed or blocked historically, with the matching rule.sbx policy log [SANDBOX]bashsbx policy check network --sandbox my-sandbox api.example.com:443 sbx policy log my-sandbox --json - lists active policies/rules;
sbx policy ls [SANDBOX] [--wide]adds rule IDs (needed for--wide) and per-resource status.sbx policy rm network --idgives full detail including each rule's exact removal command or the reason it is read-only (e.g. org-managed). To remove a sandbox-scoped rule, retainsbx policy inspect <policy-or-rule>; omitting it targets the global policy instead:--sandbox NAMERemoving one rule does not determine the final decision; other matching rules still apply.bashsbx policy rm network --sandbox my-sandbox --resource api.example.com sbx policy check network --sandbox my-sandbox api.example.com
- 在创建第一个沙箱之前,必须先初始化一次全局网络策略:。推荐从
sbx policy init <allow-all|balanced|deny-all>开始(允许典型的开发流量——AI 服务、软件包注册表)。这是一次性设置。balanced - 具有破坏性:它会删除整个本地策略存储,并停止守护进程和所有当前正在运行的沙箱。 守护进程会在下一个由守护进程支持的命令时重新启动。它不是一种轻量级的“重新开始”方式,也不是常规的诊断步骤——切勿将其作为单个规则行为异常时的首选故障排查手段。请使用有针对性的
sbx policy reset(通过sbx policy rm network或--id)来删除单个规则;只有在策略存储本身需要从头重建时才使用--resource,并在运行之前警告用户它将停止正在运行的沙箱。sbx policy reset - 使用 /
sbx policy allow network RESOURCES添加规则。sbx policy deny network RESOURCES是以逗号分隔的列表,包含精确主机、RESOURCES单标签通配符、*.example.com多标签通配符、可选的**.example.com后缀、CIDR 前缀,或用于表示“所有主机”的:port。**bashsbx policy init balanced sbx policy allow network "api.example.com,cdn.example.com" sbx policy deny network ads.example.com - 当主机名/CIDR 同时匹配时,deny 始终优先于 allow。一个被允许的主机名不会被检查其解析出的 IP 是否匹配 CIDR deny 规则。
- 默认情况下,规则是全局生效的。传入 可将其限定到单个沙箱的本地策略:
--sandbox NAMEbashsbx policy allow network --sandbox my-sandbox api.example.com - 仅在创建时,/
sbx create接受sbx run(可重复)来添加每沙箱的 deny 规则。即使在集中式(组织)治理下,这也是安全的,因为本地 deny 只会缩小出站范围,绝不会扩大——它永远不能覆盖组织级别的 allow 并使其变成更宽泛的授权。--deny-network RESOURCE - 使用 在实际影响发生前测试当前策略对某个主机/URL 会做什么;使用
sbx policy check network [--sandbox NAME] TARGET查看历史上实际被允许或阻止的内容以及匹配的规则。sbx policy log [SANDBOX]bashsbx policy check network --sandbox my-sandbox api.example.com:443 sbx policy log my-sandbox --json - 列出活动的策略/规则;
sbx policy ls [SANDBOX] [--wide]添加规则 ID(--wide需要)和每个资源的状态。sbx policy rm network --id提供完整详情,包括每条规则的确切删除命令或其为只读的原因(例如由组织管理)。要删除沙箱范围的规则,请保留sbx policy inspect <policy-or-rule>;省略它则针对全局策略:--sandbox NAME删除一条规则并不能确定最终决策;其他匹配的规则仍然适用。bashsbx policy rm network --sandbox my-sandbox --resource api.example.com sbx policy check network --sandbox my-sandbox api.example.com
Service secrets: how injection works
服务密钥:注入的工作方式
- stores a credential the proxy uses to authenticate outbound requests on behalf of the agent. In the normal proxy-managed flow, the sandbox sees a sentinel rather than the raw secret; the proxy substitutes the real value on requests to the domains the matching kit/binding declares.
sbx secret set [SERVICE]Storing a secret does not grant network access. Egress is governed separately bybashsbx secret set github # interactive printf '%s' "$ANTHROPIC_API_KEY" | sbx secret set anthropic; check the target domain in the intended scope before debugging authentication:sbx policybashsbx policy check network --sandbox my-sandbox api.anthropic.com - OAuth passthrough is an exception, not a no-secret-exposure guarantee.
When a kit sets without a refresh sentinel, the proxy forwards the real token response to the sandbox. The built-in
oauth.passthrough: truekit uses this mode. Review the agent's credential configuration before promising that it cannot read a token; do not enable passthrough merely to bypass an authentication failure. Even with sentinels, the agent can exercise the credential's permissions on allowed services — restrict token privileges as well as network access.devin - Service secrets are global by default; scopes one to a single sandbox.
--sandbox NAME - Dynamic secrets resolve the value on the host at use time instead of
storing it directly: (1Password
--refor an AWS Secrets Manager ARN — requires an authenticatedop://.../opCLI) oraws(runs a shell command and uses its stdout).--commandcontrols the resolution/cache policy (default--refresh, or55m).on-demandbashsbx secret set anthropic --ref 'op://Private/Anthropic/api-key' sbx secret set github --command 'gh auth token'and--commandare resolved on the host, with your own privileges, and treated as trusted execution — never point--refat anything an untrusted file or an agent's own output could influence.--command - Never pass a secret as a plain value or as a
--env/--kit-argvalue. Both land as literal, unmasked text — in the sandbox's environment, in--env-arg's state file, and potentially in shell history — defeating the entire point of the credential store. Usesbx env plan(orsbx secret set'ssbxenv.yaml/secrets:blocks, which route through the same store) instead.registries: - (experimental) covers a service sbx has no built-in support for: the sandbox sees a placeholder value in an env var you name (
sbx secret set-custom), and the proxy swaps in the real secret only on requests to the--envpattern(s) you declare.--host - lists what is stored, without revealing values.
sbx secret ls [--global|--sandbox NAME] [--service NAME] [--json]removes it.sbx secret rm [SERVICE] [--sandbox NAME] [--all|--registry HOST] [--force] - offers to import secrets already sitting in host environment variables (e.g.
sbx secret import [SERVICE] [--all] [--dry-run] [--force],OPENAI_API_KEY) into the global store, prompting per entry unlessGH_TOKEN/--all. A service with an OAuth token already configured is skipped — OAuth takes precedence at runtime over an imported API key.--force
- 存储凭据,代理使用它代表Agent对出站请求进行身份验证。在正常的代理管理流程中,沙箱看到的是哨兵值而不是原始密钥;代理在匹配的工具包/绑定声明的域名的请求上替换真实值。
sbx secret set [SERVICE]存储密钥并不授予网络访问权限。 出站访问由bashsbx secret set github # 交互式 printf '%s' "$ANTHROPIC_API_KEY" | sbx secret set anthropic单独控制;在调试身份验证之前,先在预期作用域中检查目标域名:sbx policybashsbx policy check network --sandbox my-sandbox api.anthropic.com - OAuth 透传是一个例外,而不是“不暴露密钥”的保证。 当工具包设置 且没有刷新哨兵时,代理会将真实的令牌响应转发给沙箱。内置的
oauth.passthrough: true工具包使用此模式。在承诺Agent无法读取令牌之前,请先审查Agent的凭据配置;不要仅仅为了绕过身份验证失败而启用透传。即使使用哨兵,Agent也可以在允许的服务上行使凭据的权限——请同时限制令牌权限和网络访问。devin - 服务密钥默认是全局的;可将其限定到单个沙箱。
--sandbox NAME - 动态密钥在使用时于主机上解析值,而不是直接存储:(1Password
--ref或 AWS Secrets Manager ARN——需要已认证的op://.../opCLI)或aws(运行一个 shell 命令并使用其标准输出)。--command控制解析/缓存策略(默认--refresh,或55m)。on-demandbashsbx secret set anthropic --ref 'op://Private/Anthropic/api-key' sbx secret set github --command 'gh auth token'和--command在主机上以你自己的权限解析,并被视为可信执行——切勿将--ref指向任何可能被不可信文件或Agent自身输出影响的内容。--command - 切勿将密钥作为普通的 值或
--env/--kit-arg值传递。 两者都会作为字面量、未掩码的文本存在——在沙箱的环境中、在--env-arg的状态文件中,以及可能在 shell 历史中——从而完全违背了凭据存储的意义。请改用sbx env plan(或sbx secret set中的sbxenv.yaml/secrets:块,它们会路由到同一个存储)。registries: - (实验性)适用于 sbx 没有内置支持的服务:沙箱在你指定的环境变量(
sbx secret set-custom)中看到一个占位符值,代理仅在你声明的--env模式上的请求中替换为真实密钥。--host - 列出已存储的内容,但不会显示值。
sbx secret ls [--global|--sandbox NAME] [--service NAME] [--json]将其移除。sbx secret rm [SERVICE] [--sandbox NAME] [--all|--registry HOST] [--force] - 提供将已存在于主机环境变量中的密钥(例如
sbx secret import [SERVICE] [--all] [--dry-run] [--force]、OPENAI_API_KEY)导入全局存储,除非使用GH_TOKEN/--all,否则会逐个提示。已配置 OAuth 令牌的服务会被跳过——OAuth 在运行时优先于导入的 API 密钥。--force
Registry credentials: host-pulls-only by default, two distinct injection scopes
注册表凭据:默认仅主机拉取,两种不同的注入范围
- (optionally
sbx secret set --registry HOST --password-stdin) stores pull credentials for a container registry, used to pull private template images and kit artifacts. Unlike service secrets, registry credentials are host-only by default: they authenticate pulls on the host and are never injected into any sandbox.--usernamebashgh auth token | sbx secret set --registry ghcr.io --password-stdin - and
--all-sandboxeswiden this differently — do not confuse them:--sandbox- : credentials are used for host pulls and injected by the proxy into every new sandbox's registry login (the credential itself never enters the sandbox filesystem).
--all-sandboxes - : credentials are injected into that one sandbox only.
--sandbox NAME - Neither flag: host-pulls-only, injected nowhere.
bashgh auth token | sbx secret set --all-sandboxes --registry ghcr.io --password-stdin gh auth token | sbx secret set --sandbox my-sandbox --registry ghcr.io --password-stdin - For a registry whose Bearer auth endpoint lives on a different hostname
than the registry itself, pass naming the exact trusted HTTPS URL — otherwise the cross-host token exchange is rejected.
--registry-auth-endpoint - removes only that sandbox's registry credential; host-only and global (all-sandboxes) entries are untouched. This does not revoke the upstream token or prevent use of another applicable credential.
sbx secret rm --registry HOST --sandbox NAMEbashsbx secret rm --registry ghcr.io --sandbox my-sandbox - Without ,
--sandboxremoves both the host-only and global entries. Addsbx secret rm --registry HOSTto remove only the global entry instead.--all-sandboxes
- (可选
sbx secret set --registry HOST --password-stdin)存储用于容器注册表的拉取凭据,用于拉取私有模板镜像和工具包制品。与服务密钥不同,注册表凭据默认仅限主机:它们用于在主机上验证拉取请求,绝不会被注入到任何沙箱中。--usernamebashgh auth token | sbx secret set --registry ghcr.io --password-stdin - 和
--all-sandboxes以不同方式扩大此范围——不要混淆:--sandbox- :凭据用于主机拉取并且由代理注入到每个新沙箱的注册表登录中(凭据本身绝不会进入沙箱文件系统)。
--all-sandboxes - :凭据仅注入到那一个沙箱。
--sandbox NAME - 两个标志都不加:仅限主机拉取,不注入任何地方。
bashgh auth token | sbx secret set --all-sandboxes --registry ghcr.io --password-stdin gh auth token | sbx secret set --sandbox my-sandbox --registry ghcr.io --password-stdin - 对于 Bearer 认证端点位于与注册表不同主机名的注册表,请传入 并指定确切的受信任 HTTPS URL——否则跨主机令牌交换将被拒绝。
--registry-auth-endpoint - 仅移除该沙箱的注册表凭据;仅主机和全局(所有沙箱)条目不受影响。这不会撤销上游令牌,也不会阻止使用其他适用的凭据。
sbx secret rm --registry HOST --sandbox NAMEbashsbx secret rm --registry ghcr.io --sandbox my-sandbox - 不带 时,
--sandbox会同时移除仅主机和全局条目。加sbx secret rm --registry HOST则只移除全局条目。--all-sandboxes
Related skills
相关技能
-
Forand
docker agent run --sandboxcommands, usedocker agent sandbox.docker-agent-run -
For creating, reattaching to, and removing the sandboxes these policies and secrets apply to, use.
docker-sandboxes-lifecycle -
For declaring/
secrets:/registries:inside a checked-inbindings:file that provisions them at environment-create time, usesbxenv.yaml.docker-sandboxes-env -
For a kit's ownand
credentials:declarations (what a kit asks for, as opposed to what the user has approved), usepermissions.network:.docker-sandboxes-kits
-
有关和
docker agent run --sandbox命令,请使用docker agent sandbox。docker-agent-run -
有关创建、重新附加和移除这些策略和密钥所作用的沙箱,请使用。
docker-sandboxes-lifecycle -
有关在已检入的文件中声明
sbxenv.yaml/secrets:/registries:以在环境创建时配置它们,请使用bindings:。docker-sandboxes-env -
有关工具包自身的和
credentials:声明(工具包请求的内容,与用户已批准的内容相反),请使用permissions.network:。docker-sandboxes-kits
References
参考资料
- — provenance for every rule above (help captures, source paths, docs URLs).
references/sources.md
- — 上述每条规则的来源(帮助捕获、源路径、文档 URL)。
references/sources.md
Assets
资产
- None.
- 无。
Checks
检查
- — Verification runbook for network policy and secret commands (unexecuted runbook; run manually with an isolated
checks/verification.md, no real secret values).--app-name
- — 网络策略和密钥命令的验证运行手册(未执行的运行手册;请使用隔离的
checks/verification.md手动运行,不要使用真实的密钥值)。--app-name