fix(sandcastle): stop forwarding bearer tokens as sandbox env vars #124

Closed
kaimahi wants to merge 0 commits from fix/sandcastle-secrets-file-mount into main
Member

Summary

FORGEJO_TOKEN, MATTERMOST_BOT_TOKEN, and DIGITALOCEAN_ACCESS_TOKEN were declared in .sandcastle/.env, which Sandcastle forwards into every worker container as docker run -e values — landing in docker inspect .Config.Env, readable by anyone with Docker API access (the 2026-07-11 breach vector this repo already documents in docs/architecture/07-secrets-architecture.md).

Found during a security audit of matou-dev (a separate host) that also inspected this swarm, because the running sandcastle worker container showed the same plaintext-env pattern on docker inspect.

Change

  • The three tokens now ship as read-only files under /run/secrets (main.mts's mounts config), materialized by run-swarm.sh from its own process env before each run — see .sandcastle/secrets/README.md.
  • list-ready-tasks.sh, preflight-triage.sh, ask-human.sh, notify-mattermost.sh, prompt.md's example commands, and the clan-lab skill all read from the file, falling back to an env var if present.
  • CLAUDE_CODE_OAUTH_TOKEN is unchanged — the claude CLI has no file-based flag for it, so it stays a documented, tool-level residual (same category as oauth2-proxy's cookie-secret on matou-dev). Rotation, not config, is the mitigation there.

Test plan

  • bash -n on every touched shell script
  • Mount + file-read fallback logic verified end-to-end in an isolated throwaway container (fake token value, confirmed it resolves correctly)
  • Not yet verified against a live scheduled run — the first swarm/triage cron tick after this merges is the real test. Recommend watching the next run (or triggering workflow_dispatch manually) before treating this as fully proven.
## Summary `FORGEJO_TOKEN`, `MATTERMOST_BOT_TOKEN`, and `DIGITALOCEAN_ACCESS_TOKEN` were declared in `.sandcastle/.env`, which Sandcastle forwards into every worker container as `docker run -e` values — landing in `docker inspect .Config.Env`, readable by anyone with Docker API access (the 2026-07-11 breach vector this repo already documents in `docs/architecture/07-secrets-architecture.md`). Found during a security audit of matou-dev (a separate host) that also inspected this swarm, because the running `sandcastle` worker container showed the same plaintext-env pattern on `docker inspect`. ## Change - The three tokens now ship as read-only files under `/run/secrets` (`main.mts`'s `mounts` config), materialized by `run-swarm.sh` from its own process env before each run — see `.sandcastle/secrets/README.md`. - `list-ready-tasks.sh`, `preflight-triage.sh`, `ask-human.sh`, `notify-mattermost.sh`, `prompt.md`'s example commands, and the `clan-lab` skill all read from the file, falling back to an env var if present. - `CLAUDE_CODE_OAUTH_TOKEN` is unchanged — the `claude` CLI has no file-based flag for it, so it stays a documented, tool-level residual (same category as oauth2-proxy's cookie-secret on matou-dev). Rotation, not config, is the mitigation there. ## Test plan - [x] `bash -n` on every touched shell script - [x] Mount + file-read fallback logic verified end-to-end in an isolated throwaway container (fake token value, confirmed it resolves correctly) - [ ] **Not yet verified against a live scheduled run** — the first `swarm`/`triage` cron tick after this merges is the real test. Recommend watching the next run (or triggering `workflow_dispatch` manually) before treating this as fully proven.
fix(sandcastle): stop forwarding bearer tokens as sandbox env vars
Some checks failed
ci / seam (pull_request) Failing after 19s
3b4a4f2123
FORGEJO_TOKEN, MATTERMOST_BOT_TOKEN, and DIGITALOCEAN_ACCESS_TOKEN were
declared in .sandcastle/.env, which Sandcastle forwards into every worker
container as `docker run -e` values — landing in `docker inspect
.Config.Env`, readable by anyone with Docker API access (the 2026-07-11
breach vector this repo already documents).

They now ship as read-only files under /run/secrets (main.mts's `mounts`
config, materialized by run-swarm.sh from its own process env before each
run — see .sandcastle/secrets/README.md) and are read directly by
list-ready-tasks.sh, preflight-triage.sh, ask-human.sh,
notify-mattermost.sh, prompt.md's example commands, and the clan-lab
skill, each falling back to an env var if the file isn't present.

CLAUDE_CODE_OAUTH_TOKEN is unchanged: the `claude` CLI has no file-based
flag for it (unlike --client-secret-file-style options elsewhere), so it
remains a documented, tool-level residual — same category as oauth2-proxy's
cookie-secret on matou-dev. Rotation, not config, is the mitigation there.

Verified: mount + file-read fallback logic tested end-to-end in an
isolated throwaway container; all touched shell scripts pass `bash -n`.
Not yet verified against a live scheduled run — first swarm/triage cron
tick after this merges is the real test.
Owner

This was merged to main on 2026-07-26 (56a03650); its head 3b4a4f21 is on main, but Forgejo never marked the PR merged. Closing so it leaves the open list — thank you for the fix.

This was merged to `main` on 2026-07-26 (56a03650); its head 3b4a4f21 is on main, but Forgejo never marked the PR merged. Closing so it leaves the open list — thank you for the fix.
ben closed this pull request 2026-11-16 17:47:27 +00:00
Some checks failed
ci / seam (pull_request) Failing after 19s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss!124
No description provided.