October 2025 · 8 min read

Hardening the NullSec Kernel

A pentesting distro running a stock kernel is ironic. Here's every kernel hardening option we enable and why.

Memory protections

Access control

Network hardening

Testing

We run the kernel-hardening-checker in CI. Our score: 85/100 (the remaining 15 points are options that break pentesting tools).

Filesystem and integrity hardening

Beyond memory and network protections, we harden the filesystem layer. These options prevent common privilege escalation vectors that target SUID binaries and writable mount points:

We also mount /tmp and /dev/shm with noexec,nosuid,nodev flags by default. Combined with IMA, this means even if an attacker drops a binary into /tmp, it cannot execute.

Boot chain security

A hardened kernel means nothing if the bootloader is compromised. NullSec's boot chain is locked down end-to-end:

This makes NullSec significantly harder to tamper with than stock Kali or Parrot, where an attacker with physical access can modify the boot chain trivially.

Runtime exploit mitigations

We enable every userspace exploit mitigation the kernel supports:

# /etc/sysctl.d/99-nullsec-hardening.conf

# ASLR at maximum strength (stack, heap, mmap, vdso)
kernel.randomize_va_space = 2

# Restrict dmesg to root (prevents info leaks)
kernel.dmesg_restrict = 1

# Restrict kernel pointer display
kernel.kptr_restrict = 2

# Disable kexec (prevents hot-loading a malicious kernel)
kernel.kexec_load_disabled = 1

# Restrict performance events (prevents side-channel attacks)
kernel.perf_event_paranoid = 3

# Disable unprivileged user namespaces (blocks container escapes)
kernel.unprivileged_userns_clone = 0

Each sysctl has a corresponding CI test that verifies the value after boot. If a kernel update resets any of these, our nightly pipeline catches it within hours.

The 15-point gap

Our kernel-hardening-checker score is 85/100. The remaining 15 points come from options we intentionally leave disabled:

Each exception is documented in /usr/share/nullsec/kernel-exceptions.md with a risk assessment and mitigation plan. Security is about informed tradeoffs, not checkbox compliance.

Verifying your installation

Every NullSec install includes a verification script:

# Run the full hardening audit
nullsec-audit --kernel --sysctl --mounts --boot

# Example output:
# [PASS] KASLR enabled
# [PASS] Stack protector: strong
# [PASS] BPF restricted to root
# [PASS] /tmp mounted noexec
# [PASS] Signed modules enforced
# [WARN] lockdown=integrity (not confidentiality)
# Score: 47/50 checks passed

We recommend running this after every kernel update. The script is also available as a Lateralus pipeline for integration into your own security workflows.

Lateralus is built by bad-antics. Follow development on GitHub or try the playground.