CVE-2024-47174
JSON

5.9medium

Credential leak when credentials are used with `<nix/fetchurl.nix>`

Severity
5.9medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.46% (higher than 32% of CVEs)
Published
Last changed
Assigned by
GitHub_M

Description

Nix is a package manager for Linux and other Unix systems. Starting in version 1.11 and prior to versions 2.18.8 and 2.24.8, `<nix/fetchurl.nix>` did not verify TLS certificates on HTTPS connections. This could lead to connection details such as full URLs or credentials leaking in case of a man-in-the-middle (MITM) attack. `<nix/fetchurl.nix>` is also known as the builtin derivation builder `builtin:fetchurl`. It's not to be confused with the evaluation-time function `builtins.fetchurl`, which was not affected by this issue. A user may be affected by the risk of leaking credentials if they have a `netrc` file for authentication, or rely on derivations with `impureEnvVars` set to use credentials from the environment. In addition, the commonplace trust-on-first-use (TOFU) technique of updating dependencies by specifying an invalid hash and obtaining it from a remote store was also vulnerable to a MITM injecting arbitrary store objects. This also applied to the impure derivations experimental feature. Note that this may also happen when using Nixpkgs fetchers to obtain new hashes when not using the fake hash method, although that mechanism is not implemented in Nix itself but rather in Nixpkgs using a fixed-output derivation. The behavior was introduced in version 1.11 to make it consistent with the Nixpkgs `pkgs.fetchurl` and to make `<nix/fetchurl.nix>` work in the derivation builder sandbox, which back then did not have access to the CA bundles by default. Nowadays, CA bundles are bind-mounted on Linux. This issue has been fixed in Nix 2.18.8 and 2.24.8. As a workaround, implement (authenticated) fetching with `pkgs.fetchurl` from Nixpkgs, using `impureEnvVars` and `curlOpts` as needed.

Affected

Product or packageVersionsReported by
NixOS nix>= 1.11, < 2.18.8, >= 2.24.0, < 2.24.8CVE List

Classification

CWE-287

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

Nix is a package manager for Linux and other Unix systems. Starting in version 1.11 and prior to versions 2.18.8 and 2.24.8, `<nix/fetchurl.nix>` did not verify TLS certificates on HTTPS connections. This could lead to connection details such as full URLs or credentials leaking in case of a man-in-the-middle (MITM) attack. `<nix/fetchurl.nix>` is also known as the builtin derivation builder `builtin:fetchurl`. It's not to be confused with the evaluation-time function `builtins.fetchurl`, which was not affected by this issue. A user may be affected by the risk of leaking credentials if they have a `netrc` file for authentication, or rely on derivations with `impureEnvVars` set to use credentials from the environment. In addition, the commonplace trust-on-first-use (TOFU) technique of updating dependencies by specifying an invalid hash and obtaining it from a remote store was also vulnerable to a MITM injecting arbitrary store objects. This also applied to the impure derivations experimental feature. Note that this may also happen when using Nixpkgs fetchers to obtain new hashes when not using the fake hash method, although that mechanism is not implemented in Nix itself but rather in Nixpkgs using a fixed-output derivation. The behavior was introduced in version 1.11 to make it consistent with the Nixpkgs `pkgs.fetchurl` and to make `<nix/fetchurl.nix>` work in the derivation builder sandbox, which back then did not have access to the CA bundles by default. Nowadays, CA bundles are bind-mounted on Linux. This issue has been fixed in Nix 2.18.8 and 2.24.8. As a workaround, implement (authenticated) fetching with `pkgs.fetchurl` from Nixpkgs, using `impureEnvVars` and `curlOpts` as needed.

NVD (es)

Nix es un administrador de paquetes para Linux y otros sistemas Unix. A partir de la versión 1.11 y antes de las versiones 2.18.8 y 2.24.8, `` no verificaba los certificados TLS en las conexiones HTTPS. Esto podría provocar que se filtraran detalles de la conexión, como URL completas o credenciales, en caso de un ataque de intermediario (MITM). `` también se conoce como el generador de derivaciones integrado `builtin:fetchurl`. No debe confundirse con la función de tiempo de evaluación `builtins.fetchurl`, que no se vio afectada por este problema. Un usuario puede verse afectado por el riesgo de filtrar credenciales si tiene un archivo `netrc` para la autenticación o confía en derivaciones con `impureEnvVars` configuradas para usar credenciales del entorno. Además, la técnica común de confianza en el primer uso (TOFU) de actualizar dependencias especificando un hash no válido y obteniéndolo de un almacén remoto también era vulnerable a un MITM que inyectara objetos de almacén arbitrarios. Esto también se aplicaba a la característica experimental de derivaciones impuras. Tenga en cuenta que esto también puede suceder cuando se utilizan los recuperadores de Nixpkgs para obtener nuevos hashes cuando no se utiliza el método de hash falso, aunque ese mecanismo no está implementado en Nix en sí, sino en Nixpkgs que utiliza una derivación de salida fija. El comportamiento se introdujo en la versión 1.11 para que fuera coherente con el `pkgs.fetchurl` de Nixpkgs y para que `` funcionara en el entorno limitado del generador de derivaciones, que en ese entonces no tenía acceso a los paquetes de CA de forma predeterminada. Hoy en día, los paquetes de CA se montan mediante enlaces en Linux. Este problema se ha solucionado en Nix 2.18.8 y 2.24.8. Como workaround, implemente la obtención (autenticada) con `pkgs.fetchurl` desde Nixpkgs, usando `impureEnvVars` y `curlOpts` según sea necesario.

References

Sources

SourceRecordLicence
CVE ListCVE-2024-47174 changed 2024-09-26CVE Terms of Use
NVDCVE-2024-47174 changed 2026-06-17Public domain