install.sh: enrollment token never on the command line (#18) #30

Merged
logan merged 3 commits from fix/18-install-token-argv into main 2026-10-04 18:28:19 -04:00
Owner

Fixes #18. CISO condition from server-26#61: the enrollment token must never appear as a plaintext CLI argument.

3269203 ("enrollment token via header file too") only got the token off curl's argv. install.sh --token DRB-… was still the documented path: it put the token in shell history, and in ps for the whole install. So #18 was still open on main.

Changes (install.sh + README)

  • The token is prompted for on the TTY with hidden input. This is the default and the recommended path.
  • Unattended installs: --token-file PATH warns if the file is group- or world-readable, and an exported DRB_ENROLLMENT_TOKEN works too. DRB_ENROLLMENT_TOKEN is unset after it is read, so child processes don't inherit it.
  • --token still works so old copied commands don't break, but it prints a deprecation warning.
  • Every "re-run with --token DRB-…" hint now points at the prompt or --token-file. A re-run with a stale pickup secret (401/404) now prompts for a token instead of dying.
  • The usage text and README example no longer show --token, and they warn that sudo DRB_ENROLLMENT_TOKEN=X bash leaks the token the same way --token does.

Not in this PR: the Server mint panel (drb-frontend/app/settings/nodes/page.tsx:63) still renders --token ${justMinted}, so it is filed in server-26. This PR does not depend on it: an old command still works, with a warning.

Verification: bash -n. I also ran the argument-parsing section in a harness: file, argv, env, none, missing file and empty file all behave as intended. Not run end-to-end on a Pi. No Python touched. edge-node pytest: 287 passed, 9 skipped. flake8 is clean.

🤖 Generated with Claude Code

Fixes #18. CISO condition from server-26#61: **the enrollment token must never appear as a plaintext CLI argument.** `3269203` ("enrollment token via header file too") only got the token off **curl's** argv. `install.sh --token DRB-…` was still the documented path: it put the token in shell history, and in `ps` for the whole install. So #18 was still open on main. **Changes (install.sh + README)** - The token is prompted for on the TTY with hidden input. This is the default and the recommended path. - Unattended installs: `--token-file PATH` warns if the file is group- or world-readable, and an exported `DRB_ENROLLMENT_TOKEN` works too. `DRB_ENROLLMENT_TOKEN` is `unset` after it is read, so child processes don't inherit it. - `--token` still works so old copied commands don't break, but it prints a deprecation warning. - Every "re-run with --token DRB-…" hint now points at the prompt or `--token-file`. A re-run with a stale pickup secret (401/404) now prompts for a token instead of dying. - The usage text and README example no longer show `--token`, and they warn that `sudo DRB_ENROLLMENT_TOKEN=X bash` leaks the token the same way `--token` does. **Not in this PR:** the Server mint panel (`drb-frontend/app/settings/nodes/page.tsx:63`) still renders `--token ${justMinted}`, so it is filed in server-26. This PR does not depend on it: an old command still works, with a warning. **Verification:** `bash -n`. I also ran the argument-parsing section in a harness: file, argv, env, none, missing file and empty file all behave as intended. Not run end-to-end on a Pi. No Python touched. edge-node pytest: 287 passed, 9 skipped. flake8 is clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
logan added 1 commit 2026-10-04 18:10:06 -04:00
install.sh: enrollment token never on the command line (node-26#18)
CI / lint (push) Successful in 6s
CI / test-op25 (push) Successful in 14s
CI / lint (pull_request) Successful in 8s
CI / test (push) Successful in 48s
CI / test-op25 (pull_request) Successful in 15s
CI / test (pull_request) Successful in 49s
4dff9cbab6
The token is now prompted for on the TTY (hidden input), or read from
--token-file PATH / an exported DRB_ENROLLMENT_TOKEN for unattended installs.
--token still works for old copied commands but warns that it has landed in
shell history and ps. Every "re-run with --token DRB-..." hint now points at
the prompt; stale-pickup (401/404) re-runs prompt for a token instead of
dying. DRB_ENROLLMENT_TOKEN is unset after reading so children don't inherit
it. README install example drops --token.

Server half (mint panel still prints --token) is filed separately.

Refs #18

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
logan added 1 commit 2026-10-04 18:17:37 -04:00
Drop last --token hint; note sudo drops DRB_ENROLLMENT_TOKEN (node-26#18)
CI / lint (push) Successful in 8s
CI / test-op25 (push) Successful in 19s
CI / lint (pull_request) Successful in 8s
CI / test-op25 (pull_request) Successful in 18s
CI / test (push) Successful in 55s
CI / test (pull_request) Successful in 51s
c4b4cb92c9
- key_pickup.py still told operators to re-run install.sh with --token.
- `curl | sudo bash` resets the env, so the documented exported-token
  path needs `sudo --preserve-env=DRB_ENROLLMENT_TOKEN`; say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Review pass (adversarial): pushed c4b4cb9 onto this branch.

  • drb-edge-node/app/internal/key_pickup.py still logged "Re-run install.sh with --token to recover" — the one re-run hint the PR missed. Reworded.
  • The documented unattended path ("an exported DRB_ENROLLMENT_TOKEN") doesn't survive curl ... | sudo bash — sudo's env_reset drops it. --help and README now say sudo --preserve-env=DRB_ENROLLMENT_TOKEN.

Local: edge-node pytest 296 passed, 0 skipped (flock shim), flake8 clean. #30 and #31 still merge cleanly together.

🤖 Generated with Claude Code

Review pass (adversarial): pushed `c4b4cb9` onto this branch. - `drb-edge-node/app/internal/key_pickup.py` still logged "Re-run install.sh with --token to recover" — the one re-run hint the PR missed. Reworded. - The documented unattended path ("an exported `DRB_ENROLLMENT_TOKEN`") doesn't survive `curl ... | sudo bash` — sudo's env_reset drops it. `--help` and README now say `sudo --preserve-env=DRB_ENROLLMENT_TOKEN`. Local: edge-node pytest 296 passed, 0 skipped (flock shim), flake8 clean. #30 and #31 still merge cleanly together. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
logan added 1 commit 2026-10-04 18:26:14 -04:00
Merge branch 'main' into fix/18-install-token-argv
CI / lint (push) Successful in 10s
CI / test-op25 (push) Successful in 24s
CI / lint (pull_request) Successful in 7s
CI / test-op25 (pull_request) Successful in 20s
CI / test (push) Successful in 54s
CI / test (pull_request) Successful in 54s
dbb41f2fd3
logan merged commit 582bc407be into main 2026-10-04 18:28:19 -04:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: logan/node-26#30