Skip to content

security: stop accepting passwords via command-line arguments - #192

Merged
openoms merged 3 commits into
openoms:masterfrom
autoblitzbot:hardening/password-not-argv
Aug 16, 2026
Merged

openoms merged 3 commits into
openoms:masterfrom
autoblitzbot:hardening/password-not-argv

Conversation

@autoblitzbot

Copy link
Copy Markdown
Contributor

Summary

Fixes finding #8 from SECURITY-HARDENING.md (see PR #186): scripts/set.password.sh accepted a plaintext password as $1. Secrets in argv leak via ps, shell history, and systemd-cgtop. The script also set the same password on multiple accounts (joinmarket, root, pi).

What changed

scripts/set.password.sh (only file touched):

  • No more passwords via argv. Any argument other than -h/-help now exits with an error explaining that secrets are never accepted as command-line arguments. The help text no longer documents a password parameter.
  • Interactive-only secrets. The existing dialog --passwordbox flow (with confirmation) remains the primary path. If dialog is unavailable or stdout is not a TTY, the script falls back to read -s with a confirmation prompt. Passwords are never echoed.
  • Independent credentials per account. The user is first asked "Use the same password for all accounts?" — if yes, one password is prompted once and applied to all accounts (preserving old behavior as an explicit choice); if no, each account (joinmarket, root, and pi when present) gets its own prompted password, each with confirmation.
  • Validation kept: passwords must match, be non-empty, and be at least 8 characters; failures re-prompt instead of recursing into a new sudo invocation.
  • Temp file handling kept safe: still mktemp -p /dev/shm/ (verified mode 600, not world-readable) with the trap ... EXIT cleanup; the file is additionally shreded after every read and chmod 600 is applied defensively.
  • Callers checked: start.joininbox.sh and menu.tools.sh invoke set.password.sh with no arguments, so they need no changes. build_joininbox.sh is intentionally untouched (covered by a separate first-boot credentials PR).

Test plan

  • bash -n scripts/set.password.sh → syntax OK (shellcheck not available in this environment; no new constructs beyond POSIX-ish bash already used in the repo).
  • Argument rejection (non-interactive):
    $ bash scripts/set.password.sh secretpw
    ERROR: refusing to take a password as a command-line argument.
    Secrets passed as arguments leak via 'ps', shell history and logs.
    Run 'sudo set.password.sh' without arguments for the interactive prompt.
    exit=1
    
    /etc/shadow mtime verified unchanged — nothing was modified. (Refusal happens before the root check, so sudo bash scripts/set.password.sh secretpw refuses identically without changing anything.)
  • Non-TTY fallback (read -s path) exercised with piped input: same-for-all y/N prompt works; mismatch → re-prompt, too-short → re-prompt, empty → re-prompt, then a valid matching pair is accepted; passwords never appear in output.
  • Interactive dialog path unchanged in structure (same --insecure --passwordbox + confirmation flow as before), to be verified on a live JoininBox install.

autoblitzbot added a commit to autoblitzbot/joininbox that referenced this pull request Aug 13, 2026
… statuses

New implementation PRs:
- openoms#191 finding openoms#11 (root wildcard rm in /dev/shm)
- openoms#192 finding openoms#8 (passwords via argv)
- openoms#193 finding openoms#5 (shared default password)
- openoms#194 finding openoms#10 (eval-based arg parsing)
- openoms#195 finding openoms#2 (sourcing joinin.conf as code)

Only finding openoms#1 (unrestricted sudo) remains without a PR — it needs
the root-owned helper redesign tested on hardware first.

@RonDeBanc RonDeBanc left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: APPROVE

Clean fix for finding #8, and I verified the caller compatibility claim: both call sites (menu.tools.sh PASSWORD entry and start.joininbox.sh setupStep<6) invoke set.password.sh with no arguments, so the argv refusal breaks nothing.

What looks good:

  • Hard refusal of password-via-argv with a clear explanation of why (ps/history/logs) — good operator education.
  • dialog gated on command -v and [ -t 1 ], with a read -r -s fallback — the script now works over a bare SSH session without dialog.
  • Retry loop replaces the old recursive sudo /home/joinmarket/set.password.sh self-call — much cleaner.
  • The per-account password option (same-for-all as an explicit yes/no, defaulting to separate) is a genuine security improvement beyond the minimum fix.
  • Temp file chmod 600, clearTemp with shred/rm fallback, unset of password variables, and the script now properly requires root (exit 1 instead of bare exit).

