Skip to content

pur: use cacert bundle instead of vendored CA bundle - #578141

Merged
fabaff merged 1 commit into
NixOS:masterfrom
irgolic:cacert/pur
Oct 24, 2026
Merged

fabaff merged 1 commit into
NixOS:masterfrom
irgolic:cacert/pur

Conversation

@irgolic

@irgolic irgolic commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Part of #576541.

pur bundles a copy of pip 23.2.1 in pur/packages. That copy has certifi 2023.5.7, with the file pip/_vendor/certifi/cacert.pem. pur puts pur/packages first in sys.path. Thus the bundled requests reads this file for all HTTPS connections. The file has 141 certificates. 24 of them are not in cacert, and 18 are in cacert but not for TLS. The file contains the roots AAA Certificate Services and emSign ECC Root CA - G3. This change replaces the file with a symlink to ${cacert}/etc/ssl/certs/ca-bundle.crt in postInstall. The rm command stops the build when a new version moves the file.

Note

AI Disclosure: Claude Code made the code change, the commit message and the first version of this pull request description, through patchix. Claude Code used Claude Opus 5.5. A person examined the work before this pull request. This pull request description is written in ASD-STE100 (Simplified Technical English), examined with memelint in strict mode.

Test

nix-cacert-harness examines the package before and after this change. A local copy of nixpkgs is not necessary.

nix run github:irgolic/nix-cacert-harness -- pur --pr 578141 --emudhra
Output of harness: pur
[1/2] static check + eMudhra chains: offline, reproducible
base (before) = dac5e22db3ed2be013da0eba8050c05140bd3f30
reference: fprs4zi8r6227x12qbsd1grvfrpz6201-nss-cacert-3.131.1 TLS roots=118 all=169
==================================================================
ATTR pur
before: dac5e22db3ed2be013da0eba8050c05140bd3f30   after: worktree <worktree>
before ok (0 built, 1s)
        drv /nix/store/sjf52dlkjzjqqhpjh8z5mdjc2g51wy6c-pur-7.4.0.drv
after  ok (0 built, 1s)
        drv /nix/store/zg88gbgkjsf13w04acvn35qwx4hszh2c-pur-7.4.0.drv

| output:path | before | after |
|---|---|---|
| out:/lib/python3.14/site-packages/pur/packages/pip/_vendor/certifi/cacert.pem | pem 141 certs: 24 not in cacert, 18 in cacert but not for TLS, 19 cacert TLS roots missing; scanner: AAA,ECC G3 | symlink->cacert:ca-bundle.crt pem 169 certs (118 TLS roots + 51 non-TLS, i.e. cacert's own trust-rules bundle) |

inside archives (scanner only; a symlink in the installed output cannot reach them, issue #576542 class):
  before dist:/pur-7.4.0-py3-none-any.whl!pur/packages/pip/_vendor/certifi/cacert.pem  roots=136 trusts AAA Certificate Services,emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  after  dist:/pur-7.4.0-py3-none-any.whl!pur/packages/pip/_vendor/certifi/cacert.pem  roots=136 trusts AAA Certificate Services,emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1

cacert in runtime closure (before): no
cacert in runtime closure (after): yes
CAs trusted before but not trusted for TLS by cacert (42 total), e.g.:
  - C=GB, O=Comodo CA Limited, CN=AAA Certificate Services
  - C=IN, OU=emSign PKI, O=eMudhra Technologies Limited, CN=emSign ECC Root CA - G3
  - C=US, OU=emSign PKI, O=eMudhra Inc, CN=emSign ECC Root CA - C3
  - C=US, OU=emSign PKI, O=eMudhra Inc, CN=emSign Root CA - C1
  - C=AT, O=e-commerce monitoring GmbH, CN=GLOBALTRUST 2020
  - C=BE, O=GlobalSign nv-sa, OU=Root CA, CN=GlobalSign Root CA
  - C=BM, O=QuoVadis Limited, CN=QuoVadis Root CA 2
  - C=BM, O=QuoVadis Limited, CN=QuoVadis Root CA 3
  - C=CH, O=SwissSign AG, CN=SwissSign Gold CA - G2
  - C=CH, O=SwissSign AG, CN=SwissSign Silver CA - G2
VERDICT pur: FIXED: before trusted CAs outside cacert; after: 1 store(s) == cacert, none with extra CAs (+ bundles inside archives remain, see above)

eMudhra chains (--emudhra; offline and reproducible): the 14 chains in fixtures/emudhra,
each leaf verified against each store (openssl verify -purpose sslserver, at 2026-10-23):
| output:path | before | after |
|---|---|---|
| out:/lib/python3.14/site-packages/pur/packages/pip/_vendor/certifi/cacert.pem | pem: accepted 14/14 (g3: 7/7, aaa: 7/7, noct: 2/2) | symlink->cacert:ca-bundle.crt pem: accepted 0/14 |
inside archives (zip members, extracted):
| dist:/pur-7.4.0-py3-none-any.whl!pur/packages/pip/_vendor/certifi/cacert.pem | pem: accepted 14/14 (g3: 7/7, aaa: 7/7, noct: 2/2) | pem: accepted 14/14 (g3: 7/7, aaa: 7/7, noct: 2/2) |
VERDICT pur emudhra: FIXED: before accepted 14/14 compromised eMudhra chains (g3: 7/7, aaa: 7/7, noct: 2/2); after 0/14 (+ after-side archive members accept 14/14 (g3: 7/7, aaa: 7/7, noct: 2/2), see table)

[2/2] live eMudhra test hosts: needs network, NOT reproducible offline
(no shims/pur.{nix,sh} or shims/live/pur.{nix,sh}: live check skipped)

Before the change, the bundled file accepts 14 of the 14 eMudhra chains. It accepts 7 of 7 for emSign ECC Root CA - G3 and 7 of 7 for AAA Certificate Services. After the change, the file is a symlink to the cacert bundle, and it accepts none of the 14 chains. The harness did not do the live test, because it has no shim for pur. The dist output keeps the wheel with the bundled file. pur does not read that wheel.

Things done

@irgolic irgolic added the 1.severity: security Issues which raise a security issue, or PRs that fix one label Oct 24, 2026
@nixpkgs-ci
nixpkgs-ci Bot requested a review from fabaff October 24, 2026 02:45
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Oct 24, 2026
@fabaff

fabaff commented Oct 24, 2026

Copy link
Copy Markdown
Member

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 578141
Commit: 16fe207b0d6dacb701e332b0e54e8bf9dd3f9fba


x86_64-linux

✅ 1 package built:
  • pur

@fabaff fabaff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good to me.

@fabaff
fabaff added this pull request to the merge queue Oct 24, 2026
Merged via the queue into NixOS:master with commit 2c8f089 Oct 24, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.severity: security Issues which raise a security issue, or PRs that fix one 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants