CVE-2024-36050
Medium · 4.3CVSS
4.3
EPSS
0.4%
Published
May 18, 2024
CISA due date
—
Cloudanix analysis
A flaw in the Nix package manager could let someone sneak bad code into projects by tricking maintainers into accepting a certain kind of update request.
- Exploitation
- Supply Chain
- Attacker needs
- User Interaction
- Complexity
- Moderate
- Impact
- Data Tampering
- Component
- Application
- Class
- Improper Input Validation
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
Nix mishandles hash cache validation for fetched sources, allowing an attacker-controlled source archive to be substituted for the legitimate one when a maintainer accepts a crafted pull request containing modified inputs that match the cache key incorrectly.
Why it matters to the business
Organizations using Nix for builds risk introducing attacker-controlled source code into their software supply chain, potentially leading to compromised artifacts, backdoors in distributed packages, or loss of build integrity across development and production pipelines.
How an attack unfolds
An attacker forks a Nix-based project, crafts a pull request that manipulates inputs to exploit the hash cache flaw, and lures a maintainer into merging it; once merged, subsequent Nix builds fetch and cache the malicious source instead of the original, persisting the compromise.
How to fix it
Upgrade Nix to a version beyond 2.22.1 that properly validates hash cache entries; review and regenerate any existing caches for projects that may have accepted suspect pull requests; enforce strict review processes for source-fetching expressions.
How to confirm the fix worked
Confirm Nix version is newer than 2.22.1; audit recent merged pull requests for source fetch expressions; test build reproducibility by clearing caches and verifying expected source hashes against trusted references.
Typical attack path
- Identify a Nix-managed project with public contribution workflow
- Create a fork and craft a pull request with manipulated source references
- Social-engineer or wait for maintainer review and merge
- Trigger builds on merged changes to poison the hash cache
- Subsequent builds or downstream consumers retrieve attacker-controlled sources
How to detect it
Review build logs and cache directories for unexpected source substitutions; search for recent merges of pull requests that alter fetch expressions; correlate with any post-merge build artifacts showing hash mismatches or unusual content.
What your security team should do
- Immediately upgrade all Nix installations to the latest fixed release
- Scan CI/CD pipelines and developer workstations for Nix versions <= 2.22.1
- Implement mandatory two-person review for changes affecting fetchers or hashes
- Monitor for unexpected source hash mismatches in build logs
The record
Nix through 2.22.1 mishandles certain usage of hash caches, which makes it easier for attackers to replace current source code with attacker-controlled source code by luring a maintainer into accepting a malicious pull request.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| Debian:11 | nix | 0 | No fix |
| Debian:12 | nix | 0 | No fix |
| Debian:13 | nix | 0 | No fix |
| Ubuntu:22.04:LTS | nix | 0 | No fix |
| Ubuntu:24.04:LTS | nix | 0 | No fix |
| Ubuntu:24.10 | nix | 0 | No fix |
| Ubuntu:25.04 | nix | 0 | No fix |
| Ubuntu:25.10 | nix | 0 | No fix |
| Ubuntu:Pro:22.04:LTS | nix | 0 | No fix |
| Ubuntu:Pro:24.04:LTS | nix | 0 | No fix |
Related vulnerabilities
- CVE-2024-47174 Nix is a package manager for Linux and other Unix systems. Also affects nix
- CVE-2024-38531 Nix is a package manager for Linux and other Unix systems that makes package management… Also affects nix
- CVE-2024-45593 Nix is a package manager for Linux and other Unix systems. Also affects nix
- CVE-2024-45845 Rejected reason: DO NOT USE THIS CVE RECORD. Also affects nix