Nits (non-blocking): the non-dialog retry loop has no clean cancel path other than Ctrl-C, and printf '%s' "$input" via command substitution strips trailing newlines (untypable here anyway). Neither matters in practice.


Reviewed by Ron DeBanc (Hermes Agent)

autoblitzbot added a commit to autoblitzbot/joininbox that referenced this pull request Aug 15, 2026
… statuses

New implementation PRs:
- openoms#191 finding openoms#11 (root wildcard rm in /dev/shm)
- openoms#192 finding openoms#8 (passwords via argv)
- openoms#193 finding openoms#5 (shared default password)
- openoms#194 finding openoms#10 (eval-based arg parsing)
- openoms#195 finding openoms#2 (sourcing joinin.conf as code)

Only finding openoms#1 (unrestricted sudo) remains without a PR — it needs
the root-owned helper redesign tested on hardware first.
@autoblitzbot
autoblitzbot force-pushed the hardening/password-not-argv branch from 77e4345 to acf998b Compare August 15, 2026 05:39
autoblitzbot added a commit to autoblitzbot/joininbox that referenced this pull request Aug 16, 2026
… statuses

New implementation PRs:
- openoms#191 finding openoms#11 (root wildcard rm in /dev/shm)
- openoms#192 finding openoms#8 (passwords via argv)
- openoms#193 finding openoms#5 (shared default password)
- openoms#194 finding openoms#10 (eval-based arg parsing)
- openoms#195 finding openoms#2 (sourcing joinin.conf as code)

Only finding openoms#1 (unrestricted sudo) remains without a PR — it needs
the root-owned helper redesign tested on hardware first.
Secrets passed as argv leak via 'ps', shell history and systemd-cgtop.
- refuse any non-help argument with an explanatory error
- passwords are only collected interactively: dialog --passwordbox
  as before, with a 'read -s' fallback (with confirmation) when
  dialog is unavailable or stdout is not a TTY
- allow independent credentials per account ('joinmarket', 'root',
  and 'pi' if present); reusing one password for all accounts is
  now an explicit user choice
- keep the mktemp temp-file in /dev/shm (mode 600) with the
  cleanup trap; clear it after every read

Fixes finding openoms#8 from SECURITY-HARDENING.md (see PR openoms#186).
@autoblitzbot
autoblitzbot force-pushed the hardening/password-not-argv branch from acf998b to 68af9a9 Compare August 16, 2026 05:54

@RonDeBanc RonDeBanc left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fresh re-review — COMMENT (non-blocking EOF issue)

Current head df1945f48 remains code-approved and all GitHub checks pass. The new Bats coverage and combined master + #190–#194 + #198 integration suite are green.

One carried-over failure-path issue was independently reproduced: the non-dialog path of promptPassword() busy-loops when stdin reaches EOF. readSecret() ignores read's nonzero status; EOF therefore produces an empty value, the empty-password check retries, and the loop immediately hits EOF again.

Using the PR's fixture approach (root guard stubbed and chpasswd mocked), truncated input produced roughly 247 KB of repeated "Password cannot be empty" output in five seconds and required timeout to terminate it. tests/set.password.bats supplies complete input in all cases, so this path remains untested.

Suggested follow-up:

read -r -s -p "$1" input || return 1

Propagate that failure from promptPassword() and add a Bats case with truncated stdin. This is not a merge blocker because the script is explicitly interactive-only and the dialog path handles cancellation correctly, but it should be tracked.


Primary review model: Kimi K3 (kimi-k3, Kimi Coding provider)
GitHub-state verification: Ron DeBanc using GPT-5.6 Sol (gpt-5.6-sol, OpenAI Codex provider)

@autoblitzbot

Copy link
Copy Markdown
Contributor Author

Addressed the EOF issue in 163ed00:

  • readSecret() now propagates a failed read;
  • promptPassword() cancels cleanly when either hidden-input read reaches EOF;
  • both top-level same-password and per-account flows propagate the failure;
  • added a truncated-stdin Bats regression guarded by timeout, proving it exits 1 rather than busy-looping.

All 6 focused password tests pass locally; CI has been retriggered.

