ca-certificates and crypto-policies vs 3way merge #145

Open
opened 2026-10-27 14:15:25 +00:00 by walters · 8 comments
Owner

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

  1. A user installs a custom subpolicy in their Containerfile as an option
    COPY ACMECORP.pmod /etc/crypto-policies/policies/modules/
  2. update-crypto-policies --set DEFAULT:ACMECORP is run once on a per machine state
  3. Upstream fixes a bug in how the OpenSSL configuration is generated
  4. The user updates to the newer image

Expected: 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 %post for 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

  1. A user blocklists an untrustworthy root CA by copying it into /etc/pki/ca-trust/source/blocklist
  2. They run update-ca-trust to regenerate the consolidated trust store
  3. An update ships newly trusted CAs and distrusts some previously trusted roots

Expected: 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.

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: - https://src.fedoraproject.org/rpms/ca-certificates - https://src.fedoraproject.org/rpms/crypto-policies ## 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 1. A user installs a custom subpolicy in their Containerfile as an option `COPY ACMECORP.pmod /etc/crypto-policies/policies/modules/` 2. `update-crypto-policies --set DEFAULT:ACMECORP` is run *once* on a per machine state 3. Upstream fixes a bug in how the OpenSSL configuration is generated 4. The user updates to the newer image **Expected:** 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 `%post` for 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 1. A user blocklists an untrustworthy root CA by copying it into `/etc/pki/ca-trust/source/blocklist` 2. They run `update-ca-trust` to regenerate the consolidated trust store 3. An update ships newly trusted CAs and distrusts some previously trusted roots **Expected:** 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.
Author
Owner

Let's be clear, by far the ideal fix is to have a /usr and /etc split 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 %post should 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)

Let's be clear, by far the *ideal* fix is to have a `/usr` and `/etc` split 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 `%post` should 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)
Author
Owner

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 /usr vs /etc split (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/3674

This 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 dracut or equivalent after dnf update ca-certificates.

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 `/usr` vs `/etc` split (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/3674 This 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 `dracut` or equivalent after `dnf update ca-certificates`.

Let's be clear, by far the ideal fix is to have a /usr and /etc split 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.

This requires having two locations, /usr/lib/pki/ca-trust and /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 /etc configuration, 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.

> Let's be clear, by far the ideal fix is to have a /usr and /etc split 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. This requires having two locations, `/usr/lib/pki/ca-trust` and `/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 `/etc` configuration, 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.
Member

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.

I have an existing [base-image MR](https://gitlab.com/fedora/bootc/base-images/-/merge_requests/663/diffs) 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.
Member

@walters wrote in #145 (comment):

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.

IIUC coreos-update-ca-trust.service could potentially handle case 2, but it has ConditionFirstBoot=true so in practice doesn't actually handle case 2?

@walters wrote in https://forge.fedoraproject.org/atomic/tracker/issues/145#issuecomment-1369001: > 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. IIUC `coreos-update-ca-trust.service` could potentially handle case 2, but it has `ConditionFirstBoot=true` so in practice doesn't actually handle case 2?
Author
Owner

IIUC coreos-update-ca-trust.service could potentially handle case 2, but it has ConditionFirstBoot=true so 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.

> IIUC coreos-update-ca-trust.service could potentially handle case 2, but it has ConditionFirstBoot=true so 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.
Owner

I think we can consider this one fixed with https://gitlab.com/fedora/bootc/base-images/-/merge_requests/663 merged?

I think we can consider this one fixed with https://gitlab.com/fedora/bootc/base-images/-/merge_requests/663 merged?
Owner

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.

Until I can find the time to de-dup and rebase the manifests, I'm copying this fix for the Atomic Desktops in https://forge.fedoraproject.org/atomic-desktops/config/pulls/818.
Sign in to join this conversation.
No description provided.