Skip to content

presets/hardened-extended: drop module.sig_enforce and lockdown - #184

Merged
seberm merged 1 commit into
bitcoinix:masterfrom
sebsgent:hardened-extended-noop-params
Nov 1, 2026
Merged

seberm merged 1 commit into
bitcoinix:masterfrom
sebsgent:hardened-extended-noop-params

Conversation

@sebsgent

Copy link
Copy Markdown
Contributor

Follow-up to #182. Independent of it: different lines of the same file.

hardened-extended sets module.sig_enforce=1 and lockdown=confidentiality. The stock NixOS kernel in the pinned nixpkgs is built without either feature, so the kernel ignores both:

kernel CONFIG_MODULE_SIG CONFIG_SECURITY_LOCKDOWN_LSM
linuxPackages 6.18.59 (x86_64, aarch64) not set not set
linuxPackages_latest 7.3 (x86_64, aarch64) not set not set

The sig_enforce module param only exists with CONFIG_MODULE_SIG, and lockdown= is parsed by the lockdown LSM. NixOS doesn't sign its modules either, so on a custom kernel with MODULE_SIG enabled, sig_enforce=1 would block every module instead of hardening anything. A comment in the preset says why the params are missing, so they don't get re-added from madaidan's guide.

Not done: security.lockKernelModules as a replacement. It would break netns-isolation, which needs veth/bridge modules after boot.

No versioning.nix entry: nothing changes on the stock kernel. Release note for 0.1.4: users of a custom kernel with module signing or lockdown who relied on the preset to set these params should set them in boot.kernelParams themselves.

Tested

  • hardened scenario: boot.kernelParams differs from master by exactly these two entries.
  • nix flake check --all-systems passes.
  • No VM test run.

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

@github-actions github-actions Bot added the area: modules modules/ and pkgs/lib.nix label Oct 29, 2026
@seberm
seberm marked this pull request as ready for review October 29, 2026 22:40

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

Checked the premise on a stock NixOS 6.18.57 kernel: /proc/config.gz has CONFIG_MODULE_SIG and CONFIG_SECURITY_LOCKDOWN_LSM both unset, so the two parameters really were dead. Dropping them with a comment that says why is the right move. Looks good to me.

DeepSeek V4.1 Flash 1017 (max) and GLM 5.3 (max) audited the tree at d16d1a7 with Codex (GPT-6 Astra, xhigh) as the second opinion: six findings, none in this file. Known ones are #133 (twice) and #86. Astra marked the BTCPay rune claim a false positive. Three low leads are new and I'll check them against the tracker: the WireGuard preset's firewall assertion has the package gap #175 closed for netns, services.clightning.wallet puts a Postgres DSN with its password into the store, and RTL's login lockout over the default onion is keyed on Tor's loopback address, so one client can lock the admin out.

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 the
kernel ignores both parameters. Keeping them suggests protection that
isn't there.

Assisted-by: Claude Code (claude-opus-5-5)
@seberm
seberm force-pushed the hardened-extended-noop-params branch from d16d1a7 to 2567f5d Compare November 1, 2026 20:30
@seberm
seberm enabled auto-merge November 1, 2026 20:31
@seberm
seberm merged commit 294200d into bitcoinix:master Nov 1, 2026
11 checks passed
prusnak added a commit that referenced this pull request Nov 10, 2026
…ded (#188)

The WireGuard preset binds the REST ports of the enabled `*connect`
helpers to 0.0.0.0 and guards them, and `restrictPeer`, only through
`networking.firewall.extraCommands`. Its assertion required the iptables
backend, but some layouts pass that check and still end with no
firewall. This is the same kind of gap #175 closed for netns-isolation.

What changed, one commit on current master:

- **Package check.** `networking.firewall.package` defaults to
`pkgs.nftables` whenever `networking.nftables` is enabled, whatever the
backend says. The firewall service then has no `iptables` binary and
fails at its first rule. The assertion now rejects the nftables package
unless `networking.firewall.extraPackages` holds iptables, which the
service also puts on its PATH.
- **flushRuleset check.** `pkgs.iptables` is iptables-nft, so the rules
live in the nftables ruleset. With `networking.nftables.flushRuleset`,
every start or reload of `nftables.service` runs `flush ruleset` and
deletes them while `firewall.service` stays active. NixOS turns it on by
default when `ruleset` or `rulesetFile` is set or `system.stateVersion`
is older than 23.11. A separate assertion rejects it and points to
`networking.nftables.tables` with `flushRuleset = false`.
- **Table name check.** `nftables.service` deletes and recreates every
table in `networking.nftables.tables`. A table named `filter` in the
`ip` or `ip6` family is the one iptables-nft keeps `nixos-fw` in, so
that's rejected too. `inet filter` still passes. Raw `flush` or `delete`
lines in `ruleset`, `rulesetFile` or `extraDeletions` aren't checked.
- The messages say to restart `firewall.service` once after a fix, since
the first nftables reload still runs the old deletions file.
- `docs/services.md` lists the preset's firewall requirements in the
WireGuard setup step.
- Configuration checks: nftables with the iptables backend fails, the
iptables package or `extraPackages` passes, `ruleset` set fails,
`system.stateVersion = lib.mkForce "23.05"` fails, tables only passes,
an `ip filter` table fails.

## Tested

- `module-config` on my KVM host on top of master: 67 tests pass. With
master's preset and the new tests, the four rejection tests fail. With
the previous PR head's preset, the `ruleset` and `stateVersion` tests
fail.
- In the pinned nixpkgs, `nftables.nix` sets the `flushRuleset` default
to `mkDefault (versionOlder stateVersion "23.11" || rulesetFile != null
|| ruleset != "")`, and recreates each table in `tables` on reload.
- The `wireguard-lndconnect` VM scenario passes.

DeepSeek V4.1 Flash 1017 (max) found the package gap in the gate runs on
#170 and #184 and Codex (GPT-6 Astra, xhigh) confirmed it both times.
@sebsgent found the flushRuleset hole. Claude Opus 5.5 wrote this
version. Codex (GPT-5.6 Sol, xhigh) reviewed it in two passes and found
two real issues: the `ip filter` table clash, and that the first reload
after a fix still applies the old deletions. Both are in. Its point that
any package not named `nftables` passes is by design, the same check as
#175. DeepSeek V4.1 Flash 1017 (max) and GLM 5.3 (max) audited the tree
at 1cea5a7 with Codex (GPT-6 Astra, xhigh) as the second opinion: seven
findings, none in the files this PR touches. They're in RTL, mempool
settings, the shared Tor SOCKS port and the netns source filter, and
Astra marked the three netns ones false positives.

netns-isolation has the same flushRuleset and table-name hole: a flush
deletes `nb-netns-bridge`'s MASQUERADE rule and the host's `nixos-fw`,
while the per-namespace rules survive. That's a separate PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: modules modules/ and pkgs/lib.nix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants