Skip to content

presets: remove the no-op hardened preset - #182

Merged
seberm merged 1 commit into
bitcoinix:masterfrom
sebsgent:presets-remove-hardened
Nov 1, 2026
Merged

seberm merged 1 commit into
bitcoinix:masterfrom
sebsgent:presets-remove-hardened

Conversation

@sebsgent

Copy link
Copy Markdown
Contributor

Fixes #177.

modules/presets/hardened.nix imported the NixOS hardened profile, which 26.05 removed along with linux_hardened. Every bitcoinix release (v0.1.0–v0.1.3) is on 26.05, so the preset has never hardened anything here: its two remaining lines (allowUserNamespaces = true, libc allocator) are NixOS defaults.

Correction to the issue: hardened-extended.nix is not a no-op. Its own sysctls, kernel params, module blacklist and usbguard still apply; it only lost the profile underneath.

Plan / changes

  • hardened.nix → stub with a failing assertion: remove the import, see hardened-extended.nix or the NixOS Hardening wiki. A stub instead of deleting gives a clear message rather than a missing-path error, and an assertion (not throw) stays inert under disabledModules.
  • hardened-extended.nix: drop the import, fix the header comment.
  • examples/configuration.nix: drop the default import and the "~50% performance" note; hardened-extended stays commented out, so new installs are unchanged.
  • examples/qemu-vm/vm-config.nix: drop the now-pointless disabledModules.
  • README.md: link the hardened-extended preset instead of promising a hardened kernel.
  • Keep the hardened test scenario: it still covers hardened-extended.
  • Release notes for 0.1.4: users who copied the example config will hit the stub's error; hardened-extended users get no change.

No versioning.nix entry, on purpose. The stub's assertion always fires, so an entry gated by configVersion would never be reached and would add nothing. hardened-extended users need no action.

Tested

  • hardened scenario: VM drvPath identical to master (9dhpvi3n…), so no change for hardened-extended users.
  • A config importing the stub fails with the message. With the stub in disabledModules, the message doesn't appear.
  • nix flake check --all-systems passes.
  • Not run locally: VM tests, examples, deploymentExamples (none of them import the preset).

Follow-up (not in this PR)

hardened-extended sets module.sig_enforce=1 and lockdown=confidentiality. Whether these block module loading or do nothing on the stock NixOS kernel is unchecked. Worth verifying before recommending the preset more prominently.

Assisted-by: Claude Code (claude-opus-5-5)

@github-actions github-actions Bot added area: docs docs/, README, examples/, SECURITY.md, book.toml, assets area: modules modules/ and pkgs/lib.nix labels Oct 29, 2026
@seberm
seberm marked this pull request as ready for review October 29, 2026 22:16

@ostermayer ostermayer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks right to me. The stub with the failing assertion is a better landing than a missing file, and I found no other reference to presets/hardened.nix left in the tree, docs included. The hardened test scenario still imports hardened-extended.nix, so that preset stays covered.

DeepSeek V4.1 Flash 1017 (max) and GLM 5.3 (max) audited the tree at c6319c0 with Codex (GPT-6 Astra, xhigh) as the second opinion: nine findings, none in the five files this PR touches. They're all known (#87, #107, #133, #64, #127, #86) or leads I still have to file, like the WireGuard preset turning tor.enforce off for lnd and clightning.

NixOS 26.05 removed profiles/hardened.nix and the linux_hardened
kernel. modules/presets/hardened.nix imported that profile, so on every
bitcoinix release it only set two options to their NixOS defaults and
gave no hardening at all.

Replace it with a stub whose assertion tells users to drop the import
and points to hardened-extended.nix and the NixOS Hardening wiki. A
stub gives a clear message instead of a missing-path error and stays
inert under disabledModules.

hardened-extended.nix keeps its own settings and no longer imports the
stub; its evaluated system is unchanged. Drop the preset from
examples/configuration.nix and the qemu-vm example, and stop promising
a hardened kernel in the README.

Fixes bitcoinix#177

Assisted-by: Claude Code (claude-opus-5-5)
@seberm
seberm force-pushed the presets-remove-hardened branch from c6319c0 to 93ff7e8 Compare November 1, 2026 14:33
@seberm seberm added the type: removal Module, package or option dropped (implies breaking) label Nov 1, 2026
@seberm
seberm merged commit 304167c into bitcoinix:master Nov 1, 2026
11 checks passed
seberm added a commit that referenced this pull request Nov 1, 2026
The stock NixOS kernel (6.18 and 7.3, x86_64 and aarch64) is built
without CONFIG_MODULE_SIG and CONFIG_SECURITY_LOCKDOWN_LSM, so it
ignores the module.sig_enforce=1 and lockdown=confidentiality
parameters set by hardened-extended. The preset suggested protection
that wasn't there.

Drop both and leave a comment saying why, so they don't get re-added
from madaidan's guide. Nothing changes on the stock kernel. Users of a
custom kernel with module signing or lockdown who relied on the preset
need to set these parameters in boot.kernelParams themselves. NixOS
doesn't sign its modules, so sig_enforce=1 would block every module on
such a kernel.

Follow-up to #182
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: docs docs/, README, examples/, SECURITY.md, book.toml, assets area: modules modules/ and pkgs/lib.nix type: removal Module, package or option dropped (implies breaking)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hardened preset is a no-op on NixOS 26.05 (profile and linux_hardened removed from nixpkgs)

3 participants