Skip to content

python3Packages.wassima: use cacert bundle instead of vendored CA list - #578891

Open
irgolic wants to merge 1 commit into
NixOS:masterfrom
irgolic:cacert/python3Packages.wassima
Open

irgolic wants to merge 1 commit into
NixOS:masterfrom
irgolic:cacert/python3Packages.wassima

Conversation

@irgolic

@irgolic irgolic commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Part of #576541.

wassima has a bundled CA list, as a Python string in wassima/_os/_embed.py, and this list has the eMudhra roots that cacert removed. In postPatch, this change removes the list and makes _embed.py read the ca-bundle.crt file of cacert. A symlink cannot replace the list, because the list is a string in the code, not a file.

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

| output:path | before | after |
|---|---|---|
| out:/lib/python3.14/site-packages/wassima/_os/_embed.py | pem 121 certs: 3 not in cacert, 0 in cacert but not for TLS, 0 cacert TLS roots missing; scanner: ECC G3 | no certs of its own; names cacert:ca-bundle.crt (read at run time) |
| out:/lib/python3.14/site-packages/wassima/_os/__pycache__/_embed.cpython-314.opt-1.pyc | pem 121 certs: 3 not in cacert, 0 in cacert but not for TLS, 0 cacert TLS roots missing; scanner: ECC G3 | no certs of its own; names cacert:ca-bundle.crt (read at run time) |
| out:/lib/python3.14/site-packages/wassima/_os/__pycache__/_embed.cpython-314.pyc | pem 121 certs: 3 not in cacert, 0 in cacert but not for TLS, 0 cacert TLS roots missing; scanner: ECC G3 | no certs of its own; names cacert:ca-bundle.crt (read at run time) |

inside archives (scanner only; a symlink in the installed output cannot reach them, issue #576542 class):
  before dist:/wassima-2.1.4-py3-none-any.whl!wassima/_os/_embed.py  roots=118 trusts 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 (3 total), e.g.:
  - 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
VERDICT python3Packages.wassima: FIXED: before trusted CAs outside cacert; after: 3 store(s) == cacert, none with extra CAs

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/wassima/_os/_embed.py | pem: accepted 7/14 (g3: 7/7, aaa: 0/7, noct: 1/2) | names cacert:ca-bundle.crt pem: accepted 0/14 |
| out:/lib/python3.14/site-packages/wassima/_os/__pycache__/_embed.cpython-314.opt-1.pyc | pem: accepted 7/14 (g3: 7/7, aaa: 0/7, noct: 1/2) | names cacert:ca-bundle.crt pem: accepted 0/14 |
| out:/lib/python3.14/site-packages/wassima/_os/__pycache__/_embed.cpython-314.pyc | pem: accepted 7/14 (g3: 7/7, aaa: 0/7, noct: 1/2) | names cacert:ca-bundle.crt pem: accepted 0/14 |
inside archives (zip members, extracted):
| dist:/wassima-2.1.4-py3-none-any.whl!wassima/_os/_embed.py | pem: accepted 7/14 (g3: 7/7, aaa: 0/7, noct: 1/2) | not found |
VERDICT python3Packages.wassima emudhra: FIXED: before accepted 7/14 compromised eMudhra chains (g3: 7/7, aaa: 0/7, noct: 1/2); after 0/14

[2/2] live eMudhra test hosts: needs network, NOT reproducible offline
==================================================================
LIVE python3Packages.wassima: needs network; NOT reproducible offline (the static and behavioral checks are)
before: 8915027df75d0403ef013dd0cbf09ff3c602fd03   after: worktree <worktree>
shim: shims/python3Packages.wassima.nix   hosts: https://<host>-emudhra.we-have-a-problem.com/, one request per host per side, 10s timeout
before ok (0 package drvs built, 1s)
        wrapper /nix/store/47dqghamazg779kf31qjsxjby9fwbm0l-ca-live-python3Packages-wassima
after  ok (0 package drvs built, 2s)
        wrapper /nix/store/yksjdx76axcskipgjgmpq1l4ky9izcvf-ca-live-python3Packages-wassima
system store: visible: /etc/ssl/certs/ca-certificates.crt -> nss-cacert-3.131.1/etc/ssl/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt -> nss-cacert-3.131.1/etc/ssl/certs/ca-bundle.crt 
              rejects every served chain, so it cannot make a cell CONNECTED
              but it holds the root of dv-g3b-aaa,dv-g3c-aaa with a trust rule that REJECTS it (OpenSSL "certificate rejected"):
              a program that loads it next to its own store (OpenSSL's default paths, e.g. excon) is
              REFUSED there whatever its own store says; --no-system-store shows the package's store alone
control dv-g3b: ok: HTTP 200, served chain == fixtures/emudhra/dv-g3b-emudhra.we-have-a-problem.com.pem (3 certs, valid for the host up to emSign ECC Root CA - G3), stock cacert rejects it
control dv-g3b-aaa: ok: HTTP 200, served chain == fixtures/emudhra/dv-g3b-aaa-emudhra.we-have-a-problem.com.pem (2 certs, valid for the host up to AAA Certificate Services), stock cacert rejects it
control dv-g3c: ok: HTTP 200, served chain == fixtures/emudhra/dv-g3c-emudhra.we-have-a-problem.com.pem (3 certs, valid for the host up to emSign ECC Root CA - G3), stock cacert rejects it
control dv-g3c-aaa: ok: HTTP 200, served chain == fixtures/emudhra/dv-g3c-aaa-emudhra.we-have-a-problem.com.pem (2 certs, valid for the host up to AAA Certificate Services), stock cacert rejects it
  before dv-g3b      CONNECTED      | status 200
  before dv-g3b-aaa  REFUSED        | ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1082)
  before dv-g3c      CONNECTED      | status 200
  before dv-g3c-aaa  REFUSED        | ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1082)
  after  dv-g3b      REFUSED        | ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1082)
  after  dv-g3b-aaa  REFUSED        | ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1082)
  after  dv-g3c      REFUSED        | ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1082)
  after  dv-g3c-aaa  REFUSED        | ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1082)

