secrets: preflight allowlist guard for .sandcastle/.env (part 1 of #592, protected-path) #593
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Matou/idss#593
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Machinery change — preflight allowlist guard for
.sandcastle/.env(part 1 of #592)Split out of #592: that ticket's part 2 (lab-dns secrets-file fallback) shipped
as a swarm slice, but part 1 is a protected
.sandcastle/change (rule 9 / #445)— a swarm worker cannot touch the machinery that judges its own run, so it needs an
interactive session's standing.
What's needed
A preflight allowlist guard: refuse a host-mode run whose
.sandcastle/.envcarries any key beyond the allowlist (
CLAUDE_CODE_OAUTH_TOKEN/ANTHROPIC_API_KEY.env.example:FORGEJO_API,MATTERMOST_URL,MATTERMOST_CHANNEL_ID,BASH_*_TIMEOUT_MS,REHEARSAL_*,SWARM_HOST,SWARM_RUN_ID). Any*TOKEN|SECRET|KEY|PASS-shaped stray → fail closed, samepattern as
preflight-swarm.sh's empty-secret / content-not-existence check(
guard_secrets_content). This stops the docker-inspect leak class (#578) fromrecurring silently: sandcastle forwards every
.envkey asdocker run -e, landingit in
docker inspect .Config.Env.run-swarm.shoverwrites.envfrom.env.exampleunderGITHUB_ACTIONS(#578), so the guard must not fire (or mustno-op) on the CI path.
run-swarm.sh(host-mode entry) with a guard mirrored/tested inpreflight-swarm.sh(guard_secrets_contentsits right there)..envwith a strayFOO_TOKEN=...(must refuse) anda clean allowlist-only
.env(must pass) — theguard_healer_railsthrowaway-fixturepattern already used in
preflight-swarm.sh.Secondary (same area, also protected)
.sandcastle/secrets/README.md's consumer table omitsourcloud_lab_dns_tokenentirely. Add a row (
ourcloud_lab_dns_token→.claude/skills/lab-dns/lab-dns)now that part 2 wired the file fallback.
Found while closing #592 (part 2). Two-way door;
ready-for-sessionper ADR 0174 +#445 (protected-path machinery change).
Ruled by agent under ADR 0174 — veto anytime.
Two-way door: a commit/config change, provable by new offline test suites — landed.
Landed on
mainat4d80a57:.sandcastle/env-allowlist-lib.sh(env_allowlist_violations): flags any*TOKEN|SECRET|KEY|PASS-shaped key in a.envfile that isn't on the allowlist (mirrors.env.example:CLAUDE_CODE_OAUTH_TOKEN/ANTHROPIC_API_KEY+ the documented non-secret config;REHEARSAL_*trusted as an open-ended prefix).run-swarm.sh's.envmaterialize step now calls the guard in the host-mode branch only (.envpre-exists andGITHUB_ACTIONSunset) — the CI branch always overwrites.envfrom.env.examplefirst, so the guard structurally never fires there, per the ticket's requirement. A violation fails the run loud (SWARM_EXIT_REASON=env-allowlist-violation) and leaves the offending.envuntouched so the operator can fix it.preflight-swarm.shgained a 7th zero-token self-test guard,guard_secrets_allowlist, mirroringguard_secrets_content's content-not-existence pattern — a strayFOO_TOKENthrowaway fixture must trip it, a clean allowlist-only fixture must pass it..sandcastle/secrets/README.md's consumer table now listsourcloud_lab_dns_token→.claude/skills/lab-dns/lab-dns(#592 part 2 wired the file fallback but left the table stale).Proof:
tests/env-allowlist-lib-test.sh(8 cases: clean allowlist passes,ANTHROPIC_API_KEYallowed, strayFOO_TOKENrefused, allTOKEN|SECRET|KEY|PASSshapes caught, a benign non-secret-shaped stray is correctly out of scope, comment/blank/exportparsing, missing file is not a violation,REHEARSAL_*prefix trusted) — green.tests/run-swarm-env-guard-test.sh(4 cases, thedebounce-test.shisolated-block pattern: CI mode always overwrites even over a bad.env; host-mode first run materializes; host-mode clean.envpasses untouched; host-mode bad.envrefused and left untouched) — green.tests/preflight-swarm-test.shupdated for the guard count (6→7) and passing..sandcastle/tests/*.shsweep (36 files) green after the change.git pull --rebaseclean, pushed straight tomain(no swarm/session collision).advances #593, advances #592