Skip to content

security: remove root wildcard deletion in /dev/shm - #191

Merged
openoms merged 2 commits into
openoms:masterfrom
autoblitzbot:hardening/quickstart-tmp-cleanup
Aug 16, 2026
Merged

openoms merged 2 commits into
openoms:masterfrom
autoblitzbot:hardening/quickstart-tmp-cleanup

Conversation

@autoblitzbot

Copy link
Copy Markdown
Contributor

Summary

Fixes security finding #11 from the hardening plan (SECURITY-HARDENING.md, see PR #186).

scripts/menu.quickstart.sh ran sudo rm -f /dev/shm/* as root after displaying wallet data. /dev/shm is a world-writable shared tmpfs, so a root wildcard deletion there can:

  • delete other processes' files in /dev/shm (e.g. /dev/shm/.pw written by _functions.sh during password entry, temp files of concurrently running menus, or unrelated processes)
  • is race-prone (TOCTOU between glob expansion and deletion in a world-writable directory)
  • requires unnecessary root privileges — the temp files are created by mktemp as the calling joinmarket user, so no sudo is needed to remove them

What changed

scripts/menu.quickstart.sh (cacheAndShowQR):

  • Removed sudo rm -f /dev/shm/*
  • After the existing shred call (kept as-is; note shred does not delete files by default and overwriting is unreliable on tmpfs anyway), the script now deletes only the exact temp files it created/used with plain rm -f:
    • $walletData (its own mktemp -p /dev/shm/ file)
    • $wallet (the mktemp -p /dev/shm/ file from chooseWallet, previously only cleaned by the root glob or the EXIT trap)
    • $mixdepth (guarded with [ -n ... ] since it is unset in this flow)
  • No sudo — all removed files are owned by the calling user

Test plan

  • bash -n scripts/menu.quickstart.sh → OK (syntax clean)
  • shellcheck is not installed on the authoring host; the change only adds quoted rm -f calls and introduces no new unquoted expansions (the pre-existing shred $wallet $mixdepth $walletData line is untouched)
  • Functional smoke test replicating the cleanup block in a scratch dir:
    • two mktemp files simulating $wallet/$walletData → deleted
    • an unrelated other_process_file in the same directory → survives (previously it would have been removed by the root glob)

Follow-ups (not changed in this PR)

Other root wildcard deletions exist elsewhere in the repo. They are in root-owned (not world-writable) directories so they are lower risk than /dev/shm, but still worth tightening in separate PRs:

  • scripts/standalone/prepare.release.sh:17 — sudo rm /etc/ssh/ssh_host_*
  • ci/amd64/debian/scripts/joininbox.sh:10 — sudo rm /etc/ssh/ssh_host_*
  • scripts/jam-remote/install.jam.sh:169-170 — sudo rm -f /etc/nginx/sites-{enabled,available}/jam*

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

Small, correct, and exactly matches finding #11's acceptance criteria: the script now unlinks precisely the three mktemp files it created ($walletData, $wallet, and $mixdepth when set) and the root wildcard delete in the world-writable /dev/shm is gone. Dropping sudo is right too — the files are owned by the calling user.

Nits (non-blocking, pre-existing): shred $wallet $mixdepth $walletData a few lines up is unquoted, and shred -u could fold the overwrite+unlink into one step. Fine as-is.


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/quickstart-tmp-cleanup branch from 7d2e64e to f48196d 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.
@autoblitzbot
autoblitzbot force-pushed the hardening/quickstart-tmp-cleanup branch from f48196d to d3a8329 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 — APPROVE

Re-checked current head a81787412, including the scoped-cleanup Bats tests, on a combined master + #190–#194 + #198 integration tree. The merge is conflict-free and the complete relevant test suite remains green.

The change still satisfies the security contract: quickstart cleanup removes only the exact temporary files created by the flow and no longer performs a root wildcard deletion in shared /dev/shm.

All current GitHub checks pass: ShellCheck, Bats, spelling, amd64 image build and arm64 image build. LGTM.


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)

@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 c40ad1b 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