Skip to content

Commit

Permalink
Disables IPv6 via cmdline option for Focal
Browse files Browse the repository at this point in the history
Adds a Focal-only cmdline option for the boot to disable IPv6
functionality completely. Adds a config test to ensure no IPv6 addresses
are assigned.
  • Loading branch information
Conor Schaefer committed Feb 22, 2021
1 parent 33f94c9 commit 1f2f575
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion install_files/securedrop-grsec-focal/DEBIAN/postinst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ set_grub_default() {
# When using CONFIG_PAX_KERNEXEC, the grsecurity team recommends the kernel
# is booted with "noefi" on the kernel command line if "CONFIG_EFI" is
# enabled, as EFI runtime services are necessarily mapped as RWX.
sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT=/s/=.*/=\"noefi\"/' /etc/default/grub
perl -pi -e 's|^GRUB_CMDLINE_LINUX_DEFAULT=|GRUB_CMDLINE_LINUX_DEFAULT="noefi ipv6.disable=1"|' /etc/default/grub
update-grub
}

Expand Down
11 changes: 11 additions & 0 deletions molecule/testinfra/common/test_grsecurity.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,14 @@ def test_mds_mitigations_and_smt_disabled(host):
grub_config = host.file(grub_config_path)

assert grub_config.contains("mds=full,nosmt")


def test_kernel_boot_options(host):
"""
Ensure command-line options for currently booted kernel are set.
"""
f = host.file("/proc/cmdline")
boot_opts = f.content_string.split()
assert "noefi" in boot_opts
if host.system_info.codename == "focal":
assert "ipv6.disable=1" in boot_opts
9 changes: 9 additions & 0 deletions molecule/testinfra/common/test_ip6tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ def test_ip6tables_drop_everything(host):
with host.sudo():
c = host.check_output("ip6tables -S")
assert c == desired_ip6tables_output


def test_ipv6_addresses_absent(host):
"""
Ensure that no IPv6 addresses are assigned to interfaces.
"""
with host.sudo():
c = host.check_output("ip -6 addr")
assert c == ""

0 comments on commit 1f2f575

Please sign in to comment.