Skip to content

fix: 9.5.0 audit hardening batch (config.txt, SSH lockout, state) - #11

Merged
extremeshok merged 1 commit into
masterfrom
fix/audit-9.5.0
Jun 13, 2026
Merged

fix: 9.5.0 audit hardening batch (config.txt, SSH lockout, state)#11
extremeshok merged 1 commit into
masterfrom
fix/audit-9.5.0

Conversation

@extremeshok

Copy link
Copy Markdown
Owner

Summary

Hardening release from a full multi-agent audit (43 confirmed findings):
2 critical, 14 high, plus medium/low fixes, safer defaults, and
de-duplication. Bumps to 9.5.0. Affected tasks bump their version so
corrected values re-apply on upgrade.

Critical

  • config.txt dtparam=NAME=value lines no longer clobber each other
    (was silently disabling stock audio/i2c/spi via --disable-leds etc.).
  • SSH-port detection reads the effective config via sshd -T (honours
    sshd_config.d drop-ins), so UFW can't lock out a custom-port host.

High

  • --force no longer wipes opt-in task markers; --diff/--dry-run no
    longer mutate state.json (re-run detection moved to value_changed hooks).
  • ipv6_disable undo works; boot_config replaces keys; usb_uas_quirks
    merges the quirks token; tailscale uses ensure_packages.
  • var_log_tmpfs journal archive is now 0600 under /var/backups.
  • snapshot excludes config-optimisations.json like state.json.
  • TUI keeps zstd, runs value-typed tasks from the Values menu, and stops
    dropping default-enabled tasks in unvisited categories.

Changed (safer defaults — please review)

  • IP forwarding no longer enabled by default (sysctl).
  • Raspberry Pi Connect no longer purged (remove_bloat).
  • rsyslog no longer disabled (disable_services) — volatile journald +
    tmpfs /var/log otherwise left no persistent log after reboot.

Refactor / CI

  • Shared apply_config_entries / pi_curl_secure / write_systemd_unit
    helpers; run and --diff share one entry source per task;
    oc_conservative/underclock use a per-model table; dead code removed.
  • Release fails if tag/SCRIPT_VERSION/man footer disagree; ShellCheck +
    bash -n cover the test harness and stubs; integration matrix now runs
    on Trixie and Bookworm; stub invocation log is exercised.

Test plan

  • bash -n on all shell files (main, lib, install, tests, stubs)
  • shellcheck --severity=warning clean across the same set
  • --version / --help / --list-tasks (54 tasks)
  • scripts/build-bundle.sh builds; standalone --version = 9.5.0
  • Docker integration harness: 65/65 PASS on Debian Trixie
  • Docker integration harness: PASS on Debian Bookworm (new matrix)
  • Targeted unit tests for dtparam keying, boot_config replace,
    cmdline merge, libliftoff, overclock plan, write_systemd_unit
  • Version consistent across SCRIPT_VERSION / header / man footer

Deferred (documented)

  • main() decomposition and a package-bundle task registry (refactor-only,
    high churn / low ROI).
  • A concurrent state.json locking test (couldn't make deterministic
    without flakiness; shipped the stub-log test instead).

Resolves a full multi-agent audit: 2 critical, 14 high, plus medium/low
fixes and de-duplication. Affected tasks bump their version so corrected
values re-apply on upgrade.

Critical:
- ensure_config_key_value keyed every dtparam=NAME=value line on the bare
  word "dtparam", so writing one wiped unrelated stock dtparam lines
  (audio/i2c/spi). dtparam/dtoverlay are now keyed by parameter name.
- SSH-port detection reads the effective config via `sshd -T`, honouring
  sshd_config.d drop-ins, so UFW no longer opens 22 while sshd listens on
  a custom port and drops the operator's session.

High:
- --force no longer wipes completion markers of opt-in tasks not
  re-requested; --diff/--dry-run no longer mutate state.json (proxy/ufw
  re-run detection moved to dry-run-safe value_changed hooks).
- ipv6_disable records the file it creates so --undo reverses it.
- boot_config replaces existing keys instead of appending duplicates.
- usb_uas_quirks merges the usb-storage.quirks token instead of appending.
- tailscale installs via ensure_packages (dpkg-lock wait).
- var_log_tmpfs journal archive is 0600 under /var/backups (was
  world-readable in /var/log).
- snapshot excludes config-optimisations.json like state.json.
- TUI keeps a non-default zram algo, runs value-typed tasks set in the
  Values menu, and no longer drops default-enabled tasks in unvisited
  categories.

Safer defaults (review):
- IP forwarding no longer enabled by default in sysctl.
- remove_bloat no longer purges Raspberry Pi Connect.
- disable_services no longer disables rsyslog (volatile journald + tmpfs
  /var/log otherwise left no persistent log after reboot).

Other correctness: dns_cache backs up resolv.conf before repointing;
eeprom_config records its backup + revert command; config.yaml zram.algo
validated; Compute Module 4/5 mapped to their Pi generation; --diff no
longer launches the TUI (menu-skip flags derived from the task registry);
pi_rollback_release resolves paths before comparing; libliftoff stops
uncommenting disabled overlays and collapses duplicate KMS lines;
install.sh distinguishes a 404 ref from a network error.

Refactor: shared apply_config_entries / pi_curl_secure / write_systemd_unit
helpers; run and --diff share one entry source per task; oc_conservative
and underclock use a per-model table; removed dead validate_timezone,
is_pi500, fstab_root_has_option; pi_daemon_reload_now now has callers;
implemented pi_supports_eeprom; inline list-unit-files replaced with
unit_exists.

CI/tests: release fails if tag, SCRIPT_VERSION and man footer disagree;
ShellCheck/bash -n cover the test harness and stubs; integration matrix
runs against Trixie and Bookworm; stub invocation log is now exercised;
bundle shebang-parity gate actually checks the shebang.
@extremeshok
extremeshok merged commit f74a35c into master Jun 13, 2026
3 checks passed
@extremeshok
extremeshok deleted the fix/audit-9.5.0 branch June 13, 2026 12:20
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.

1 participant