secrets: .env allowlist preflight guard + file fallback for lab-dns (follow-up to #578) #592

Closed
opened 2026-08-19 17:15:25 +00:00 by ben · 3 comments
Owner

Follow-up from #578 (its third bullet + the caveat found while closing it):

  1. Preflight allowlist guard: refuse a host-mode run whose .sandcastle/.env contains keys beyond the allowlist (CLAUDE_CODE_OAUTH_TOKEN + non-secret config) — same fail-closed pattern as the empty-secret check. Stops the docker-inspect leak class recurring.
  2. File fallbacks for the two consumers that lack one: .claude/skills/lab-dns/lab-dns (reads only env/.env for OURCLOUD_LAB_DNS_TOKEN) should fall back to .sandcastle/secrets/ourcloud_lab_dns_token (file now exists on the dev laptop), matching notify-mattermost.sh's pattern.

Two-way door, agent-shaped (ADR 0174).

Follow-up from #578 (its third bullet + the caveat found while closing it): 1. **Preflight allowlist guard**: refuse a host-mode run whose `.sandcastle/.env` contains keys beyond the allowlist (`CLAUDE_CODE_OAUTH_TOKEN` + non-secret config) — same fail-closed pattern as the empty-secret check. Stops the docker-inspect leak class recurring. 2. **File fallbacks for the two consumers that lack one**: `.claude/skills/lab-dns/lab-dns` (reads only env/`.env` for `OURCLOUD_LAB_DNS_TOKEN`) should fall back to `.sandcastle/secrets/ourcloud_lab_dns_token` (file now exists on the dev laptop), matching notify-mattermost.sh's pattern. Two-way door, agent-shaped (ADR 0174).
Author
Owner

swarm-claim host=matou-dev-server-01 run=7708
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=7708 (automated multi-host claim — lowest live claim id works this ticket)
Author
Owner

Ruled by agent under ADR 0174 — veto anytime. Split this two-part follow-up:

  • Part 2 (lab-dns file fallback) — shipped this iteration. load_creds now
    resolves OURCLOUD_LAB_DNS_TOKEN from a read-only secret file
    (/run/secrets/ourcloud_lab_dns_token in-sandbox, .sandcastle/secrets/ourcloud_lab_dns_token
    on a host run) before the .env fallback, mirroring notify-mattermost.sh / the
    clan-lab skill. Empty files are skipped (content-not-existence, GOTCHAS §4).
    Proven by .claude/skills/lab-dns/lab-dns-test.sh (red→green at the load_creds seam).

  • Part 1 (preflight allowlist guard) — filed as #593, ready-for-session. The
    guard must live in run-swarm.sh / preflight-swarm.sh — protected .sandcastle/
    paths (rule 9 / #445)
    , which a swarm worker cannot edit (the tree-fingerprint rolls
    it back and reds the run). It needs an interactive session's standing, not a swarm slice.

Why two-way door: part 2 is a purely additive credential-source fallback, revertible by a
later commit and proven by the seam test; it widens no security posture (still fails closed,
still one token, still file-not-env). Part 1 is escalated, not ruled, exactly because #445
reserves protected-path machinery changes for a session.

Closing #592 on part 2; part 1 continues in #593.

**Ruled by agent under ADR 0174 — veto anytime.** Split this two-part follow-up: - **Part 2 (lab-dns file fallback) — shipped this iteration.** `load_creds` now resolves `OURCLOUD_LAB_DNS_TOKEN` from a read-only secret file (`/run/secrets/ourcloud_lab_dns_token` in-sandbox, `.sandcastle/secrets/ourcloud_lab_dns_token` on a host run) before the `.env` fallback, mirroring `notify-mattermost.sh` / the `clan-lab` skill. Empty files are skipped (content-not-existence, GOTCHAS §4). Proven by `.claude/skills/lab-dns/lab-dns-test.sh` (red→green at the `load_creds` seam). - **Part 1 (preflight allowlist guard) — filed as #593, `ready-for-session`.** The guard must live in `run-swarm.sh` / `preflight-swarm.sh` — **protected `.sandcastle/` paths (rule 9 / #445)**, which a swarm worker cannot edit (the tree-fingerprint rolls it back and reds the run). It needs an interactive session's standing, not a swarm slice. Why two-way door: part 2 is a purely additive credential-source fallback, revertible by a later commit and proven by the seam test; it widens no security posture (still fails closed, still one token, still file-not-env). Part 1 is escalated, not ruled, exactly because #445 reserves protected-path machinery changes for a session. Closing #592 on part 2; part 1 continues in #593.
Author
Owner

close-report for #592 — status success

✅ close-report gates passed — every claim verified against main; closing.

envelope
{
  "issue": 592,
  "status": "success",
  "commits": [
    "146a98b5101ee27567e2b459c733c4e83ea4455f"
  ],
  "changed_files": [
    ".claude/skills/lab-dns/lab-dns",
    ".claude/skills/lab-dns/SKILL.md",
    ".claude/skills/lab-dns/lab-dns-test.sh"
  ],
  "tests": [
    {
      "command": "bash .claude/skills/lab-dns/lab-dns-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash -n .claude/skills/lab-dns/lab-dns",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Part 2: lab-dns falls back to .sandcastle/secrets/ourcloud_lab_dns_token (matching notify-mattermost.sh's pattern)": "load_creds in .claude/skills/lab-dns/lab-dns now reads /run/secrets/ourcloud_lab_dns_token then $REPO_ROOT/.sandcastle/secrets/ourcloud_lab_dns_token before the .env fallback (commit 146a98b); proven by lab-dns-test.sh 'reads token from .sandcastle/secrets file' (red pre-fix, green post-fix)",
    "Part 1: preflight .env allowlist guard (protected .sandcastle/ machinery, rule 9 / #445)": "Cannot be edited by a swarm worker (tree-fingerprint rolls back protected paths); filed as #593 ready-for-session and ruled under ADR 0174 in a comment on #592",
    "Fail-closed pattern preserved": "empty secret files are skipped (-s check, GOTCHAS §4) and a wholly-missing credential still dies; proven by lab-dns-test.sh cases 'missing credential fails closed' and 'empty secret file skipped'"
  },
  "summary": "lab-dns resolves OURCLOUD_LAB_DNS_TOKEN from a secrets file before .env (part 2 of #592); the protected-path preflight allowlist guard (part 1) is filed as #593 ready-for-session per rule 9/#445.",
  "blockers": []
}
**close-report** for #592 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; closing. <details><summary>envelope</summary> ```json { "issue": 592, "status": "success", "commits": [ "146a98b5101ee27567e2b459c733c4e83ea4455f" ], "changed_files": [ ".claude/skills/lab-dns/lab-dns", ".claude/skills/lab-dns/SKILL.md", ".claude/skills/lab-dns/lab-dns-test.sh" ], "tests": [ { "command": "bash .claude/skills/lab-dns/lab-dns-test.sh", "exit_code": 0 }, { "command": "bash -n .claude/skills/lab-dns/lab-dns", "exit_code": 0 } ], "criteria": { "Part 2: lab-dns falls back to .sandcastle/secrets/ourcloud_lab_dns_token (matching notify-mattermost.sh's pattern)": "load_creds in .claude/skills/lab-dns/lab-dns now reads /run/secrets/ourcloud_lab_dns_token then $REPO_ROOT/.sandcastle/secrets/ourcloud_lab_dns_token before the .env fallback (commit 146a98b); proven by lab-dns-test.sh 'reads token from .sandcastle/secrets file' (red pre-fix, green post-fix)", "Part 1: preflight .env allowlist guard (protected .sandcastle/ machinery, rule 9 / #445)": "Cannot be edited by a swarm worker (tree-fingerprint rolls back protected paths); filed as #593 ready-for-session and ruled under ADR 0174 in a comment on #592", "Fail-closed pattern preserved": "empty secret files are skipped (-s check, GOTCHAS §4) and a wholly-missing credential still dies; proven by lab-dns-test.sh cases 'missing credential fails closed' and 'empty secret file skipped'" }, "summary": "lab-dns resolves OURCLOUD_LAB_DNS_TOKEN from a secrets file before .env (part 2 of #592); the protected-path preflight allowlist guard (part 1) is filed as #593 ready-for-session per rule 9/#445.", "blockers": [] } ``` </details>
ben closed this issue 2026-08-19 17:25:53 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#592
No description provided.