ca_certs: remove_defaults is undone by the next CA package update on p11-kit distros

Aperta
#7,304 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
linux, python
Ambito
backend, security

Direzione di ricerca

Read the cloud-init changes referenced as #7250 and #7297, then inspect the rhel CA certificate handling and its tests to see how remove_defaults currently clears trust sources. Compare the proposed p11-kit module configuration override with blocklisting, including how each behaves on Fedora and Arch after a CA package update. Done means choosing and implementing an approach that keeps defaults excluded after updates, with tests covering the behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug new

Bug report

On distros that use the p11-kit trust store (the RHEL family, and Arch in #7297), remove_defaults: true deletes the packaged CA source files. The package manager owns those files, so the next update or reinstall of the CA package puts them back, update-ca-trust runs from the package scriptlet/hook, and every default CA is trusted again. Nothing tells the user that the setting stopped working.

This came up as a known limitation in #7299 and #7297, but there is no issue for it yet.

Steps to reproduce the problem

Fedora 45 container (ca-certificates 2026.2.92). This removes the same trust sources that remove_default_ca_certs() clears for the rhel family once #7250 is in:

dnf -y download --destdir /tmp/pkg ca-certificates
B=/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
grep -c BEGIN $B                                  # 118
find /usr/share/pki/ca-trust-source /etc/pki/ca-trust/source -type f -delete
update-ca-trust; grep -c BEGIN $B                 # 0
rpm -Uvh --replacepkgs --nodeps /tmp/pkg/ca-certificates-*.rpm
grep -c BEGIN $B                                  # 118 again

Same result on Arch (ca-certificates-mozilla 3.134-1) running the module itself from the #7297 branch with remove_defaults: true and one trusted CA: the bundle has 1 certificate, and after reinstalling ca-certificates-mozilla it has 114.

Possible fix

Instead of deleting package-owned files, limit p11-kit's trust paths to the local admin directory with a module config override, e.g. on Fedora:

# /etc/pkcs11/modules/p11-kit-trust.module
module: p11-kit-trust.so
x-init-reserved: paths=/etc/pki/ca-trust/source

(/etc/ca-certificates/trust-source on Arch.) I tested this by hand:

Fedora 45 Arch
default 118 113
override + trusted CA, after update-ca-trust 1 1
after reinstalling the CA package 1 1
override file removed + update-ca-trust 119 (118 + the trusted CA)

The package files stay untouched, so updates don't undo the setting, CAs added by later package versions are excluded too, and removing one file reverts it. update-ca-trust extract and trust list both honour it. The override applies to every p11-kit consumer, which is what remove_defaults means anyway.

Another option is to blocklist the default CAs (.../source/blocklist/). That also survives updates, but it only covers the CAs present when cloud-init ran, not CAs added by later packages.

I'm happy to implement either one once #7250 and #7205 have landed, if you agree with the direction. Which approach would you prefer?

Environment details

  • Cloud-init version: main (faa0d79), plus the #7297 branch for the Arch run
  • Operating System Distribution: Fedora 45 and Arch Linux containers
  • Cloud provider, platform or installer type: N/A (module behaviour, reproduced in containers)

cloud-init logs

Not applicable: the module succeeds. The defaults come back later, when the CA package is updated.

Lingua principale
Python
Stelle
3.9k
Fork
1.2k
Merge medio
2g 24m
PR unite (30g)
18

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di canonical/cloud-init

Tutte le issue di canonical/cloud-init

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.