Skip to content

zoneminder: use cacert bundle instead of vendored CakePHP CA bundle - #577804

Merged
pbsds merged 1 commit into
NixOS:masterfrom
irgolic:cacert/zoneminder
Oct 24, 2026
Merged

pbsds merged 1 commit into
NixOS:masterfrom
irgolic:cacert/zoneminder

Conversation

@irgolic

@irgolic irgolic commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Part of #576541.

The API of ZoneMinder, in share/zoneminder/www/api, has CakePHP 2.10 with a bundled CA file, lib/Cake/Config/cacert.pem. When the caller gives no cafile, the CakeSocket class of CakePHP uses this file, and HttpSocket sets ssl_verify_peer to true by default. The code of ZoneMinder does not make an HttpSocket. Only one path goes from a ZoneMinder installation to this file. When the API gets an XML request body that starts with https://, Xml::build of CakePHP downloads from this URL with an HttpSocket. This is the only path at runtime, thus the effect of this change is small. This change replaces the file with a symlink to the ca-bundle.crt file of cacert in postInstall.

Warning

AI Disclosure: Claude Code made the code change, the commit message and the first version of this pull request description. Claude Code used Claude Fable 5.1 and Claude Opus 5.5. I examined all of this work. Claude Code also wrote all of nix-cacert-harness. 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. The harness builds ZoneMinder from source a maximum of two times, and each build is approximately 10 minutes long.

nix run github:irgolic/nix-cacert-harness -- zoneminder --pr 577804 --emudhra
Harness output: zoneminder
$ nix run github:irgolic/nix-cacert-harness -- zoneminder --base 8915027df75d0403ef013dd0cbf09ff3c602fd03 --after github:irgolic/nixpkgs/a6e7c2334c43ba7e3e479e56df5b330aaa72c111 --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 zoneminder
before: 8915027df75d0403ef013dd0cbf09ff3c602fd03   after: github:irgolic/nixpkgs/a6e7c2334c43ba7e3e479e56df5b330aaa72c111
before ok (0 built, 3s)
        drv /nix/store/…-zoneminder-1.38.6.drv
after  ok (0 built, 2s)
        drv /nix/store/…-zoneminder-1.38.6.drv

| output:path | before | after |
|---|---|---|
| out:/share/zoneminder/www/api/lib/Cake/Config/cacert.pem | pem 152 certs: 96 not in cacert, 19 in cacert but not for TLS, 81 cacert TLS roots missing; scanner: AAA | 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 (115 total), e.g.:
  - C=GB, O=Comodo CA Limited, CN=AAA Certificate Services
  - 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=BM, O=QuoVadis Limited, OU=Root Certification Authority, CN=QuoVadis Root Certification Authority
  - C=ch, O=Swisscom, OU=Digital Certificate Services, CN=Swisscom Root CA 1
  - C=ch, O=Swisscom, OU=Digital Certificate Services, CN=Swisscom Root CA 2
VERDICT zoneminder: 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:/share/zoneminder/www/api/lib/Cake/Config/cacert.pem | pem: accepted 7/14 (g3: 0/7, aaa: 7/7, noct: 1/2) | symlink->cacert:ca-bundle.crt pem: accepted 0/14 |
VERDICT zoneminder emudhra: FIXED: before accepted 7/14 compromised eMudhra chains (g3: 0/7, aaa: 7/7, noct: 1/2); after 0/14

[2/2] live eMudhra test hosts: needs network, NOT reproducible offline
==================================================================
LIVE zoneminder: needs network; NOT reproducible offline (the static and behavioral checks are)
before: 8915027df75d0403ef013dd0cbf09ff3c602fd03   after: github:irgolic/nixpkgs/a6e7c2334c43ba7e3e479e56df5b330aaa72c111
shim: shims/zoneminder.nix   hosts: https://<host>-emudhra.we-have-a-problem.com/, one request per host per side, 10s timeout
before ok (0 package drvs built, 6s)
        wrapper /nix/store/…-ca-live-zoneminder
after  ok (0 package drvs built, 6s)
        wrapper /nix/store/…-ca-live-zoneminder
system store: visible: /etc/ssl/certs/ca-certificates.crt -> nss-cacert-3.126/etc/ssl/certs/ca-bundle.crt /etc/pki/tls/certs/ca-bundle.crt -> nss-cacert-3.126/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,dv-g3b-aaa,dv-g3c,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      REFUSED        | error:0A000086:SSL routines::certificate verify failed
  before dv-g3b-aaa  CONNECTED      | status 200
  before dv-g3c      REFUSED        | error:0A000086:SSL routines::certificate verify failed
  before dv-g3c-aaa  CONNECTED      | status 200
  after  dv-g3b      REFUSED        | error:0A000086:SSL routines::certificate verify failed
  after  dv-g3b-aaa  REFUSED        | error:0A000086:SSL routines::certificate verify failed
  after  dv-g3c      REFUSED        | error:0A000086:SSL routines::certificate verify failed
  after  dv-g3c-aaa  REFUSED        | error:0A000086:SSL routines::certificate verify failed

