Skip to content

[BUG] sandbox: NOPASSWD:ALL + workspace-writable firewall script lets the agent disable the firewall #208

Closed

Description

@gatezh

Summary

The claude-code-sandbox image's firewall isn't a boundary against the agent it sandboxes. The shared Dockerfile stage grants node ALL=(ALL) NOPASSWD:ALL to both targets, and the sandbox template bind-mounts init-firewall.sh from the workspace, which the agent can write to, then runs it as root via sudo on every start. Combined with claudeCode.allowDangerouslySkipPermissions: true, a prompt-injected agent can run sudo iptables -P OUTPUT ACCEPT && sudo iptables -F (or edit the script) and reach any host.

Reproduction

  1. Open the sandbox variant.
  2. sudo iptables -P OUTPUT ACCEPT && sudo iptables -F && curl -sI https://example.com → succeeds.

Suggested fix

  • Sandbox target: drop /etc/sudoers.d/node-nopasswd; allow only NOPASSWD: /usr/local/bin/init-firewall.sh plus the specific chown/find used by postCreateCommand (or move those into the image/entrypoint).
  • Don't run a workspace-writable script as root: bake a root-owned firewall runner into the image that reads a project allowlist file (domains only, validated) instead of executing project code.

Affected files in this repo

  • claude-code/.devcontainer/Dockerfile:225
  • claude-code/.devcontainer/claude-sandbox/devcontainer.json (mounts init-firewall.sh bind, postStartCommand)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions