NixOS must implement address space layout randomization to protect its memory from unauthorized code execution.

Severity
Group ID
Group Title
Version
Rule ID
Date
STIG Version
mediumV-268161SRG-OS-000433-GPOS-00193ANIX-00-001670SV-268161r1039371_rule2024-10-251
Description
Some adversaries launch attacks with the intent of executing code in nonexecutable regions of memory or in memory locations that are prohibited. Security safeguards employed to protect memory include, for example, data execution prevention and address space layout randomization. Data execution prevention safeguards can either be hardware-enforced or software-enforced with hardware providing the greater strength of mechanism. Examples of attacks are buffer overflow attacks.
ℹ️ Check
Verify NixOS enables address space layout randomization with the following command: $ sudo sysctl kernel.randomize_va_space kernel.randomize_va_space = 2 If "kernel.randomize_va_space" does not have a value of "2" or is missing, this is a finding.
✔️ Fix
Configure /etc/nixos/configuration.nix to enable ASLR by adding the following configuration settings: boot.kernel.sysctl = { "kernel.randomize_va_space" = 2; }; Rebuild the system with the following command: $ sudo nixos-rebuild switch