Skip to content

pgsql-tools: use cacert bundle instead of vendored CA file - #578585

Merged
mdaniels5757 merged 1 commit into
NixOS:masterfrom
irgolic:cacert/pgsql-tools
Oct 31, 2026
Merged

mdaniels5757 merged 1 commit into
NixOS:masterfrom
irgolic:cacert/pgsql-tools

Conversation

@irgolic

@irgolic irgolic commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Part of #576541.

pgsql-tools is a binary release that PyInstaller made. It has a bundled CA file from certifi, lib/pgsql-tools/_internal/certifi/cacert.pem. In this release, requests, httpx and httplib2 use this file. The Azure clients of pgsql-tools (azure-mgmt-monitor and azure-mgmt-postgresqlflexibleservers, through azure-core and requests) use this file for their HTTPS requests to Azure. The PostgreSQL connections do not use this file. This change replaces the file with a symlink to the ca-bundle.crt file of cacert in postInstall.

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 -- pgsql-tools --pr 578585 --emudhra
Output of harness: pgsql-tools
$ nix run github:irgolic/nix-cacert-harness -- pgsql-tools --base 8915027df75d0403ef013dd0cbf09ff3c602fd03 --after github:irgolic/nixpkgs/9356d114d98d56229b99ca4bdb7433d8ef3775f9 --emudhra
[1/2] static check + eMudhra chains: offline, reproducible
base (before) = 8915027df75d0403ef013dd0cbf09ff3c602fd03
reference: fprs4zi8r6227x12qbsd1grvfrpz6201-nss-cacert-3.131.1 TLS roots=118 all=169
==================================================================
ATTR pgsql-tools
before: 8915027df75d0403ef013dd0cbf09ff3c602fd03   after: github:irgolic/nixpkgs/9356d114d98d56229b99ca4bdb7433d8ef3775f9
before ok (0 built, 0s)
        drv /nix/store/…-pgsql-tools-2.1.0.drv
after  ok (0 built, 1s)
        drv /nix/store/…-pgsql-tools-2.1.0.drv

| output:path | before | after |
|---|---|---|
| out:/lib/pgsql-tools/_internal/certifi/cacert.pem | pem 145 certs: 22 not in cacert, 12 in cacert but not for TLS, 7 cacert TLS roots missing; scanner: ECC G3 | symlink->cacert:ca-bundle.crt pem 169 certs (118 TLS roots + 51 non-TLS, i.e. cacert's own trust-rules bundle) |

cacert in runtime closure (before): no
cacert in runtime closure (after): yes
CAs trusted before but not trusted for TLS by cacert (34 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
  - 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
  - C=FR, O=Dhimyotis, CN=Certigna
  - C=GB, O=COMODO CA Limited, CN=COMODO Certification Authority
VERDICT pgsql-tools: FIXED: before trusted CAs outside cacert; after: 1 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/pgsql-tools/_internal/certifi/cacert.pem | pem: accepted 7/14 (g3: 7/7, aaa: 0/7, noct: 1/2) | symlink->cacert:ca-bundle.crt pem: accepted 0/14 |
VERDICT pgsql-tools 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
(no shims/pgsql-tools.{nix,sh} or shims/live/pgsql-tools.{nix,sh}: live check skipped)

The harness tests the package with the certificate chains of the eMudhra incident, from https://emudhra.we-have-a-problem.com/ (only the certificates, not the keys). Before this change, the bundled file accepts 7 of the 14 chains (accepted 7/14). Thus, the file accepts the eMudhra intermediate certificates through emSign ECC Root CA - G3, but not through AAA Certificate Services, because the file does not have this root. After this change, the file accepts no chain (accepted 0/14). The output has no second part, because pgsql-tools is a JSON-RPC service for the PostgreSQL extension of VS Code. It sends HTTPS requests only to Azure, with a token from the extension. Also, a test cannot start a small Python script in a PyInstaller release.

Things done

@irgolic irgolic added the 1.severity: security Issues which raise a security issue, or PRs that fix one label Oct 25, 2026
@zimbatm zimbatm mentioned this pull request Oct 25, 2026
66 of 95 tasks
@nixpkgs-ci
nixpkgs-ci Bot requested a review from liberodark October 25, 2026 01:16
@nixpkgs-ci nixpkgs-ci Bot added 2.status: merge conflict This PR has merge conflicts with the target branch 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. llm-assisted Contributions that include code generation with LLMs labels Oct 25, 2026
@nixpkgs-ci nixpkgs-ci Bot added 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels Oct 25, 2026
@SuperSandro2000

Copy link
Copy Markdown
Member

Please rebase

Assisted-by: Claude Code (Claude Opus 5.5) with patchix
@irgolic
irgolic force-pushed the cacert/pgsql-tools branch from 477f290 to a51bb30 Compare October 28, 2026 19:09
@irgolic

irgolic commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

Rebased and moved it to preFixup; let me know if you think it should go into postInstall instead like it was originally.

@nixpkgs-ci nixpkgs-ci Bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Oct 28, 2026
@mdaniels5757 mdaniels5757 added the backport release-26.05 Backport PR automatically label Oct 31, 2026
@mdaniels5757

Copy link
Copy Markdown
Member

npb · 74cac4a → a51bb30

Expand this for a reproducible command.
npb --base 74cac4ac565ebaccd188224995e6deb95b44d66d --head 46337987f8fb15bc3b4a934b4ae2dc0af49fc2ad --patch 46337987f8fb15bc3b4a934b4ae2dc0af49fc2ad...a51bb30db66bd42970144e4967630e7605f5dca2 -s x86_64-linux -s aarch64-linux -s aarch64-darwin
Expand this for a legend of all symbols below.
  • ✅ = successfully built
  • ❌ = failed to build
  • 🚫 = dependency failed to build
  • ❔ = couldn't try to build
  • ⏩ = failed to evaluate
  • ➖ = doesn't exist

x86_64-linux

✅ → ✅ · 1 package
  • pgsql-tools

aarch64-linux

✅ → ✅ · 1 package
  • pgsql-tools

aarch64-darwin

✅ → ✅ · 1 package
  • pgsql-tools

@mdaniels5757
mdaniels5757 added this pull request to the merge queue Oct 31, 2026
Merged via the queue into NixOS:master with commit f4b6e10 Oct 31, 2026
28 checks passed
@nixpkgs-ci

nixpkgs-ci Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Backport failed for release-26.05, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-26.05
git worktree add -d .worktree/backport-578585-to-release-26.05 origin/release-26.05
cd .worktree/backport-578585-to-release-26.05
git switch --create backport-578585-to-release-26.05
git cherry-pick -x a51bb30db66bd42970144e4967630e7605f5dca2

@mdaniels5757

Copy link
Copy Markdown
Member

#581232

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 8.has: port to stable This PR already has a backport to the stable release. 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. 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. llm-assisted Contributions that include code generation with LLMs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants