Skip to content

feat(sandbox): isolate image:* ENV secrets via proxy sidecar container#55

Open
geminixiang wants to merge 3 commits into
mainfrom
claude/sandbox-image-secrets-proxy-R4UeS
Open

feat(sandbox): isolate image:* ENV secrets via proxy sidecar container#55
geminixiang wants to merge 3 commits into
mainfrom
claude/sandbox-image-secrets-proxy-R4UeS

Conversation

@geminixiang

Copy link
Copy Markdown
Owner

For image:* sandboxes, known AI service API keys (Anthropic, OpenAI,
OpenRouter) are no longer injected into the sandbox container environment.
Instead a lightweight Node.js proxy container is provisioned on the same
Docker network; the sandbox receives proxy base URLs and dummy placeholder
key values, so malicious code running env inside the sandbox cannot
obtain the real credentials.

  • SecretProxyManager: provisions/stops/removes per-user proxy containers
    running the embedded HTTP reverse-proxy script in node:20-alpine
  • Proxy strips inbound auth headers and injects the real key before
    forwarding to the upstream API (streaming via pipe)
  • ContainerLifecycleHooks added to DockerContainerManager so proxy
    containers are stopped/removed alongside their sandbox counterparts
  • SecretProxyManager threaded through CommandServices → SessionRuntime
    → createRunner so a single shared instance handles both provisioning
    and lifecycle cleanup

https://claude.ai/code/session_01DFxUg9kw52rqDGP4YFosiN

claude added 3 commits May 8, 2026 14:27
For image:* sandboxes, known AI service API keys (Anthropic, OpenAI,
OpenRouter) are no longer injected into the sandbox container environment.
Instead a lightweight Node.js proxy container is provisioned on the same
Docker network; the sandbox receives proxy base URLs and dummy placeholder
key values, so malicious code running `env` inside the sandbox cannot
obtain the real credentials.

- SecretProxyManager: provisions/stops/removes per-user proxy containers
  running the embedded HTTP reverse-proxy script in node:20-alpine
- Proxy strips inbound auth headers and injects the real key before
  forwarding to the upstream API (streaming via pipe)
- ContainerLifecycleHooks added to DockerContainerManager so proxy
  containers are stopped/removed alongside their sandbox counterparts
- SecretProxyManager threaded through CommandServices → SessionRuntime
  → createRunner so a single shared instance handles both provisioning
  and lifecycle cleanup

https://claude.ai/code/session_01DFxUg9kw52rqDGP4YFosiN
Remove secretProxyManager from shared interfaces (CommandServices,
createRunner signature, session-runtime) to keep image:* concerns
isolated. ActorExecutionResolver now self-creates the proxy manager
when baseConfig.type === "image", so no caller plumbing is needed.

Also simplify SecretProxyManager to write the embedded proxy script to
a fixed temp path (mama-proxy-server.mjs) instead of a unique mkdtemp
dir, allowing multiple instances to coexist without shared mutable state.

https://claude.ai/code/session_01DFxUg9kw52rqDGP4YFosiN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants