STIGUI
V-268161CAT II — Medium severitySV-268161r1131128_rule

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

Rule version ANIX-00-001670 · STIG v1 · 2025-08-19

Discussion

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.

Add the following Nix code to the NixOS Configuration, usually located in /etc/nixos/configuration.nix or /etc/nixos/flake.nix:

boot.kernel.sysctl = { "kernel.randomize_va_space" = 2; };

Rebuild and switch to the new NixOS configuration: $ sudo nixos-rebuild switch

Identifiers

Group ID
V-268161
Group title
SRG-OS-000433-GPOS-00193
Rule ID
SV-268161r1131128_rule
Check ID
C-72085r1039369_chk
Fix ID
F-71988r1131127_fix