Skip to content

security: replace eval-based argument parsing in installer - #194

Merged
openoms merged 2 commits into
openoms:masterfrom
autoblitzbot:hardening/install-arg-parsing
Aug 16, 2026
Merged

openoms merged 2 commits into
openoms:masterfrom
autoblitzbot:hardening/install-arg-parsing

Conversation

@autoblitzbot

@autoblitzbot autoblitzbot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes finding #10 from the security hardening plan (SECURITY-HARDENING.md, see PR #186): scripts/install.joinmarket.sh used eval for CLI argument parsing.

  • assign_value() ran eval "${1}"="\"${value}\"" — a crafted option value like --install '$(id)' executed arbitrary shell commands.
  • range_argument() ran eval var='$'"${1}" on the variable name — a crafted name also executed arbitrary shell.

This is particularly dangerous because the script performs privileged (sudo) operations.

What changed

  • assign_value(): validates the target variable name against ^[a-zA-Z_][a-zA-Z0-9_]*$] (rejects otherwise via error_msg), rejects values containing shell metacharacters (; & | `` `$` `<` `>`), then assigns safely with `printf -v "$name" '%s' "$value"` — no `eval`, no interpretation of the value.
  • range_argument(): validates the name the same way, then reads via indirect expansion ${!name} instead of eval.
  • New helpers valid_var_name() / reject_shell_syntax() fail closed with a clear error_msg.
  • CLI interface and behavior for legitimate inputs are unchanged (dash-stripping, 0/1 → false/true mapping, range validation, defaults all preserved). Calls happen at top level, so printf -v assigns globals exactly as eval did.

Other eval usage in the repo: grep -rn 'eval ' finds no other eval on caller-controlled input — this was the only file (left untouched per PR scope: SECURITY-HARDENING.md / SECURITY.md not modified).

Test plan

bash -n passes. A throwaway harness (in /tmp, not committed) sources the patched helpers and ran 15 checks, all passing:

  • Legitimate inputs still work: assign_value install update, 0/1 → false/true mapping, dash-stripping (--bob → bob), get_arg version -v v0.9.12, range_argument accepts valid / rejects invalid values, indirect read ${!name} correct.
  • Malicious inputs fail closed with no code execution (verified no side-effect file created):
    • names: x;touch /tmp/pwned, a$(touch /tmp/pwned)
    • values: $(touch /tmp/pwned), `touch /tmp/pwned`, a$(reboot); touch /tmp/pwned, x;touch /tmp/pwned
  • End-to-end through the real CLI parse loop:
    • --install '$(touch /tmp/pwned)' → Invalid characters in: '$(touch /tmp/pwned)', no file created
    • --install=update --qtgui=1 --user=bob → parses and proceeds normally
    • --install bogus → Option '--install' cannot be 'bogus'! It can only be: install config update testPR commit.

shellcheck is not installed in this environment; no new constructs were introduced that change existing warning classes.

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

Textbook remediation of finding #10:

  • valid_var_name gates every dynamic name against ^[a-zA-Z_][a-zA-Z0-9_]*$ before use.
  • printf -v "${1}" '%s' "${value}" replaces eval for writes; ${!name} replaces eval var='$'… for reads. No user-controlled string is ever re-parsed as code.
  • reject_shell_syntax fails closed on [;&|$\<>]` in values — appropriate for this installer's value domain (versions, booleans, paths, hostnames), and the error names the offending input.

I traced the value shapes flowing through assign_value/range_argument (qtgui 0/1/true/false, version strings, user names) — none legitimately contain the rejected characters, so this hardens without breaking the supported install matrix.

Suggestion (non-blocking): add a case to the shellcheck/CI matrix that exercises the installer with hostile args (e.g. --version 'v0.9.11$(touch /tmp/x)') and asserts no file appears — cheap regression test proving the eval is really gone.


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/install-arg-parsing branch from 6879575 to a2ed78f 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/install-arg-parsing branch from a2ed78f to 6b04ddb 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 c37577b80, including the hardened installer argument-parsing Bats suite, on a combined master + #190–#194 + #198 integration tree. The merge is conflict-free and the complete relevant test suite remains green.

The security boundary remains correct: dynamic variable names are validated, writes use printf -v, reads use indirect expansion, and user-controlled values are never passed through eval or re-parsed as shell code.

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 9bc2707 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