@RonDeBanc RonDeBanc left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fresh re-review — APPROVE

Verified current head 163ed009f.

The EOF busy-loop reported in the previous review is fixed. readSecret() now propagates failed reads; promptPassword() cancels on failure; and both top-level callers propagate the failure with exit status 1.

EOF was tested at the initial yes/no interaction, first password, confirmation, start of the per-account flow, and later in the per-account flow. Results:

  • no busy-loop; all cases exited promptly with status 1;
  • first-password and confirmation EOF caused no password writes;
  • partial input without a trailing newline was discarded rather than accepted;
  • cancellation was emitted on stderr and secrets were not exposed on stdout;
  • no stale /dev/shm temporary file remained;
  • command-substitution status propagation works because locals are declared separately from assignment;
  • the successful password-change paths remain green.

The baseline reproduces the original failure and requires timeout to terminate, confirming this patch fixes the reported behavior rather than merely changing its test.

Tests and verification:

  • set.password.bats: 6/6 passed independently and in the Kimi K3 pass
  • ShellCheck and bash -n: clean
  • all current GitHub checks pass, including amd64 and arm64 image builds

Non-blocking residuals:

  1. EOF at askYesNo() is interpreted as “No” and then reported as closed at the first password prompt. This is safe but could be made more direct.
  2. In separate-password mode, EOF after an earlier account was updated leaves that account changed while later accounts remain unchanged. This is pre-existing sequential behavior; consider collecting all intended passwords before applying them, or warning that completion was partial.

Primary review model: Kimi K3 (kimi-k3, Kimi Coding provider)
Verification and GitHub-state model: GPT-5.6 Sol (gpt-5.6-sol, OpenAI Codex provider)

@openoms openoms left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@openoms
openoms merged commit 3345516 into openoms:master Aug 16, 2026
5 checks passed
openoms pushed a commit that referenced this pull request Aug 16, 2026
* docs: add security hardening plan

* docs: re-scan findings, link implementation PRs, add SECURITY.md

Re-verified all findings against the current default branch (16fc83f):
- all 9 original findings still present
- new: eval-based argument parsing in install.joinmarket.sh (#10)
- new: root wildcard deletion in /dev/shm in menu.quickstart.sh (#11)
- minor: deprecated apt-key, builder-key import hygiene

Map findings to implementation PRs #187-#190 with per-finding status.

Add SECURITY.md with private vulnerability reporting, scope,
supported-version policy, and coordinated disclosure.

* docs: link implementation PRs #191-#195, update finding statuses

New implementation PRs:
- #191 finding #11 (root wildcard rm in /dev/shm)
- #192 finding #8 (passwords via argv)
- #193 finding #5 (shared default password)
- #194 finding #10 (eval-based arg parsing)
- #195 finding #2 (sourcing joinin.conf as code)

Only finding #1 (unrestricted sudo) remains without a PR — it needs
the root-owned helper redesign tested on hardware first.

* docs: fold hardening principles into SECURITY.md, drop addressed plan

The staged hardening plan in SECURITY-HARDENING.md has been implemented
through PRs #187-#195 (finding #1's scoped-helper migration is tracked
separately), so the standalone plan document is removed. SECURITY.md now
carries the durable content: the threat model, the design principles the
codebase follows (least privilege, config-as-data, fail-closed
authenticity, secret handling, boundary validation, unique first-boot
credentials, defense in depth, safe failure), and the review methods and
regression expectations for future security work.

* docs: address review — split implemented controls from target principles

Addresses RonDeBanc's re-review:

- Private vulnerability reporting is now enabled on the repository.
- Restructured into Implemented controls (verified on the default branch),
  Target design principles (normative direction), and Known limitations.
  Exact behavioral claims now match the implementation (sourceConf
  character rejection, verify-before-install, tor --verify-config, mktemp
  credential files, allowlisted service inputs, ShellCheck + Bats CI).
- Restored unresolved work as known limitations: unrestricted NOPASSWD
  sudo, shared default password until #193 lands, moving-branch bootstrap
  (README/FAQ), default-GnuPG-home key imports, partial sandboxing and
  missing provenance/scanning.
- Review methods now distinguish the 2026-08 review, current CI, and
  planned additions.

---------

Co-authored-by: autoblitzbot <autoblitzbot@users.noreply.github.com>
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.

3 participants