Skip to content

Should security.pki.caCertificateBlacklist warn instead of error when encountering certificates not in the trust store? #249080

Open
nix-community/buildcatrust
#19

Description

@whentze

Describe the bug

You can use security.pki.caCertificateBlacklist to opt out of importing certain certificates from Mozilla's trust store. This is a very useful option for people who want to be extra cautious.

However, if a certificate that's on the blocklist gets removed by upstream (which is quite common, the lesser-known and lesser-trustworthy CAs are both the most likely to get blocklisted and to get removed upstream), the module will give a build error like this:

Certs in blocklist but not in cert store: {'Hongkong Post Root CA 1'}

In practice, this has some quite regrettable consequences. Folks who are proactive about CA management are punished by frequent breakage when they update nixpkgs. Worse: if you then remove those CAs from the blocklist, everything builds fine, but if the CAs are re-added to the original trust store (for instance because you downgraded nixpkgs again) you will silently start trusting them again! It is also highly inconvenient for anybody trying to write re-usable NixOS modules using this option that are supposed to work on several NixOS releases.

I think it would be much better if this was a warning, not a build error.

This behavior is inherited from buildcatrust: https://github.com/lukegb/buildcatrust/blob/2f613c36ddb3d0e032d2e145fe05bc4c7eb3d7d9/buildcatrust/cli.py#L128
Therefore, we might have to carry more patches for that if we want to change it.

Notify maintainers

This module doesn't seem to have any maintainers declared.

Activity

  1. added
    0.kind: bug
    on Aug 14, 2023
  2. whentze commented on Aug 14, 2023

    @whentze
    ContributorAuthor

    Pinging @fpletz and @lukegb who are listed as maintainers for pkgs.cacert

  3. lukegb commented on Aug 14, 2023

    @lukegb
    Contributor

    I'm not sure there's a great way of dealing with this.

    This is deliberately a fatal error because, if it isn't, it's easy to end up not distrusting what you thought you were distrusting because the name doesn't match exactly.

    If you're paranoid enough to want to distrust arbitrary CAs then you should already be keeping up to date with every cacerts bump anyway, because each new release might add a new CA that meets your criteria for being dropped. You can also parameterize your distrust list based on the cacerts version if you think you'll be moving backwards and forwards often.

    In terms of finding a middle ground, though: I'd be supportive of adding an option to buildcatrust to downgrade the error to a warning and then expose that in the module as an option, though.

  4. whentze commented on Aug 14, 2023

    @whentze
    ContributorAuthor

    Hey, thanks so much for the quick respones :)

    If you're paranoid enough to want to distrust arbitrary CAs then you should already be keeping up to date with every cacerts bump anyway, because each new release might add a new CA that meets your criteria for being dropped. You can also parameterize your distrust list based on the cacerts version if you think you'll be moving backwards and forwards often.

    That is a good point. In fact, I think a bunch of people would like an allowlist-type option instead.
    You can of course remove the entire trust-store and provide your own PEMs, but that is quite a steep usability cliff.
    Do you think an allowlist-by-name option that still takes the certificates thus named from the trust-store would be a good idea?

    In that scenario, if you misspell a CA's name, it would still build, but then later fail "loudly" as you get cert validation errors. So it is fail-safe in that sense.

  5. whentze commented on Apr 22, 2024

    @whentze
    ContributorAuthor

    Taking another look at this in the interest of Spring Cleaning.

    I think @lukegb's reasoning is sound, and the current somewhat inconvenient way is better than one that will silently fail to meet security requirements.

    We can still consider an allowlist-style option in a future issue, but I'll close this for now.

  6. nh2 commented on Nov 1, 2026

    @nh2
    Contributor

    I am reopening this because this isn't really a workable situation: It breaks automatic security updates.

    I used security.pki.caCertificateBlacklist to mitigate the eMudhra CA compromise

    only to notice some days later that this build error Certs in blocklist but not in cert store: {'emSign ECC Root CA - G3'} completly broke system.autoUpgrade and thus stopping ALL security updates of my servers, including the fix for CVE-2026-98432, the Linux IP options remote code execution bug (nixpkgs tracker).

    This drawback of caCertificateBlacklist was separately noticed in:


    No other blacklisting system I am aware of behaves like this, e.g. if you blacklist a kernel module, it'll not break your kernel from booting if that module doesn't exist.

    I understand the desire to not typo the name, but killing NixOS's main security update mechanism for it is the wrong tradeoff.

    If available at all, such a breaking mechanism should have the behaviour in the name, e.g. caCertificateBlacklistFailOnNonexistent, and the NixOS option description of that should make very clear how using it will break the system build in the future.

    Then caCertificateBlacklist itself should ignore nonexistent one, and perhaps output a nss-cacert package-build-time warning, instead of an error.

  7. reopened this on Nov 1, 2026
  8. nh2 commented on Nov 1, 2026

    @nh2
    Contributor

    Moving the discussion from #576485 (comment) to here:

    @lukegb In your newer feature --distrust_bundle_input you already support lenient-ness, right?

    It seems cleanest to me to just add a flag that makes the name-based check lenient, and then have both caCertificateBlacklistFailOnNonexistent for strong and caCertificateBlacklist for lenient.

    Then users can choose if they want to fail hard on absence or just "add to blacklist" behaviour.

  9. bjornfor commented on Nov 1, 2026

    @bjornfor
    Contributor

    Data point: I'd like the default to be eval time error, and if that's difficult, build time error. Degrading to warning only by opt-in.

  10. nh2 commented on Nov 1, 2026

    @nh2
    Contributor

    @bjornfor Eval feels difficult because of IFD. With my proposal there's no "default" option; there'd be 2 NixOS options (one failing loudly on absence in the certstore, one failing leniently), and they could even be combined (so you can name some certificates that shall fail loudly, and others that fail leniently).

  11. lukegb commented on Nov 1, 2026

    @lukegb
    Contributor

    --distrust_bundle_input doesn't really factor into this - any certs you provide there end up added to the cert store and then explicitly distrusted, so it doesn't really have the same problem and is useful for e.g. intermediates, because then you can keep root trust and drop the intermediate... on systems which can support that - so software that consumes the trust bundle that includes trust rules. upki will hopefully make this better, but we're not there yet.

    TBH I think it's a better UX than listing the names of the certs, but it's not in a release nor exposed as an option yet, in part due to the drawbacks.

  12. nh2 commented on Nov 1, 2026

    @nh2
    Contributor

    @lukegb I'm currently working on a draft option for what I suggest, for both buildcatrust and nixpkgs. Will ping you shortly.

  13. added a commit that references this issue on Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions