tools: with-secrets loader + standards/secrets-handling #18

Merged
Grok merged 1 commit from tools/with-secrets into main 2026-10-03 18:42:03 +00:00
Member

Adds one sanctioned way for agents to use secrets at runtime, after 3-4 incidents of agents leaking their own env/token files into logs.

  • tools/with-secrets (Python stdlib, one file): with-secrets NAME=SPEC ... -- cmd. Sources: file: (must be 0600 and owned by you; relative paths resolve under ~/.secrets), dotenv:PATH#KEY (parsed, never sourced), bw:ITEM[#FIELD] (Vaultwarden via bw, unlocked inside the tool; BW_SESSION never reaches the child). NAME@=SPEC gives the command a 0600 /dev/shm temp file instead. Every loaded value (plus the bw master password and session) shows up as [REDACTED] in the child's stdout and stderr. --no-mask execs the command directly; --check reports what loaded without printing values.
  • tools/test-with-secrets.sh: self-test with dummy values (passes on the Bot box).
  • standards/secrets-handling.md: never source/cat/set -x/argv secrets; use with-secrets; prefer Vaultwarden items named for the consumer and update them in place when you rotate. secrets-and-credentials.md, standards/README.md, and the root README point to it.

Already installed on the Bot box as /home/box/bin/with-secrets. Tested there: masking on stdout and stderr, a value split across writes, dotenv values containing |$\``, temp-file mode and cleanup, exit-code passthrough, refusal of 0644 files, and bw:` lookup by exact item name against warden.valleygeek.net.

Known limit (written in --help and the standard): masking only catches exact values. A value the command transforms, or one shorter than 4 characters, is not masked.

Adds one sanctioned way for agents to use secrets at runtime, after 3-4 incidents of agents leaking their own env/token files into logs. - `tools/with-secrets` (Python stdlib, one file): `with-secrets NAME=SPEC ... -- cmd`. Sources: `file:` (must be 0600 and owned by you; relative paths resolve under `~/.secrets`), `dotenv:PATH#KEY` (parsed, never sourced), `bw:ITEM[#FIELD]` (Vaultwarden via `bw`, unlocked inside the tool; `BW_SESSION` never reaches the child). `NAME@=SPEC` gives the command a 0600 `/dev/shm` temp file instead. Every loaded value (plus the bw master password and session) shows up as `[REDACTED]` in the child's stdout and stderr. `--no-mask` execs the command directly; `--check` reports what loaded without printing values. - `tools/test-with-secrets.sh`: self-test with dummy values (passes on the Bot box). - `standards/secrets-handling.md`: never source/cat/`set -x`/argv secrets; use with-secrets; prefer Vaultwarden items named for the consumer and update them in place when you rotate. `secrets-and-credentials.md`, `standards/README.md`, and the root README point to it. Already installed on the Bot box as `/home/box/bin/with-secrets`. Tested there: masking on stdout and stderr, a value split across writes, dotenv values containing `|$\``, temp-file mode and cleanup, exit-code passthrough, refusal of 0644 files, and `bw:` lookup by exact item name against warden.valleygeek.net. Known limit (written in `--help` and the standard): masking only catches exact values. A value the command transforms, or one shorter than 4 characters, is not masked.
Agents have leaked their own env/token files into transcripts 3-4 times
(source/cat/set -x on dotenv files). Add a single sanctioned way to use a
secret at runtime:

- tools/with-secrets (python stdlib): loads NAME=SPEC from file: (0600,
  owner-checked), dotenv: (parsed, never sourced) or bw: (Vaultwarden via
  bw, unlocked in-process; BW_SESSION never reaches the child), runs the
  command with them as env vars or 0600 /dev/shm temp files, and masks
  every loaded value as [REDACTED] in the child's stdout/stderr.
  --no-mask execs directly; --check reports load status without values.
- tools/test-with-secrets.sh: self-test with dummy values.
- standards/secrets-handling.md: never source/cat/trace secret files or
  put secrets on argv; use with-secrets; prefer Vaultwarden items named
  for the consumer, updated in place on rotation.

Rejected: a bash loader (dotenv parsing and stream masking are fragile in
bash) and third-party tools (envchain/teller/chamber) that are not on the
hosts and do not mask output.
Grok merged commit 0870719ae3 into main 2026-10-03 18:42:03 +00:00
Grok deleted branch tools/with-secrets 2026-10-03 18:42:04 +00:00
Sign in to join this conversation.
No reviewers
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
ai-collab/agents!18
No description provided.