From 67f51177288b083a12129e190a8eff11872d1f55 Mon Sep 17 00:00:00 2001 From: Vinod Muthusamy Date: Tue, 24 Feb 2026 10:07:16 -0600 Subject: [PATCH 1/4] feat: add sandbox for running Claude Code in Docker --- sandbox/Dockerfile | 32 ++++++++++++++++++++++++++++++++ sandbox/README.md | 30 ++++++++++++++++++++++++++++++ sandbox/sample.env | 1 + 3 files changed, 63 insertions(+) create mode 100644 sandbox/Dockerfile create mode 100644 sandbox/README.md create mode 100644 sandbox/sample.env diff --git a/sandbox/Dockerfile b/sandbox/Dockerfile new file mode 100644 index 00000000..945a4d56 --- /dev/null +++ b/sandbox/Dockerfile @@ -0,0 +1,32 @@ +FROM debian:bookworm-slim + +# Install Linux utilities, Python, and jq +RUN apt-get update && apt-get install -y \ + # Basics & editors + bash coreutils findutils grep sed gawk less nano vim tree file which procps psmisc sudo \ + # Networking + curl wget ca-certificates iputils-ping dnsutils netcat-traditional iproute2 \ + # Git + archives + git unzip zip tar gzip bzip2 xz-utils \ + # Build tools + build-essential make \ + # Python + python3 python3-venv python3-pip \ + # JSON parsing + jq \ + && rm -rf /var/lib/apt/lists/* + +# Create Python venv and upgrade pip safely +RUN python3 -m venv /opt/claude-venv \ + && /opt/claude-venv/bin/python -m pip install --upgrade pip + +# Install Claude Code (native installer) +#RUN curl -fsSL https://install.anthropic.com/claude-code/linux | bash +RUN curl -fsSL https://claude.ai/install.sh | bash + +# Add venv + Claude to PATH +ENV PATH="/opt/claude-venv/bin:/root/.local/bin:${PATH}" + +WORKDIR /workspace + +CMD ["bash"] diff --git a/sandbox/README.md b/sandbox/README.md new file mode 100644 index 00000000..07783d0a --- /dev/null +++ b/sandbox/README.md @@ -0,0 +1,30 @@ +# Claude Code Sandbox + +A Docker image for running Claude Code in a sandboxed Debian environment with Python and common Linux tools. + +## Build + +```bash +docker build -t claude-sandbox . +``` + +## Run + +1. Copy the sample env file and add your API key: + +```bash +cp sample.env .env # edit .env and set your credentials. +``` + +2. Run the container, mounting your project into `/workspace`: + +```bash +docker run --rm -it --env-file .env -v "$(pwd)":/workspace claude-sandbox +``` + +3. Test that Claude Code is working: + +```bash +docker run --rm --env-file .env claude-sandbox claude -p "who are you" +``` + diff --git a/sandbox/sample.env b/sandbox/sample.env new file mode 100644 index 00000000..640c797c --- /dev/null +++ b/sandbox/sample.env @@ -0,0 +1 @@ +ANTHROPIC_API_KEY=sk-ant-xxxx From 0246f508052fb313455afbac59307b2df24262e2 Mon Sep 17 00:00:00 2001 From: Vinod Muthusamy Date: Tue, 24 Feb 2026 10:20:49 -0600 Subject: [PATCH 2/4] chore: update secrets baseline for sandbox --- .secrets.baseline | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 25406af5..8cc5307d 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -3,7 +3,7 @@ "files": "^.secrets.baseline$", "lines": null }, - "generated_at": "2026-01-27T22:16:04Z", + "generated_at": "2026-02-24T16:20:06Z", "plugins_used": [ { "name": "AWSKeyDetector" @@ -100,7 +100,7 @@ "hashed_secret": "ec3810e10fb78db55ce38b9c18d1c3eb1db739e0", "is_secret": false, "is_verified": false, - "line_number": 32, + "line_number": 36, "type": "Secret Keyword", "verified_result": null } @@ -153,6 +153,16 @@ "verified_result": null } ], + "sandbox/sample.env": [ + { + "hashed_secret": "b792a28a35da9b44fa0ee8a53002e9c238afb1bd", + "is_secret": false, + "is_verified": false, + "line_number": 1, + "type": "Secret Keyword", + "verified_result": null + } + ], "tests/data/trajectory.json": [ { "hashed_secret": "88de85ead2ab26f647127036827ee7746fcd7514", From d65d7bf4e4eea1e4fa8d410a8371dd8b3374ff13 Mon Sep 17 00:00:00 2001 From: Vinod Muthusamy Date: Tue, 24 Feb 2026 10:22:33 -0600 Subject: [PATCH 3/4] docs: fix sandbox README paths to work from repo root --- sandbox/README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sandbox/README.md b/sandbox/README.md index 07783d0a..22199295 100644 --- a/sandbox/README.md +++ b/sandbox/README.md @@ -4,8 +4,10 @@ A Docker image for running Claude Code in a sandboxed Debian environment with Py ## Build +From the repository root: + ```bash -docker build -t claude-sandbox . +docker build -t claude-sandbox sandbox/ ``` ## Run @@ -13,18 +15,18 @@ docker build -t claude-sandbox . 1. Copy the sample env file and add your API key: ```bash -cp sample.env .env # edit .env and set your credentials. +cp sandbox/sample.env sandbox/.env # edit sandbox/.env and set your credentials. ``` 2. Run the container, mounting your project into `/workspace`: ```bash -docker run --rm -it --env-file .env -v "$(pwd)":/workspace claude-sandbox +docker run --rm -it --env-file sandbox/.env -v "$(pwd)":/workspace claude-sandbox ``` 3. Test that Claude Code is working: ```bash -docker run --rm --env-file .env claude-sandbox claude -p "who are you" +docker run --rm --env-file sandbox/.env claude-sandbox claude -p "who are you" ``` From c91a15b58e02b494e80c0c54237dce982191ab7e Mon Sep 17 00:00:00 2001 From: Vinod Muthusamy Date: Tue, 24 Feb 2026 11:23:05 -0600 Subject: [PATCH 4/4] fix: run sandbox container as non-root user and harden installer Add a dedicated sandbox user so the container no longer runs as root. Also download the installer to a file before executing and update README paths to use sandbox/myenv. --- sandbox/Dockerfile | 20 ++++++++++++++------ sandbox/README.md | 6 +++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/sandbox/Dockerfile b/sandbox/Dockerfile index 945a4d56..5c68146a 100644 --- a/sandbox/Dockerfile +++ b/sandbox/Dockerfile @@ -16,16 +16,24 @@ RUN apt-get update && apt-get install -y \ jq \ && rm -rf /var/lib/apt/lists/* -# Create Python venv and upgrade pip safely +# Create non-root user +RUN groupadd sandbox && useradd -m -g sandbox sandbox \ + && mkdir -p /workspace && chown sandbox:sandbox /workspace + +# Create Python venv and make it accessible to sandbox user RUN python3 -m venv /opt/claude-venv \ - && /opt/claude-venv/bin/python -m pip install --upgrade pip + && /opt/claude-venv/bin/python -m pip install --upgrade pip \ + && chown -R sandbox:sandbox /opt/claude-venv -# Install Claude Code (native installer) -#RUN curl -fsSL https://install.anthropic.com/claude-code/linux | bash -RUN curl -fsSL https://claude.ai/install.sh | bash +# Install Claude Code as sandbox user +USER sandbox +RUN curl -fsSL -o /tmp/install.sh https://claude.ai/install.sh \ + && bash /tmp/install.sh \ + && rm /tmp/install.sh # Add venv + Claude to PATH -ENV PATH="/opt/claude-venv/bin:/root/.local/bin:${PATH}" +ENV HOME="/home/sandbox" +ENV PATH="/opt/claude-venv/bin:/home/sandbox/.local/bin:${PATH}" WORKDIR /workspace diff --git a/sandbox/README.md b/sandbox/README.md index 22199295..fed9d8d4 100644 --- a/sandbox/README.md +++ b/sandbox/README.md @@ -15,18 +15,18 @@ docker build -t claude-sandbox sandbox/ 1. Copy the sample env file and add your API key: ```bash -cp sandbox/sample.env sandbox/.env # edit sandbox/.env and set your credentials. +cp sandbox/sample.env sandbox/myenv # edit sandbox/myenv and set your credentials. ``` 2. Run the container, mounting your project into `/workspace`: ```bash -docker run --rm -it --env-file sandbox/.env -v "$(pwd)":/workspace claude-sandbox +docker run --rm -it --env-file sandbox/myenv -v "$(pwd)":/workspace claude-sandbox ``` 3. Test that Claude Code is working: ```bash -docker run --rm --env-file sandbox/.env claude-sandbox claude -p "who are you" +docker run --rm --env-file sandbox/myenv claude-sandbox claude -p "who are you" ```