Skip to content

Commit

Permalink
Merge pull request #11586 from NixOS/mergify/bp/2.18-maintenance/pr-1…
Browse files Browse the repository at this point in the history
…1585

builtin:fetchurl: Enable TLS verification (backport #11585)
  • Loading branch information
edolstra authored Sep 25, 2024
2 parents 691f67d + 798e0bc commit 501a805
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 8 additions & 0 deletions doc/manual/rl-next/verify-tls.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
synopsis: "`<nix/fetchurl.nix>` uses TLS verification"
prs: [11585]
---

Previously `<nix/fetchurl.nix>` did not do TLS verification. This was because the Nix sandbox in the past did not have access to TLS certificates, and Nix checks the hash of the fetched file anyway. However, this can expose authentication data from `netrc` and URLs to man-in-the-middle attackers. In addition, Nix now in some cases (such as when using impure derivations) does *not* check the hash. Therefore we have now enabled TLS verification. This means that downloads by `<nix/fetchurl.nix>` will now fail if you're fetching from a HTTPS server that does not have a valid certificate.

`<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.
3 changes: 0 additions & 3 deletions src/libstore/builtins/fetchurl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData)

auto source = sinkToSource([&](Sink & sink) {

/* No need to do TLS verification, because we check the hash of
the result anyway. */
FileTransferRequest request(url);
request.verifyTLS = false;
request.decompress = false;

auto decompressor = makeDecompressionSink(
Expand Down

0 comments on commit 501a805

Please sign in to comment.