zoneminder  (live; before 8915027df75d0403ef013dd0cbf09ff3c602fd03, after github:irgolic/nixpkgs/a6e7c2334c43ba7e3e479e56df5b330aaa72c111)
         | dv-g3b         | dv-g3b-aaa     | dv-g3c         | dv-g3c-aaa
before   | REFUSED        | CONNECTED      | REFUSED        | CONNECTED
after    | REFUSED        | REFUSED        | REFUSED        | REFUSED
VERDICT zoneminder live: PASS: before CONNECTED to 2/4 host(s) serving a compromised eMudhra chain (dv-g3b-aaa,dv-g3c-aaa); after REFUSED on all 4

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 the Sectigo cross-sign by AAA Certificate Services. After this change, the file accepts no chain (accepted 0/14). In the second part of the output, a small PHP test sends one GET request to each of four test servers, as Xml::build does. Before this change, the test connects to the two servers with the AAA chain. After this change, the test connects to no server.

Things done

Assisted-by: Claude Code (Claude Fable 5.1)
Assisted-by: Claude Code (Claude Opus 5.5)
@irgolic irgolic added the 1.severity: security Issues which raise a security issue, or PRs that fix one label Oct 23, 2026
@zimbatm zimbatm mentioned this pull request Oct 23, 2026
66 of 95 tasks
@nixpkgs-ci
nixpkgs-ci Bot requested a review from peat-psuwit October 23, 2026 11:44
@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: 0 This PR does not cause any packages 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 23, 2026
@peat-psuwit

peat-psuwit commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Okay...

Surprises no. 1: Since when CakePHP vendors a CA bundle?
Surprises no. 2: ZoneMinder vendors CakePHP version... *check notes*... 2.10? While CakePHP's latest version is 5.4.3?
Surprises no. 3: CakePHP has actually stopped vendoring CA bundle since version 4.0 (it relies on composer/ca-bundle instead). Should ZoneMinder regularly updates its CakePHP version, this would not have been a problem...

Now, it seems like ca-bundle.crt from cacerts package is in a slightly different format than vendored cacerts.pem (it contains -----BEGIN TRUSTED CERTIFICATE----- sections). So I'll have to recheck if it will actually work. But other than a minor comment, I think it looks OK.

@irgolic

irgolic commented Oct 23, 2026

Copy link
Copy Markdown
Member Author

Should I symlink ca-no-trust-rules-bundle.crt instead of ca-bundle.crt? The former omits the -----BEGIN TRUSTED CERTIFICATE----- sections. Most software can read the latter just fine, and other maintainers have preferred using those, but I'm delegating to maintainer taste here; if you think it's more important to be faithful to upstream, I'll switch em.

@peat-psuwit

Copy link
Copy Markdown
Contributor

Will get back to you tomorrow. At the moment it seems like CakePHP 2.10 simply passes path to this file to PHP, so will check that.

@peat-psuwit

Copy link
Copy Markdown
Contributor

I tested the ca-bundle.crt file with a test PHP file. Seems like PHP has no problem handling -----BEGIN TRUSTED CERTIFICATE----- section. So I think this PR looks good to me!

As for ca-no-trust-rules-bundle.crt vs. ca-bundle.crt: I don't have a preference here. In fact I don't even learn the difference until yesterdays. I don't really care about being faithful to upstream; I just want to make sure it will work.

@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 24, 2026
@pbsbot

pbsbot commented Oct 24, 2026

Copy link
Copy Markdown

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 577804
Commit: a6e7c2334c43ba7e3e479e56df5b330aaa72c111


x86_64-linux

✅ 1 package built:
  • zoneminder

@pbsds
pbsds added this pull request to the merge queue Oct 24, 2026
Merged via the queue into NixOS:master with commit 914ab5b Oct 24, 2026
36 checks passed
@peat-psuwit peat-psuwit added the backport release-26.05 Backport PR automatically label Oct 27, 2026
@nixpkgs-ci

nixpkgs-ci Bot commented Oct 27, 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-577804-to-release-26.05 origin/release-26.05
cd .worktree/backport-577804-to-release-26.05
git switch --create backport-577804-to-release-26.05
git cherry-pick -x a6e7c2334c43ba7e3e479e56df5b330aaa72c111

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: failed backport 10.rebuild-darwin: 0 This PR does not cause any packages 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. backport release-26.05 Backport PR automatically llm-assisted Contributions that include code generation with LLMs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants