Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 9 min read

Ubuntu removed a root CA. Node 22.23.2 still trusts it: comparing CA lists by public key

On 30 October, apt on my Ubuntu 24.04 container installed ca-certificates 20260816ubuntu0.24.04.1. Its changelog has one line that matters here: * Blacklist the following CA cert due to intermediate cert compromise

On 30 October, apt on my Ubuntu 24.04 container installed ca-certificates 20260816ubuntu0.24.04.1. Its changelog has one line that matters here:

  * Blacklist the following CA cert due to intermediate cert compromise
    (LP: #2171507)
    + "emSign ECC Root CA - G3"

That is the root above the intermediates with tiny private keys that I wrote about in October. The system store dropped it. The question I wanted answered was narrower: what on this machine still trusts it? Answering it takes two steps. Ask each runtime which list it reads, then compare the lists by public key.

Step 1: ask each runtime where it looks

Python's ssl module reads whatever OpenSSL was built to read:

import ssl

print(ssl.get_default_verify_paths())
ctx = ssl.create_default_context()
print(ctx.cert_store_stats())
print(any("emSign ECC Root CA - G3" in str(c["subject"]) for c in ctx.get_ca_certs()))
DefaultVerifyPaths(cafile='/usr/lib/ssl/cert.pem', capath='/usr/lib/ssl/certs', openssl_cafile_env='SSL_CERT_FILE', openssl_cafile='/usr/lib/ssl/cert.pem', openssl_capath_env='SSL_CERT_DIR', openssl_capath='/usr/lib/ssl/certs')
{'x509': 120, 'crl': 0, 'x509_ca': 120}
False

/usr/lib/ssl/cert.pem is a symlink to /etc/ssl/certs/ca-certificates.crt, so plain ssl follows the distro: 120 roots, no G3. That stops being true the moment you pip install requests. The Requests docs say it "uses certificates from the package certifi", and certifi ships its own cacert.pem, frozen at whatever certifi version you have.

Node is the interesting one. Since 22.15 it has tls.getCACertificates(type), which returns the list for each source: bundled (the copy compiled into the binary), system, extra (from NODE_EXTRA_CA_CERTS), and default, the list TLS clients actually use. This script prints all four and checks for G3:

const tls = require('tls');
const { X509Certificate } = require('crypto');

const spki = (p) => new X509Certificate(p).publicKey.export({ type: 'spki', format: 'der' }).toString('base64');
const distinct = (pems) => new Set(pems.map(spki)).size;
const hasRoot = (pems, cn) => pems.some((p) => new X509Certificate(p).subject.split('\n').includes(`CN=${cn}`));

console.log(`node ${process.version}, NODE_USE_SYSTEM_CA=${process.env.NODE_USE_SYSTEM_CA ?? 'unset'}, flags: ${process.execArgv.join(' ') || 'none'}`);
for (const t of ['default', 'bundled', 'system', 'extra']) {
  const pems = tls.getCACertificates(t);
  console.log(`  ${t.padEnd(8)} ${String(pems.length).padStart(4)} entries, ${String(distinct(pems)).padStart(3)} distinct keys, G3: ${hasRoot(pems, 'emSign ECC Root CA - G3')}`);
}

On Node 22.23.2, run three ways (the bundled, system and extra lines are the same in all three runs, so I cut them from the second and third):

node v22.23.2, NODE_USE_SYSTEM_CA=unset, flags: none
  default   145 entries, 145 distinct keys, G3: true
  bundled   145 entries, 145 distinct keys, G3: true
  system    360 entries, 120 distinct keys, G3: false
  extra       0 entries,   0 distinct keys, G3: false
node v22.23.2, NODE_USE_SYSTEM_CA=1, flags: none
  default   505 entries, 149 distinct keys, G3: true
  ...
node v22.23.2, NODE_USE_SYSTEM_CA=unset, flags: --use-openssl-ca
  default     0 entries,   0 distinct keys, G3: false
  ...

Three things in that output matter.

The default list is the bundled one. The Node docs describe it as "a snapshot of Mozilla CA store that is fixed at release time". 22.23.2 came out on 28 July (per Node's release index), so its snapshot has G3, and no OS update can change that.

NODE_USE_SYSTEM_CA=1 adds, it does not subtract. The docs for --use-system-ca say Node uses the system store "along with" the bundled one, and they are blunt about the consequence: "Node.js currently does not support distrust/revocation of certificates from another source based on system settings." So 145 bundled plus 360 system entries gives 505, which collapses to 149 distinct keys: the 145 bundled roots plus four roots that only the system store has. G3 is still in. Turning on the system store only helps with roots the bundle is missing, never with roots the distro removed.

--use-openssl-ca reports an empty default list, and it still works. In that mode the default list leaves out the bundled roots, as the docs say it will, and the OpenSSL store that Node verifies against does not show up in it. So I checked that it really verifies against the system store rather than against nothing:

node --use-openssl-ca -e "require('https').get('https://www.rfc-editor.org/', r => console.log(r.statusCode, r.socket.authorized))"
SSL_CERT_FILE=/dev/null SSL_CERT_DIR=/nonexistent node --use-openssl-ca -e "require('https').get('https://www.rfc-editor.org/', r => console.log(r.statusCode)).on('error', e => console.log(e.code))"
200 true
UNABLE_TO_GET_ISSUER_CERT_LOCALLY

The 360 system entries for 120 roots are not a bug either. The docs warn that the array "may contain duplicates if the same certificate is repeatedly stored in multiple sources", and Node reads both the bundle file and the certificate directory. Count distinct keys, not entries.

Step 2: compare the lists by public key

Comparing files by hash tells you nothing, and comparing by name is fragile. A CA can reissue a root with the same key under a new certificate, so the key is the identity that matters. The script below hashes each certificate's SubjectPublicKeyInfo and walks just enough DER to find the subject and the key, with the standard library only:

"""Compare CA bundles by public key. Usage: python3 trust_inventory.py REF.pem OTHER.pem ..."""
import hashlib, re, sys
from base64 import b64decode

PEM = re.compile(rb"-----BEGIN CERTIFICATE-----(.+?)-----END CERTIFICATE-----", re.S)


def tlv(buf, i):
    """Return (tag, start of value, end of value) for the DER element at i."""
    tag, n = buf[i], buf[i + 1]
    i += 2
    if n & 0x80:
        size, n = n & 0x7F, int.from_bytes(buf[i:i + (n & 0x7F)], "big")
        i += size
    return tag, i, i + n


def fields(buf, start, end):
    """Split a SEQUENCE body into its elements as (tag, start, end) of the whole element."""
    out = []
    while start < end:
        tag, vs, ve = tlv(buf, start)
        out.append((tag, start, ve))
        start = ve
    return out


def parse(der):
    """Return (SPKI SHA-256, subject CN or O) for one DER certificate."""
    _, s, e = tlv(der, 0)               # Certificate
    _, s, e = tlv(der, s)               # tbsCertificate
    f = fields(der, s, e)
    if f[0][0] == 0xA0:                 # skip the explicit [0] version
        f = f[1:]
    subject, spki = f[4], f[5]          # serial, sigAlg, issuer, validity, subject, spki
    name = {}
    for oid, label in ((b"\x55\x04\x03", "CN"), (b"\x55\x04\x0a", "O")):
        k = der.find(b"\x06\x03" + oid, subject[1], subject[2])
        if k != -1:
            _, vs, ve = tlv(der, k + 5)
            name[label] = der[vs:ve].decode("utf-8", "replace")
    return hashlib.sha256(der[spki[1]:spki[2]]).hexdigest(), name.get("CN") or name.get("O")


def show(sign, names, limit=6):
    for n in names[:limit]:
        print(f"    {sign} {n}")
    if len(names) > limit:
        print(f"    ... and {len(names) - limit} more")


def load(path):
    data = open(path, "rb").read()
    certs = [b64decode(b"".join(m.split())) for m in PEM.findall(data)]
    return len(certs), dict(parse(c) for c in certs)


ref_path, *others = sys.argv[1:]
ref_count, ref = load(ref_path)
print(f"{ref_path}: {ref_count} certificates, {len(ref)} distinct keys (reference)")
for path in others:
    count, roots = load(path)
    extra = sorted(roots[k] for k in roots.keys() - ref.keys())
    missing = sorted(ref[k] for k in ref.keys() - roots.keys())
    print(f"\n{path}: {count} certificates, {len(roots)} distinct keys")
    print(f"  trusted here but not in the reference: {len(extra)}")
    show("+", extra)
    print(f"  in the reference but not here: {len(missing)}")
    show("-", missing)

To get Node's bundle into a file, node -e "process.stdout.write(require('tls').rootCertificates.join('\n'))" > node-bundled.pem. Then compare it, today's certifi release (2026.11.20) and an older certifi copy I found inside a desktop app, all against the system store:

/etc/ssl/certs/ca-certificates.crt: 120 certificates, 120 distinct keys (reference)

node-v22.23.2-bundled.pem: 145 certificates, 145 distinct keys
  trusted here but not in the reference: 29
    + AffirmTrust Commercial
    + AffirmTrust Networking
    + AffirmTrust Premium
    + AffirmTrust Premium ECC
    + Atos TrustedRoot 2011
    + COMODO Certification Authority
    ... and 23 more
  in the reference but not here: 4
    - SECOM TLS ECC Root CA 2024
    - SECOM TLS RSA Root CA 2024
    - Telia EC TLS Root CA v3
    - Telia RSA TLS Root CA v3

certifi-2026.11.20.pem: 113 certificates, 113 distinct keys
  trusted here but not in the reference: 0
  in the reference but not here: 7
    - Buypass Class 2 Root CA
    - Buypass Class 3 Root CA
    - Certigna Root CA
    - QuoVadis Root CA 1 G3
    - QuoVadis Root CA 3 G3
    - emSign ECC Root CA - C3
    ... and 1 more

vendored-certifi-in-app.pem: 121 certificates, 121 distinct keys
  trusted here but not in the reference: 1
    + emSign ECC Root CA - G3
  in the reference but not here: 0

The same Ubuntu changelog accounts for all 29 extra roots in Node's bundle. The June package (20260601~24.04.1) lists 24 roots removed in its update to Mozilla bundle 2.86, DigiCert Global Root CA and the four AffirmTrust roots among them. The October package removes four more with bundle 2.90 and blacklists G3. Node 22.23.2 was released on 28 July and still carries every one of them.

certifi goes the other way: the current release trusts fewer roots than Ubuntu and lacks seven that Ubuntu still ships, two other emSign roots among them. The old copy inside the app is byte-identical to certifi 2026.07.22, and it still has G3.

The fix for Node is an upgrade

Node did remove G3. The commit "crypto: update root certificates to NSS 3.131.1" (20 October) lists emSign ECC Root CA - G3, emSign Root CA - C1 and emSign ECC Root CA - C3 as removed. I fetched src/node_root_certs.h at the current release tags:

v22.23.5  116 roots  G3: no
v24.22.3  118 roots  G3: no
v26.13.1  118 roots  G3: no

Run through the same comparison, the 22.23.5 bundle has only two roots the Ubuntu store lacks (Atos TrustedRoot 2011 and the Chunghwa Telecom ePKI root) instead of 29. So on 22.x the answer is 22.23.5 or later. The other Node on this machine, 20.20.2, bundles 144 roots including G3 and has no getCACertificates at all. It will not get a fix: Node 20 reached end of life on 30 April 2026 (release schedule), and 20.20.2 from 24 March was its last release.

If you would rather your Node processes follow the distro's decisions, --use-openssl-ca does that. NODE_USE_SYSTEM_CA=1 does not.

The copies you did not install on purpose

The last step is a plain find:

find ~ /opt /usr \( -name cacert.pem -o -name tls-ca-bundle.pem -o -name ca-bundle.pem \) -type f 2>/dev/null

It turned up 296 files on this machine. 284 were named cacert.pem, and 264 of those sat in uv's package cache. Of the 20 outside the cache, 15 still list G3: certifi inside three virtualenvs and a uv tool, pip's own vendored certifi in three uv-managed Python installs and one virtualenv, six copies in container image layers, and the desktop app from above. The other five: botocore's own cacert.pem, a game that ships one, and three Flatpak bundles. I did not work out which of these each program reads at runtime, so treat the count as places to check, not as 15 open holes.

What I would check on any machine

  1. node -p "process.version + ' ' + require('tls').rootCertificates.length" on every Node you run, then compare with a current release of the same line. The OS store does not reach the bundled list.
  2. python -m certifi in every virtualenv that uses Requests, and the certifi version pinned in your lock files.
  3. Container images: each one carries the ca-certificates package and any certifi from the day it was built.
  4. The find above, then the SPKI comparison on anything it turns up.

The distro did its job on 30 October. The other copies change only when you upgrade the thing that ships them, and nothing warns you that a copy is out of date.

Written with AI assistance from my own notes and test results. I checked every fact and command before publishing.

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.