Skip to content

secrets env: keep the token and secret values off every child's argv - #100

Merged
margani merged 1 commit into
mainfrom
fix/97-secrets-argv
Nov 2, 2026
Merged

margani merged 1 commit into
mainfrom
fix/97-secrets-argv

Conversation

@margani

@margani margani commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Closes #97.

What changed

  • bws_list exports BWS_ACCESS_TOKEN in a subshell that execs bws, instead of passing it as an argument to the external env.
  • Project secrets (and --vars) are merged by one jq reading both documents on stdin, instead of a --argjson value.
  • The key-name check anchors with \A…\z; jq's $ also matched before a trailing newline.

Why

The script promises that the token and secret values never appear on a command line. Both were in a child's argv, which other local accounts can read through /proc.

Verification

  • secrets/tests/secrets_test.sh now shims env and jq to log their argv and fails if the token or a secret value appears; it also refuses a key ending in a newline.
  • On the old code the new check failed: FAIL: 'machine-token-123' was on a child's command line.
  • Mutation: restoring the ^…$ anchor fails with FAIL: accepted: … --project newlinekey.
  • ./run-tests: all 10 passed, 3 skipped (harden needs a disposable machine; two Windows-only suites).

Not verified

  • Behaviour against the real bws CLI (tests use the fake).

The token reached bws through the external env command's argv, and each
project's secrets reached jq as a --argjson value; both are readable by other
local accounts through /proc. Export the token in a subshell that execs bws,
merge through stdin, and anchor the key check with \A...\z so a key ending in
a newline is refused. The test now shims env and jq to log their argv.

Closes #97
@margani
margani merged commit 9af1fb9 into main Nov 2, 2026
4 checks passed
@margani
margani deleted the fix/97-secrets-argv branch November 2, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

secrets env: keep the token and secret values off every child's command line

1 participant