ca-certificates and crypto-policies vs 3way merge #145
Labels
No labels
Area
Anaconda
Area
CI
Area
composefs
Area
dnf
Area
podman
Bug
Documentation
DO NOT MERGE
Duplicate
Enhancement
Flaky
Good first issue
Help wanted
Invalid
level-1
level-2
level-3
Meeting
Question
TEST ONLY
Version
Fedora 41
Version
Fedora 42
Version
Fedora 43
Version
Fedora 44
Version
Fedora 45
Won't fix
No milestone
No project
No assignees
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
atomic/tracker#145
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Migrated from a RHT internal tracker https://redhat.atlassian.net/browse/BIFROST-654
The problem
ostree and bootc (with composefs) do a "3 way merge" for files in
/etc. This issue is about the problems that can occur with this pattern with two important packages:Scope
Note that for both of these, we need to consider both custom derived images as well as machine local configuration.
Scenario 1: crypto-policies machine local change
COPY ACMECORP.pmod /etc/crypto-policies/policies/modules/update-crypto-policies --set DEFAULT:ACMECORPis run once on a per machine stateExpected: the new system starts with the OpenSSL configuration regenerated by the new crypto-policies version. This must be in place when PID 1 starts, since systemd links against OpenSSL — which rules out regenerating via a systemd unit.
Observed: the 3-way merge either fails to apply the diff (the generated file changed when the subpolicy was applied) or applies it while retaining the fixed bug. Retaining the locally modified file unchanged also keeps the bug.
The
%postfor update-crypto-policies runs on the build server, not the client, so there's no opportunity to regenerate the local change.Scenario 2: ca-certificates local change
/etc/pki/ca-trust/source/blocklistupdate-ca-trustto regenerate the consolidated trust storeExpected: PID 1 still distrusts the locally blocked CA, but picks up the upstream trust changes.
Observed: the locally modified generated trust store is preserved, so new CAs aren't picked up and recently distrusted CAs remain trusted.
Let's be clear, by far the ideal fix is to have a
/usrand/etcsplit as encouraged by https://uapi-group.org/specifications/specs/configuration_files_specification/It would work especially well for ca-certificates to have
/usr/lib/pki/ca-trust.For Fedora CoreOS derivatives we shipped https://github.com/coreos/fedora-coreos-config/blob/testing-devel/overlay.d/05core/usr/lib/systemd/system/coreos-update-ca-trust.service which handles 2 for most use cases.
There's a general pattern here of some things that today live in RPM
%postshould migrate in general to systemd units.I think moving that service into the ca-certificates package could make sense.
That said, in the internal tracker what this quickly snowballed into is the question of the initramfs - for some use cases, we actually do need to get updated content into that for cases where we want to do TLS before we mount the root filesystem.
Ultimately, in my opinion most of those cases are just much better handled with custom image builds instead of having it be per-machine mutable state. And taking that out one step, it'd be nice if ca-certificates and crypto-policies supported a mode where machine local mutations are denied. (One can aim to enforce this with a transient or readonly
/etc, but those can be harder to achieve)One thing that's related here is we did land special support in ostree for regenerating the selinux policy for similar reasons which also lacks a
/usrvs/etcsplit (and it was not yet reimplemented for bootc xref https://github.com/bootc-dev/bootc/issues/2511). We could generalize that into a mechanism where we support "drop in" services that can run during finalization. This just came up in https://github.com/ostreedev/ostree/pull/3674This wouldn't address the initramfs case, but that's arguably semi-broken too in the mutable package (dnf) case too because you just have to know to rerun
dracutor equivalent afterdnf update ca-certificates.This requires having two locations,
/usr/lib/pki/ca-trustand/etc/pki/ca-trust, and all applications that read the CA trust store need to read both and do a local computation taking the system store, adding explicitly trusted CAs from the/etcconfiguration, and subtracting explicitly distrusted CAs from/etc.In other words, every component that currently reads the CA store (and that's NSS, OpenSSL, GnuTLS, p11-kit, OpenJDK, likely Go, a bunch of Rust binaries, and many more that we don't know about) to agree on a new interface for this, and implement this mechanism.
The crypto team has no plans to work on this. Feel free to convince the various upstreams that this is desirable and they should implement it.
I have an existing base-image MR that builds on the CoreOS approach. It adds early-boot services to regenerate CA trust and crypto-policy backend files on every boot, covering subsequent image updates as well as initial provisioning.
This could provide a starting point for moving the CA regeneration service into ca-certificates, as suggested above. It remains a partial mitigation: consumers that load the configuration before these services run may require a restart or an additional reboot to pick up the regenerated files. It also does not address updating trust and policy embedded in the initramfs.
I agree that separating vendor defaults under /usr from local configuration under /etc is the right direction. Even with that separation implemented by the packages, we would still need a mechanism to refresh the generated trust bundles after updates, incorporating vendor trust changes while preserving machine-local additions, such as internal company CAs.
@walters wrote in #145 (comment):
IIUC
coreos-update-ca-trust.servicecould potentially handle case 2, but it hasConditionFirstBoot=trueso in practice doesn't actually handle case 2?Yes good observation, indeed! We should probably discuss this over in the MR where this came up because of how it slows down boot times.
I think we can consider this one fixed with https://gitlab.com/fedora/bootc/base-images/-/merge_requests/663 merged?
Until I can find the time to de-dup and rebase the manifests, I'm copying this fix for the Atomic Desktops in atomic-desktops/config#818.