python3Packages.wassima  (live; before 8915027df75d0403ef013dd0cbf09ff3c602fd03, after worktree)
         | dv-g3b         | dv-g3b-aaa     | dv-g3c         | dv-g3c-aaa    
before   | CONNECTED      | REFUSED        | CONNECTED      | REFUSED       
after    | REFUSED        | REFUSED        | REFUSED        | REFUSED       
VERDICT python3Packages.wassima live: PASS: before CONNECTED to 2/4 host(s) serving a compromised eMudhra chain (dv-g3b,dv-g3c); after REFUSED on all 4

Before the change, the bundled list accepts 7 of the 14 eMudhra chains; after, none. In the live test, wassima connected to two of the four eMudhra test servers before the change, and to no server after.

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

@dotlambda dotlambda 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.

This project allows you to access your original operating system trust store, thus helping you to verify the remote peer certificates. It automatically fallback to an embedded trust store generated from the CCADB trusted source.

So what's the point of embedding cacert in the first place?

@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. llm-assisted Contributions that include code generation with LLMs 6.topic: python Python is a high-level, general-purpose programming language. labels Oct 25, 2026
@irgolic

irgolic commented Oct 25, 2026

Copy link
Copy Markdown
Member Author

So what's the point of embedding cacert in the first place?

I'm not sure, maybe ping someone from upstream? Here's the shim that reproduces the vulnerable behavior before the change and fixed behavior after it. Simplified version:

import urllib.request
import wassima
ctx = wassima.create_default_ssl_context()
with urllib.request.urlopen(sys.argv[1], context=ctx) as r:
    print("status", r.status)

Unfurl the collapsed "Output of harness: python3Packages.wassima" bit under the "Test" heading in the OP to see the run results.

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. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 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.

2 participants