Repository navigation
security: harden wallet credential temp files - #187
Conversation
872591a to
c537ea2
Compare
RonDeBanc
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Comment — solid security improvement, no blockers. 2 minor suggestions, 2 observations.
Reviewed the full diff in a local worktree at the PR head (c537ea2), ran bash -n on all four changed scripts and git diff --check — all clean. Verified no remaining /dev/shm/.pw or chmod 777 /dev/shm references.
Looks good
chmod 1777 /dev/shmrestores the sticky bit, which is also what makes the per-user temp-file model instart.service.shsound — other users can no longer unlink the credential file.- Per-invocation
mktempcredentials remove the predictable shared/dev/shm/.pwand the clobbering risk between concurrent runs. start.service.shfails closed on a missing$3(-f ""is false), and the owner/mode check viastat -c '%u:%a'is strict (rejects setuid bits etc.).- Quoting of
"$wallet"in the systemdExecStartline is a genuine improvement over the old unquoted expansion.
Suggestions (non-blocking)
- scripts/start.service.sh:15 — the allowlist glob accepts
/in the suffix, so path traversal technically passes the check (see inline comment). - scripts/start.service.sh:93 — log message still says "Shredding" but the code now uses
rm -f.
Observations (pre-existing, not introduced here)
- The
EXITtrap inpasswordToFilereplaces the one set bychooseWallet, so on the success path the$wallettemp file is no longer cleaned up at shell exit. The cancel/ESC paths alreadyrmit explicitly — consider adding"$wallet"to the trap for parity. - Dropping
shredforrmon tmpfs is fine in practice (shred's guarantees on tmpfs are weak anyway), just noting the threat-model change is intentional. - Manual two-argument invocations of
start.service.sh(as in older docs/muscle memory) now fail closed — worth a line in the docs if any reference the old usage.
Reviewed by Ron DeBanc (Hermes agent)
| exit 1 | ||
| fi | ||
| case "$passwordFile" in | ||
| /dev/shm/joininbox-wallet-password.*) ;; |
There was a problem hiding this comment.
Minor: in bash case patterns, * matches / too, so a path like /dev/shm/joininbox-wallet-password.x/../../../etc/something passes this allowlist (verified locally). The -f + owner/mode checks still gate it, and an attacker who can pass arbitrary args here already runs as the joinmarket user, so impact is negligible — but since this check exists for defense-in-depth, consider tightening it, e.g. mktemp's fixed 6-char suffix:
case "$passwordFile" in
/dev/shm/joininbox-wallet-password.??????) ;;or explicitly rejecting any value containing an extra / after the prefix.
| sleep 5 | ||
| # delete password once used | ||
| shred -uvz /dev/shm/.pw | ||
| rm -f -- "$passwordFile" |
There was a problem hiding this comment.
Nit: the echo above still says "Shredding the password once used..." but this now does rm -f. Suggest rewording to "Deleting" for accuracy.
| return 1 | ||
| } | ||
| chmod 600 -- "$data" "$walletPasswordFile" | ||
| trap 'rm -f -- "$data" "$walletPasswordFile"' EXIT |
There was a problem hiding this comment.
Observation (pre-existing): this EXIT trap replaces the one set in chooseWallet (trap 'rm -f "$wallet"' EXIT), so after a successful passwordToFile run the $wallet temp file is no longer removed when the menu shell exits. The cancel/ESC branches below already remove "$wallet" explicitly — consider including it here too for parity:
trap 'rm -f -- "$data" "$wallet" "$walletPasswordFile"' EXITRe-verified all findings against the current default branch (16fc83f): - all 9 original findings still present - new: eval-based argument parsing in install.joinmarket.sh (openoms#10) - new: root wildcard deletion in /dev/shm in menu.quickstart.sh (openoms#11) - minor: deprecated apt-key, builder-key import hygiene Map findings to implementation PRs openoms#187-openoms#190 with per-finding status. Add SECURITY.md with private vulnerability reporting, scope, supported-version policy, and coordinated disclosure.
|
All review suggestions applied in 586e547 (pushed to
Test evidence (stubbed
|
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 (openoms#10) - new: root wildcard deletion in /dev/shm in menu.quickstart.sh (openoms#11) - minor: deprecated apt-key, builder-key import hygiene Map findings to implementation PRs openoms#187-openoms#190 with per-finding status. Add SECURITY.md with private vulnerability reporting, scope, supported-version policy, and coordinated disclosure.
586e547 to
233fb44
Compare
RonDeBanc
left a comment
There was a problem hiding this comment.
Re-review of 233fb44bf — APPROVE
The follow-up addresses every point from my previous review:
- ✅ Password-file suffixes now reject empty names,
.., and/, so the allowed/dev/shm/joininbox-wallet-password.*prefix cannot be used for traversal or nested paths. - ✅ Wallet arguments are constrained to a plain filename directly below the fixed
$walletPath; traversal/nested paths are rejected. - ✅
passwordToFile's replacement EXIT trap now retains cleanup of the$wallettemporary file. - ✅ The cleanup message now accurately says "Deleting" rather than "Shredding" for tmpfs unlinking.
- ✅ The new three-argument
start.service.shcontract is documented at the script entry.
The original security improvements remain sound: sticky mode 1777 on /dev/shm, unpredictable per-run credential files, strict owner/mode checks, symlink rejection, quoted credential/wallet paths, and exact-file cleanup. All four current checks pass, including the full amd64 and arm64 image builds.
Integration note (non-blocking for this PR)
This overlaps heavily with #189 in start.service.sh and _functions*. When rebasing/merging, preserve #189's stronger service allowlist, canonical wallet validation, validate-before-password flow, failure propagation, and credential cleanup together with this PR's per-run password-file handling. The combined result should be re-reviewed rather than resolving the overlap mechanically.
Reviewed by Ron DeBanc (Hermes Agent)
233fb44 to
6381dae
Compare
|
Note: this branch is now stacked on #189 ( The rebase merged the two features in I could not switch the GitHub base of this PR to |
start.service.bats: password file validation in start.service.sh (missing, symlink, outside-path, traversal, bad-mode rejection; validation order; password over stdin, never in the unit; deleted after use). password-to-file.bats: passwordToFile creates an unpredictable per-run mode-600 file under /dev/shm, cleans up via EXIT trap and on cancel/ESC. test-bats.yml runs 'bats -r tests' on push/PR - new .bats files are discovered automatically. Suite verified locally: 12/12 pass.
b0887ac to
5a2cafd
Compare
On a tagless shallow checkout (CI) the version block's git describe exits 128; under bats errexit that aborted the source before the function definitions. '|| true' keeps the source errexit-immune. Verified locally from a non-git CWD: 12/12 pass.
|
Added a bats test suite covering this PR's credential-file handling, plus a bats CI workflow (9607b73): tests/start.service.bats (7 tests) — the password-file validation in
tests/password-to-file.bats (5 tests) —
CI: Verified locally (12/12) and now green in CI. Note this branch was rebased onto master after #188/#189 merged, so the PR diff is back to just the credential-hardening commits + tests. |
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 (openoms#10) - new: root wildcard deletion in /dev/shm in menu.quickstart.sh (openoms#11) - minor: deprecated apt-key, builder-key import hygiene Map findings to implementation PRs openoms#187-openoms#190 with per-finding status. Add SECURITY.md with private vulnerability reporting, scope, supported-version policy, and coordinated disclosure.
The staged hardening plan in SECURITY-HARDENING.md has been implemented through PRs openoms#187-openoms#195 (finding openoms#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: 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>
Summary
/dev/shminstead of changing it to mode0777/dev/shm/.pwwallet credential with an unpredictablemktempfileThis implements the temporary wallet credential recommendations from #186 without changing the JoinMarket password-stdin interface.
Security impact
The old global filename could be pre-created or replaced by another local user, and removing the sticky bit from
/dev/shmallowed users to remove each other's files. The new credential is created atomically with an unpredictable name, mode0600, checked immediately before use, and cleaned up through an EXIT trap and after service startup.Tests
bash -non all four changed shell scripts/dev/shm/.pworchmod 777 /dev/shmreferencesgit diff --check