You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Credential leak when credentials are used with `<nix/fetchurl.nix>`
Moderate
edolstra
published
GHSA-6fjr-mq49-mm2cSep 26, 2024
Package
nix
(Nix)
Affected versions
<= 2.24.7
Patched versions
2.18.8, 2.24.8
Description
Impact
<nix/fetchurl.nix> historically 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.
Important
<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.
You may be affected by the risk of leaking credentials if you 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 5db358d 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.
Patches
This issue has been fixed on Nix master and in Nix 2.24.8.
Workarounds
Implement (authenticated) fetching with pkgs.fetchurl from Nixpkgs, using impureEnvVars and curlOpts as needed.
Impact
<nix/fetchurl.nix>
historically 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.Important
<nix/fetchurl.nix>
is also known as the builtin derivation builderbuiltin:fetchurl
. It's not to be confused with the evaluation-time functionbuiltins.fetchurl
, which was not affected by this issue.You may be affected by the risk of leaking credentials if you have a
netrc
file for authentication, or rely on derivations withimpureEnvVars
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 5db358d 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.Patches
This issue has been fixed on Nix master and in Nix 2.24.8.
Workarounds
Implement (authenticated) fetching with
pkgs.fetchurl
from Nixpkgs, usingimpureEnvVars
andcurlOpts
as needed.References
None