fix(system_baseline): refuse ICMP redirects on every interface
With forwarding off the kernel accepts redirects when either `all` or the interface's own value is 1, and over IPv6 only the interface's value counts. The profiles now also set `default` and, with a wildcard, every existing interface, over IPv4 and IPv6. Refs #511 Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
1 parent
d88e5d237a
commit
74e574ee80
6 files changed
+163
-5
No files matched your search
@@ -43,7 +43,7 @@ templating error instead of the role's own message.
|
||||
| `system_baseline_unattended_upgrade_settings` | from profile | no | Keys for `50unattended-upgrades` |
|
||||
| `system_baseline_unattended_upgrade_origins` | from profile | no | Pinned `Origins-Pattern` entries; `[]` keeps the distribution default (see below) |
|
||||
| `system_baseline_unattended_upgrade_package_blacklist` | `[]` | no | Packages unattended-upgrades must not touch, as regular expressions (see below) |
|
||||
| `system_baseline_sysctl_hardening` | from profile | no | List of `name` and `value` sysctl pairs |
|
||||
| `system_baseline_sysctl_hardening` | from profile | no | List of `name` and `value` sysctl pairs; `*` in a name matches every interface (see "Sysctl hardening") |
|
||||
| `system_baseline_sysctl_file` | `/etc/sysctl.d/99-zz-system-baseline.conf` | no | Drop-in that persists the sysctl pairs: a `.conf` file directly under `/etc/sysctl.d` (see "Sysctl hardening") |
|
||||
| `system_baseline_secure_tmp_mounts` | from profile | no | Paths remounted as tmpfs with `noexec,nosuid,nodev` |
|
||||
| `system_baseline_journal_max_use` | `200M` | no | Upper bound of the persistent journal (journald `SystemMaxUse`): a number with an optional upper-case `B`, `K`, `M`, `G`, `T`, `P` or `E`, such as `1.5G`; a bare number is bytes. journald does not take `infinity`. Empty leaves the host alone and removes nothing a former run wrote (see "Leaving journald alone") |
|
||||
@@ -137,12 +137,12 @@ The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_
|
||||
- Verify refuses bad items in `system_baseline_extra_packages` and `system_baseline_extra_remove_packages` (whitespace, a null, an empty string, a trailing minus, upper case, a bare string) and a package that one input installs and another purges; converge applies the `ubuntu_lxc` profile with `jq` as an extra package and `ed` as an extra removal; verify checks that `jq` is installed, `ed` is gone and the profile's packages are still there, and that an extra `tmux` installs the snippet where a flat list without it installs none.
|
||||
- Verify also checks that a bad `system_baseline_apt_tmpdir` (under `/tmp` or `/var/tmp`, relative, with `..`, empty) is refused in the main flow and in the `update` entry point. It reads `tasks/update.yml` and checks that the scratch directory is created with mode `0700`, that both apt tasks set `TMPDIR` to it, that the connection is reset afterwards, and that the vzdump guard is imported before the upgrade, whose `when` reads the guard's fact: the scenario skips the `update` tag, so the upgrade itself never runs there.
|
||||
- Verify runs the vzdump guard in check mode on the Ubuntu container with `system_baseline_system_type: pve` and a `pvesh` stub, in seven cases (a running, a finished or no vzdump task, the input off, `ubuntu_lxc`); six run the guard's task file alone and the `ubuntu_lxc` case runs the whole `update` entry point. Each case asserts the fact that decides the upgrade and that `pvesh` was run, with `--source active`, only when it should be. It does not assert that the apt task itself was skipped. The stub stands for the real answer, which no CI image has.
|
||||
- Prepare seeds `/etc/sysctl.conf` with keys of the role and other lines. Verify checks that the drop-in holds exactly the profile's keys, that only the role's keys left `/etc/sysctl.conf`, that a key removed from the list leaves the drop-in and that a missing `/etc/sysctl.conf` is not created. It runs the runtime apply on the container's read-only `/proc/sys`: no change for the live value, a reported change in check mode and a failure for a value that cannot be set.
|
||||
- Prepare seeds `/etc/sysctl.conf` with keys of the role and other lines. Verify checks that the drop-in holds exactly the profile's keys, that only the role's keys left `/etc/sysctl.conf`, that a key removed from the list leaves the drop-in and that a missing `/etc/sysctl.conf` is not created. It runs the runtime apply on the container's read-only `/proc/sys`: no change for the live value, a reported change in check mode and a failure for a value that cannot be set, each for a plain key and for a `*`, and a failure for a `*` that matches no key.
|
||||
- Verify ends by running the role once with `system_baseline_journal_max_use: ""` after removing the drop-in, and asserts that no drop-in is written and that `systemd-journald` was not restarted.
|
||||
- Verify runs the `reboot` entry point with `system_baseline_reboot_if_required: false`, without and with `/var/run/reboot-required`, and checks the fact and that the host did not reboot.
|
||||
- The `pve` origins pin is applied to the Ubuntu container and read back with `apt-config dump`, then removed again. The package blacklist is written, read back as a list, left alone by a second run and removed by an empty list.
|
||||
|
||||
Not covered: Molecule skips the sysctl runtime apply in the role run, `secure_tmp`, `update` and `timezone` (no privileged container); see `molecule/default/molecule.yml`. So `system_baseline_update` is checked only for its default; the skip itself is not exercised by a test. No test writes a live sysctl value or reboots to see `systemd-sysctl` load the drop-in. No host reboots, and the `pve` profile is not converged: Debian 13 is not verified by a test.
|
||||
Not covered: Molecule skips the sysctl runtime apply in the role run, `secure_tmp`, `update` and `timezone` (no privileged container); see `molecule/default/molecule.yml`. So `system_baseline_update` is checked only for its default; the skip itself is not exercised by a test. No test writes a live sysctl value, runs without IPv6 or reboots to see `systemd-sysctl` load the drop-in. No host reboots, and the `pve` profile is not converged: Debian 13 is not verified by a test.
|
||||
|
||||
## Notes
|
||||
|
||||
@@ -234,6 +234,9 @@ An upgrade of a Proxmox node can restart Proxmox services while a backup holds a
|
||||
|
||||
The role sets each pair of `system_baseline_sysctl_hardening` on the running kernel when the live value differs, then writes the list to `system_baseline_sysctl_file`, which `systemd-sysctl` loads at boot. A value that cannot be set stops the run before the file is written. `--tags sysctl` does both.
|
||||
|
||||
- Every profile refuses ICMP redirects on every interface: `accept_redirects` is `0` for `all`, `default` and `*` (each interface that exists) over IPv4 and IPv6. `secure_redirects` is `0` for `all` and `default` over IPv4; the kernel reads it only for an interface that accepts redirects. An inventory that overrides the list or a profile's `sysctl_hardening` has to add these keys itself.
|
||||
- A `*` sets every matching key except those with an entry of their own, so `net.ipv4.conf.eth1.accept_redirects` in the list keeps its value. At boot an entry in any other `sysctl.d` file also wins over a `*`. Write names with dots, and a dot in an interface name as a slash: `net.ipv4.conf.eth0/100.accept_redirects`. Use a `*` only for keys with a single-word value, and no two patterns that match the same key.
|
||||
- Without IPv6 in the kernel the role skips the `net.ipv6` keys on the running kernel and still persists them. `systemd-sysctl` ignores them at boot; `sysctl -p` on the drop-in reports them as missing and exits 1.
|
||||
- The role owns the whole drop-in: a key removed from the list leaves the file, and its live value stays until the next reboot. When the list repeats a key, the last entry wins.
|
||||
- At boot the last file that sets a key wins, in the order of the file names. The default sorts after `99-sysctl.conf`, but a name that starts with a letter loads later: for example Proxmox VE's `/usr/lib/sysctl.d/pve-firewall.conf`, which sets `net.ipv4.conf.all.rp_filter`. To override such a file, choose a name that sorts after it.
|
||||
- Changing `system_baseline_sysctl_file` does not remove the old file, which is still loaded at boot; remove it by hand.
|
||||
|
||||
Reference in new issue
Block a user