Executive brief
Nix is a package manager used to automate software builds and deployments. A security flaw in how it handles temporary files during the build process allows a local user to trick the system into overwriting sensitive files on the host computer. In many configurations, this allows a standard user to gain full administrative (root) control over the entire system.
Technical details
A vulnerability exists in the Nix daemon's fixed-output derivation (FOD) registration process. When Nix attempts to prevent file descriptor exfiltration by copying build outputs to a temporary '.tmp' path within the build chroot, it fails to validate if that path is a symbolic link. Because the Nix process performing the copy operates in the host mount namespace with root privileges, a malicious derivation builder can create a symlink at the expected temporary path pointing to a sensitive host file (e.g., /etc/shadow). During output registration, Nix follows the symlink and overwrites the target with the derivation's output. This allows any user authorized to submit builds to achieve local privilege escalation. The issue is fixed in versions 2.34.5, 2.33.4, 2.32.7, 2.31.4, 2.30.4, 2.29.3, and 2.28.6.
Affected products
- NixOS nix >= 2.18.2, < 2.28.6; >= 2.29.0, < 2.29.3; >= 2.30.0, < 2.30.4; >= 2.31.0, < 2.31.4; >= 2.32.0, < 2.32.7; >= 2.33.0, < 2.33.4; >= 2.34.0, < 2.34.5
Timeline
- 2026-04-08: advisory
- 2026-04-08: disclosed
References
- https://github.com/NixOS/nix/commit/244f3eee0bbc7f11e9b383a15ed7368e2c4becc9
- https://github.com/NixOS/nix/commit/4bc5a3510fa3735798f9ed3a2a30a3ea7b32343a
- https://github.com/NixOS/nix/commit/7794354a982449927ee7401cdeb573ddd16c4688
- https://github.com/NixOS/nix/commit/a3163b9eabb952b4aa96e376dea95ebcca97b31a
- https://github.com/NixOS/nix/pull/10178
- https://github.com/NixOS/nix/security/advisories/GHSA-g3g9-5vj6-r3gj