Skip to content

Sandbox escape

Low
fricklerhandwerk published GHSA-q82p-44mg-mgh5 Jun 27, 2024

Package

Nix (Nix)

Affected versions

<=2.23

Patched versions

2.23.1, 2.22.2, 2.21.3, 2.20.7, 2.19.5, 2.18.4

Description

Impact

A build process has access to and can change the permissions of the build directory. After creating a setuid binary in a globally accessible location, a malicious local user can assume the permissions of a Nix daemon worker and hijack all future builds.

Concretely, this can happen when all the following conditions are met:

  • The attacker has access to a local user
  • The local user has access to the Nix daemon (but does not have to be a trusted user)
  • seccomp is disabled (if the sandbox is disabled or filter-syscalls if set to false on Linux) or ineffective (fixed in #10501)

Patches

The patch changes the location of the build process to occur in a sub-directory owned by and accessible only to the Nix daemon, which means that a derivation cannot alter the permissions to make it world-readable.

Workarounds

  • If your Nix version is >= 2.22, set build-dir to a location that is only accessible by root (added in #10312)
  • Otherwise, run your Nix daemon with $TMPDIR set to a location only accessible by root

Severity

Low

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Local
Attack complexity
High
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
Low
Availability
Low

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:L/A:L

CVE ID

CVE-2024-38531

Weaknesses

Credits