Skip to content

python3Packages.pex: use cacert bundle instead of vendored CA bundle - #578576

Merged
SuperSandro2000 merged 1 commit into
NixOS:masterfrom
irgolic:cacert/python3Packages.pex
Oct 27, 2026
Merged

SuperSandro2000 merged 1 commit into
NixOS:masterfrom
irgolic:cacert/python3Packages.pex

Conversation

@irgolic

@irgolic irgolic commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Part of #576541.

pex bundles a copy of pip 20.3.4 in pex/vendor/_vendored/pip. That copy has certifi 2020.11.08, with the file pip/_vendor/certifi/cacert.pem. pex uses the bundled pip for a Python version before 3.12, and for --pip-version vendored. The bundled pip reads this file for each HTTPS connection. The file has 150 certificates. 25 of them are not in cacert, and 17 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. Before pex uses its bundled code, it copies that code into PEX_ROOT. A local test shows that the copy of the file in PEX_ROOT is the same as the cacert bundle.

Note

AI Disclosure: Claude Code made the code change, the commit message and the first version of this pull request description, with patchix. Claude Code used Claude Opus 5.5. This pull request description is written in ASD-STE100 (Simplified Technical English), examined with memelint in strict mode. As the automation/AI policy requires, I established confidence in this output: by manual review of the code change and of this description, and with the verification tooling that this description discloses.

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 -- python3Packages.pex --pr 578576 --emudhra
Output of harness: python3Packages.pex
[1/2] static check + eMudhra chains: offline, reproducible
base (before) = dac5e22db3ed2be013da0eba8050c05140bd3f30
reference: fprs4zi8r6227x12qbsd1grvfrpz6201-nss-cacert-3.131.1 TLS roots=118 all=169
==================================================================
ATTR python3Packages.pex
before: dac5e22db3ed2be013da0eba8050c05140bd3f30   after: worktree <worktree>
before ok (0 built, 1s)
        drv /nix/store/k6gnma56ggk94xfnb0yvyq254andmi72-python3.14-pex-2.38.1.drv
after  ok (0 built, 1s)
        drv /nix/store/xfd9i9mm7vaid0pbfpy8ids64gxj56sy-python3.14-pex-2.38.1.drv

| output:path | before | after |
|---|---|---|
| out:/lib/python3.14/site-packages/pex/vendor/_vendored/pip/pip/_vendor/certifi/cacert.pem | pem 150 certs: 25 not in cacert, 17 in cacert but not for TLS, 10 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:/pex-2.38.1-py2.py3-none-any.whl!pex/vendor/_vendored/pip/pip/_vendor/certifi/cacert.pem  roots=143 trusts AAA Certificate Services,emSign ECC Root CA - C3,emSign ECC Root CA - G3,emSign Root CA - C1,emSign Root CA - G1
  after  dist:/pex-2.38.1-py2.py3-none-any.whl!pex/vendor/_vendored/pip/pip/_vendor/certifi/cacert.pem  roots=143 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=ES, O=Firmaprofesional SA, CN=FIRMAPROFESIONAL CA ROOT-A WEB
VERDICT python3Packages.pex: 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/pex/vendor/_vendored/pip/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:/pex-2.38.1-py2.py3-none-any.whl!pex/vendor/_vendored/pip/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 python3Packages.pex 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/python3Packages.pex.{nix,sh} or shims/live/python3Packages.pex.{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 pex. The wheel in the dist output keeps the bundled file (#576542). The installed pex does not read that wheel.

Things done

Assisted-by: Claude Code (Claude Opus 5.5) with patchix
@irgolic irgolic added the 1.severity: security Issues which raise a security issue, or PRs that fix one label Oct 25, 2026
@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. 9.needs: reviewer This PR currently has no reviewers requested and needs attention. llm-assisted Contributions that include code generation with LLMs 7.no default reviewers This PR targets a package or module with no existing maintainers; roving reviewers, take pity! 6.topic: python Python is a high-level, general-purpose programming language. labels Oct 25, 2026
@SuperSandroBot

Copy link
Copy Markdown

✅ nixpkgs-review result

Generated using nixpkgs-review-gha (b97195b)

Command: nixpkgs-review pr 578576
Commit: 666f3eff3e3b466339f9a1c7c905049965346620 (subsequent changes)
Merge: 4602409f678e04cc39a64c30f6a42c7054f623fd

Logs: https://github.com/SuperSandro2000/nixpkgs-review-gha/actions/runs/40537753557/attempts/1


x86_64-linux

✅ 2 packages built:
  • python313Packages.pex
  • python314Packages.pex

aarch64-linux

✅ 2 packages built:
  • python313Packages.pex
  • python314Packages.pex

@SuperSandro2000
SuperSandro2000 added this pull request to the merge queue Oct 27, 2026
Merged via the queue into NixOS:master with commit 6db815c Oct 27, 2026
35 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 6.topic: python Python is a high-level, general-purpose programming language. 7.no default reviewers This PR targets a package or module with no existing maintainers; roving reviewers, take pity! 9.needs: reviewer This PR currently has no reviewers requested and needs attention. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. llm-assisted Contributions that include code generation with LLMs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants