Repository navigation
presets/hardened-extended: drop module.sig_enforce and lockdown - #184
Conversation
ostermayer
left a comment
There was a problem hiding this comment.
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)
d16d1a7 to
2567f5d
Compare
…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.
Follow-up to #182. Independent of it: different lines of the same file.
hardened-extendedsetsmodule.sig_enforce=1andlockdown=confidentiality. The stock NixOS kernel in the pinned nixpkgs is built without either feature, so the kernel ignores both:CONFIG_MODULE_SIGCONFIG_SECURITY_LOCKDOWN_LSMlinuxPackages6.18.59 (x86_64, aarch64)linuxPackages_latest7.3 (x86_64, aarch64)The
sig_enforcemodule param only exists withCONFIG_MODULE_SIG, andlockdown=is parsed by the lockdown LSM. NixOS doesn't sign its modules either, so on a custom kernel withMODULE_SIGenabled,sig_enforce=1would 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.lockKernelModulesas a replacement. It would break netns-isolation, which needsveth/bridge modules after boot.No
versioning.nixentry: 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 inboot.kernelParamsthemselves.Tested
hardenedscenario:boot.kernelParamsdiffers from master by exactly these two entries.nix flake check --all-systemspasses.Assisted-by: Claude Code (claude-opus-5-5)