*** This bug is a security vulnerability *** Public security bug reported:
Package: ca-certificates (Ubuntu) Also affects: ca-certificates-java (Ubuntu) Affected versions: 20260816ubuntu0.24.04.2 (noble-security), 20260816ubuntu0.22.04.2 (jammy-security), 20260816ubuntu0.26.04.2 (resolute-security) Upstream Debian Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1153565 Hello Ubuntu Team, In `/usr/sbin/update-ca-certificates`, `add()` (line 92) sanitizes `.crt` basenames via `sed -e 's/ /_/g' -e 's/[()]/=/g' -e 's/,/_/g'`, whereas `remove()` (line 106) omits `sed` and checks `PEM="$ETCCERTSDIR/$(basename "$CERT" .crt).pem"`. Lines 90-94 (`add()`): add() { CERT="$1" PEM="$ETCCERTSDIR/$(basename "$CERT" .crt | sed -e 's/ /_/g' \ -e 's/[()]/=/g' \ -e 's/,/_/g').pem" Lines 104-114 (`remove()`): remove() { CERT="$1" PEM="$ETCCERTSDIR/$(basename "$CERT" .crt).pem" if test -L "$PEM" then rm -f "$PEM" echo "-$PEM" >> "$REMOVED" fi } [Impact] If a certificate installed under `/usr/share/ca-certificates/` has spaces, parentheses `()`, or commas `,` in its `.crt` filename on disk (common for custom enterprise or Windows/AD CS certificates like `Corp Special CA (G1), Inc.crt`) and is deselected with `!` in `/etc/ca-certificates.conf` followed by `update-ca-certificates` (without `--fresh`): 1. It is removed from `/etc/ssl/certs/ca-certificates.crt` (`CAfile`), so `python3-requests` rejects it and Python's `ssl.create_default_context().get_ca_certs()` reports it as removed. 2. However, `remove()` checks `test -L` against the unsanitized `.pem` filename, which does not exist because `add()` created `/etc/ssl/certs/Corp_Special_CA_=G1=__Inc.pem`. 3. The sanitized `.pem` symlink and its OpenSSL `<hash>.0` symlink remain in `/etc/ssl/certs/` (`CApath`), and nothing is written to `$REMOVED` for `/etc/ca-certificates/update.d/` hooks. 4. Consequently, `curl`, `openssl verify`, Python `urllib.request.urlopen()`, Go `crypto/tls`, and OpenJDK (`/etc/ssl/certs/java/cacerts`) ALL continue to trust certificates signed by the deselected CA! [Test Plan / Steps to Reproduce] mkdir -p /usr/share/ca-certificates/localtest openssl req -x509 -newkey rsa:2048 -nodes -days 1 \ -subj "/CN=Special-Char-Test-CA" \ -keyout /tmp/spec.key \ -out "/usr/share/ca-certificates/localtest/Corp Special CA (G1), Inc.crt" echo "localtest/Corp Special CA (G1), Inc.crt" >> /etc/ca-certificates.conf update-ca-certificates # -> 1 added, 0 removed; done. # Symlink created: /etc/ssl/certs/Corp_Special_CA_=G1=__Inc.pem # Deselect with '!' in /etc/ca-certificates.conf: sed -i 's|^localtest/Corp Special CA (G1), Inc.crt|!localtest/Corp Special CA (G1), Inc.crt|' /etc/ca-certificates.conf update-ca-certificates # -> 0 added, 0 removed; done. ls -l /etc/ssl/certs/Corp_Special_CA_=G1=__Inc.pem # -> STILL PRESENT in /etc/ssl/certs/! keytool -list -cacerts -storepass changeit | grep -i corp_special # -> debian:corp_special_ca_=g1=__inc.pem STILL PRESENT in java cacerts! [Where problems could occur] Factoring out `cert_to_pem()` so both `add()` and `remove()` apply the exact same `sed` transformation only affects `remove()` for certificate filenames containing spaces, parentheses, or commas, bringing `remove()` in line with `add()`. [Proposed Patch] --- a/sbin/update-ca-certificates +++ b/sbin/update-ca-certificates @@ -87,12 +87,16 @@ TEMPBUNDLE="${ETCCERTSDIR}/${CERTBUNDLE}.new" ADDED=$(mktemp -t "ca-certificates.tmp.XXXXXX") REMOVED=$(mktemp -t "ca-certificates.rem.XXXXXX") +cert_to_pem() { + echo "$ETCCERTSDIR/$(basename "$1" .crt | sed -e 's/ /_/g' \ + -e 's/[()]/=/g' \ + -e 's/,/_/g').pem" +} + add() { CERT="$1" - PEM="$ETCCERTSDIR/$(basename "$CERT" .crt | sed -e 's/ /_/g' \ - -e 's/[()]/=/g' \ - -e 's/,/_/g').pem" + PEM=$(cert_to_pem "$CERT") if ! test -e "$PEM" || [ "$(readlink "$PEM")" != "$CERT" ] then ln -sf "$CERT" "$PEM" @@ -103,7 +107,7 @@ remove() { CERT="$1" - PEM="$ETCCERTSDIR/$(basename "$CERT" .crt).pem" + PEM=$(cert_to_pem "$CERT") if test -L "$PEM" then rm -f "$PEM" ** Affects: ca-certificates (Ubuntu) Importance: Undecided Status: New ** Information type changed from Public to Public Security -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/2174377 Title: update-ca-certificates: remove() omits sed filename sanitization used by add(), leaving symlinks in /etc/ssl/certs and entries in java cacerts To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/ca-certificates/+bug/2174377/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
