News for hackers. Stuff that matters.
Re:Linux Certificate Authority root stores have a too simple... by ayende on Tuesday December 06, 2022 @03:36AM (#33877193)
There is no API to actually handle trust. If you are asking `curl` or `openssl` to verify the chain, it needs to read it from somewhere. By convention, there is `OPENSSLDIR`, for example.

But that just tells us where the root certs are, not much more. In the API, I load the root CAs and check validity of the cert, nothing beyond that.

And I can do that in multiple different TLS engines.

Given that there is no API for this, all the TLS engines need to re-implement this logic. Hell, in most cases, even things like validity range checks are handled by the applicative logic.

On Windows, there is the builtin TLS API `schannel` which means that you have a lot more structure / order in this. Including the ability to express those sort of details.

There is another aspect, as well. You need to be able to express those issues as errors, otherwise the user is going to be left with a broken box and no idea what is going on.

Re:Linux Certificate Authority root stores have a too simple... by deathanatos on Tuesday December 06, 2022 @03:47AM (#33877244)
Yeah, TFA seems to make a good argument for a libca-certificates, or so.

> There is another aspect, as well. You need to be able to express those issues as errors, otherwise the user is going to be left with a broken box and no idea what is going on.

TLS libraries are terrible at this. Part of it is C: the "integer is the only error type you'll ever need" cannot convey the necessary context, such as which cert is the problem.

Having a library might also help with path building bugs. I've seen bugs in both OpenSSL and GnuTLS in building a correct path, and both just from when the ISRG cross-sign expired.

… and maybe a more complicated data structure in /etc/certs (or whatever the path is) will keep prying vendors out. I've seen a lot of people make out of band changes there, and I would suspect those qualify as "undefined behavior", but OpenSSL's docs don't seem to answer the question of "what happens if vendors do random stuff?" (Like drop non-CA certs into the list of CAs, or don't update the symlinks that seem to form an index…)

Re:Linux Certificate Authority root stores have a too simple... by kelnos on Tuesday December 06, 2022 @04:09AM (#33877352)
> TLS libraries are terrible at this. Part of it is C: the "integer is the only error type you'll ever need" cannot convey the necessary context, such as which cert is the problem.

Not really; I mean, sure, the validation function will probably rely on returning an integer error code, but there's no reason that the API couldn't also provide a function to retrieve the certificate chain at hand, where an application could walk the chain backwards to the root and figure out the last one (er, or first one, depending on how you look at it) that isn't trusted.

Whether an application would choose to go to the trouble to make use of these APIs is another matter, of course. At any rate, from perspective of the average user, TLS errors are already not so easy to understand, so giving detailed information in this case might not be all that helpful anyway. Just a simple "we don't trust this website, so you shouldn't either" is about as much as most users would understand, probably.

Re:Linux Certificate Authority root stores have a too simple... by ayende on Tuesday December 06, 2022 @04:51AM (#33877596)
That assumes that the application even know to check the "only valid if issued before" flag.
Re:Linux Certificate Authority root stores have a too simple... by kelnos on Tuesday December 06, 2022 @04:01AM (#33877312)
> There is no API to actually handle trust.

The various TLS libraries already agree on at least one thing: what certificates look like on disk (e.g. PEM and DER formats). There's no reason why some committee couldn't sit down and standardize a format for ancillary data such as the trust date cutoffs mentioned here. Then the TLS libraries would have to implement it, and return appropriate errors from their validation functions. This could possibly be done in a way without needing applications to also be updated, though that depends on how each TLS library reports validation errors.

But even if a particular TLS library doesn't have a way to express these errors properly, I think it's better to have a user confused as to why they can't connect to a site, than silently connect to a site "protected" by a certificate that shouldn't be trusted.

Re:Linux Certificate Authority root stores have a too simple... by blibble on Tuesday December 06, 2022 @04:23AM (#33877441)
> The various TLS libraries already agree on at least one thing: what certificates look like on disk (e.g. PEM and DER formats).

Java would like a word with you :(

Re:Linux Certificate Authority root stores have a too simple... by mike_hearn on Tuesday December 06, 2022 @04:51AM (#33877597)
Java uses those formats too.

Java actually solves the complaint in this thread, and has done for a long time. The JDK has its own root store program run by Sun and now Oracle, TLS APIs use the bundled root store automatically, it provides tools to manage that root store, exceptions are easily rendered to users in a generic way, and it provides a mix of high and low level APIs.

What you're probably thinking of is the JKS format. Java defined a way to represent a root store on disk that's Java specific, I think because there was no standard at the time. But it migrated to the PKCS#12 format in recent releases.

Re:Linux Certificate Authority root stores have a too simple... by GauntletWizard on Tuesday December 06, 2022 @08:05AM (#33879007)
Java has the exact opposite of a solution to this, though their intentions were very admirable. PKCS#12 is a terrible solution, and Java does it's best to enforce it, and it's move to adopt it further is the exact opposite direction that everyone has been moving in.

What everyone's realized in recent years is that trust is context-dependent, and that you don't want to use the same roots of trust (or trust anchors, or CAs, though each of those terms has a slightly different meaning) everywhere, nor do you want to co-mingle them. It doesn't make sense to have one file that specifies "Here are all the CAs I trust, and here are rules for each of them"; It makes a lot more sense to have configuration per use-case of "Here are all the CAs for this usecase", and to rely much more on code within the program to disambigutate. Having one file with all those CA certificates and your private keys is... Backwards. Keytool and their custom format at least kept a clear distinction between "these are my private keys" and "these are keys I trust". PKCS#12 has no such distinction, and the tooling around it (Particularly Java's!) makes it hard to disambiguate safebags, so you're left with one giant mess.

It's actually the same problem as Global Variables[1]; Security and trust isn't one object. It's many. One program may act as itself to many providers, but it might also act as three or four different roles within it's scope to the same provider.

[1] https://dl.acm.org/doi/10.1145/953353.953355

Re:Linux Certificate Authority root stores have a too simple... by mike_hearn on Tuesday December 06, 2022 @11:52AM (#33883127)
Well, but the default of having a bag of certs with a trust store program does make sense - apps want to just be able to talk to random web servers in a secure manner and that's the only way to get that.

In many use cases you could use a store with only a self-signed certificate. That works, the APIs make it straightforward enough. It has many advantages when possible, e.g. you can set the expiry time to so far in the future it never expires, you don't have to muck about with LetsEncrypt and CAs. You do have to control the client and the server. If your frontend is a web app that's a problem. If it's a mobile or desktop app that's easy. Control over the client has other advantages too like not needing HTTP load balancers anymore (in many cases), reducing costs.

Re:Linux Certificate Authority root stores have a too simple... by GauntletWizard on Wednesday December 07, 2022 @12:05AM (#33890809)
That is one bag of trust, yes. "The web CA pool" (there's not just one, there's actually at least four in common use in America (Google/Chrome, Mozilla, Microsoft, and Apple), with several more besides)

But most modern apps don't just connect to the internet, they connect to internal stuff like databases using TLS as well. It's actually a valid strategy to just use the web trust pool for that as well - I personally use it in places, with the certificate managed by CertBot reused for the webserver and the postgres server.

It's not a solution for the modern enterprise, where mutual TLS is sometimes a requirement and is attractive if not. You will want to have at least one non-web CA pool (Trust Bundle) for your enterprise, and sometimes several more for other departments, or other companies you collaborate with.

Re:Linux Certificate Authority root stores have a too simple... by firebird84 on Tuesday December 06, 2022 @08:19AM (#33879199)
Unfortunately (in the case of TRUST stores) it uses pkcs12 in a non-standard way. You cannot, for example, use openssl pkc12 to create a p12 store java can read. Java expects some oracle-specific non-standard attributes on the bag.

PKCS12 keystores work fine, however.

Re:Linux Certificate Authority root stores have a too simple... by cesarb on Tuesday December 06, 2022 @06:35AM (#33878235)
Java has always been its own separate world. For instance, recently we had daylight saving issues on a server (we no longer have daylight savings time, but the Java application thought it had just started). The server did have an updated timezone database with the correct rules... but Java uses a separate timezone database, which hadn't been updated.
Re:Linux Certificate Authority root stores have a too simple... by throw0101c on Tuesday December 06, 2022 @07:30AM (#33878642)
Java has used the standard PKCS12 format by default since version 9:

* https://openjdk.org/jeps/229

* https://en.wikipedia.org/wiki/PKCS_12

* https://openjdk.org/projects/jdk9/

Re:Linux Certificate Authority root stores have a too simple... by jeltz on Tuesday December 06, 2022 @07:44AM (#33878771)
Yeah, this confused me when working with java because some of the tools just silently changed to generating PKCS12 certificates when the same options used to generate their proprietary format.
Re:Linux Certificate Authority root stores have a too simple... by ak217 on Tuesday December 06, 2022 @09:08AM (#33879968)
> There's no reason why some committee couldn't sit down and standardize a format for ancillary data such as the trust date cutoffs mentioned here

They already have (https://www.rfc-editor.org/rfc/rfc5280.html, https://www.rfc-editor.org/rfc/rfc6960.html) but CRL/OCSP functionality not implemented in most libraries because it's hard and thankless work.

Re:Linux Certificate Authority root stores have a too simple... by Ajedi32 on Tuesday December 06, 2022 @09:32AM (#33880478)
AFAIK those are standards for allowing CAs to revoke certificates. Trust conditions for root stores are a completely different thing.

Or at least, I'm certainly not aware of any mechanism in the CRL standard to "partially revoke" a CA certificate based on complex conditions like "What's the notBefore date on the leaf certificate we're currently validating?".

Re:Linux Certificate Authority root stores have a too simple... by ak217 on Tuesday December 06, 2022 @11:54AM (#33883165)
Ah I see, you're right I guess they didn't contemplate the scenario of "we want to distrust this CA - against its wishes - but we still trust it enough to make it an orderly transition instead of an emergency". I guess it was previously assumed that CA trust would be binary and that CAs would be cooperative - seems like a pretty common evolution that internet standards go through.

The problem is, code that handles these things is safety critical and requires real and sustained investment to be reliable. Given this overhead (and the gaps in CRL/OCSP support that I mentioned), it's unclear if this use case will be common enough to commit to supporting.

Re:Linux Certificate Authority root stores have a too simple... by e12e on Tuesday December 06, 2022 @04:28AM (#33877482)
> There is no API to actually handle trust.

We might need something more - but I wonder i trust-stores could be modified so that:

- every device get a "host" CA (like a ssh key)

- this CA is the only one trusted

- in turn, this CA signs issuer/top-level CA (or even cross-signs the intermediary certs directly) (eg with - new/-force_pubkey)

Additional logic could be applied in the signing step - say rules to set the validity, or rules to sign/not-sign. One might set a 48h lifetime, and run a crown job every night - allowing for "dynamic" "revocation" (cert expiry).

Not sure if this would work out of the box though - I have not looked that deep into ca and ca trust.

Re:Linux Certificate Authority root stores have a too simple... by mike_hearn on Tuesday December 06, 2022 @04:56AM (#33877619)
Certificates advertise if they're meant to be roots or not and libraries enforce that via things like the path length constraints, so it wouldn't work. But it also just seems kind of complicated - how is that any easier than just updating the root store in a cron job, which is already done via normal package maintenance routines anyway?

The reason the Linux root stores don't have a notion of 'trust until' like the article wants is simple - nothing stops an untrusted CA just issuing certificates that claim to have been issued before the cutoff, so it seems pointless. Browsers have ways to tackle that like Certificate Transparency or crawling the web to try and identify every extant cert, but most apps don't use that.

Re:Linux Certificate Authority root stores have a too simple... by xg15 on Tuesday December 06, 2022 @07:15AM (#33878506)
Linux root stores could piggyback on the browsers' efforts here though. The attack scenario you described was sensible in the past, so it didn't make sense for non-browser clients to go ahead with "trust until".

However, now CAs can't really do this anymore, because - as you say - they'd risk immediate exclusion from browsers if this is detected via CT analysis. So Linux distros can actually benefit from CT and browser's impact in the CA space in an indirect manner.

There is definitely a power imbalance though. E.g., even if a distro implemented "trust until", they could not realistically make their own rules that are stricter than what browsers do: CAs could backdate certs so they get accepted by the distro, but if browsers consider the CA fully trusted, they might not care about the backdated certificates.

Re:Linux Certificate Authority root stores have a too simple... by siebenmann on Tuesday December 06, 2022 @06:39PM (#33888671)
I think it's more that Linux root stores date from an era when everyone approached CA trust as a binary thing (even browsers), and there has never been enough pressure and coordination to evolve them into a more complex system, unlike browsers. My memory is that browsers added conditional distrust and conditional limits on CAs and various similar things when they became convinced that it would be too bad of a user experience to simply remove CAs but also too dangerous to retain them in fully empowered form. Having conditional distrust also gave browsers more power over CAs, because now browsers had more options for dealing with marginal but (semi-)popular ones.

(I'm the author of the linked-to entry.)

Re:Linux Certificate Authority root stores have a too simple... by tinus_hn on Tuesday December 06, 2022 @05:35AM (#33877825)
There’s a surprising amount of old Unix software like Postfix, that by default doesn’t actually validate certificates.
Re:Linux Certificate Authority root stores have a too simple... by gjvc on Tuesday December 06, 2022 @06:19AM (#33878144)
Postfix is not old. Sendmail is old :-)
Re:Linux Certificate Authority root stores have a too simple... by usr1106 on Tuesday December 06, 2022 @08:55AM (#33879736)
When I renewed my Let's Encrypt certifcate the last time I noticed that my postfix was still using the certificate that had expired 3 months later. I don't receive a whole lot of email on that machine, but I did not notice any delivey failures.

I started to think (but not check specs): Is it even defined what domain name should be checked? MX records can be different from server names. Maybe certificate checking is just not defined for SMTP over TLS?

Re:Linux Certificate Authority root stores have a too simple... by tinus_hn on Tuesday December 06, 2022 @12:21PM (#33883657)
Considering you basically can only get a certificate for a domain name that refers to a host (and offering an IP address for an unqualified domain name is an anomaly) I’d expect the required subject to be the hostname. But the RFC does not specify it:

  The decision of whether or not to believe the authenticity of the
   other party in a TLS negotiation is a local matter. However, some
   general rules for the decisions are:

    - A SMTP client would probably only want to authenticate an SMTP
      server whose server certificate has a domain name that is the
      domain name that the client thought it was connecting to.
However in the case of Postfix there’s also the matter of connection to services like an ldap server to check things. In that case it’ll also by default happily connect to an ldaps service with a self signed, expired certificate.
Re:Linux Certificate Authority root stores have a too simple... by usr1106 on Tuesday December 06, 2022 @08:16PM (#33889523)
Thanks for the reference. But this does not seem to make sense. Email delivery is about interoperability. How can that be achieved if parties make their local decisions?

P.S. As you probably guessed in my previous comment "3 months later" should of course have been "3 months earlier". Sorry about the mistake.

Re:Linux Certificate Authority root stores have a too simple... by tinus_hn on Wednesday December 07, 2022 @05:26AM (#33892749)
It’s delivering email, there is no way for the receiving site to state a certificate is required anyway. Traditionally it’s just a plaintext connection on port 25 and using and supporting STARTTLS is optional.

I suppose you could write up a way to specify this in DNS but it’d take decades to be implemented and you would have to deal with pushback from the snoops who I’m sure don’t mind they can peep into the email you receive.

Re:Linux Certificate Authority root stores have a too simple... by usr1106 on Wednesday December 07, 2022 @06:01PM (#33901621)
I guess the support of TLS was added for confidentiality and integrity on untrusted networks. If you don't verify the certificate a MITM attack is possible. So what is the remaining benefit of using TLS?
Re:Linux Certificate Authority root stores have a too simple... by dontbenebby on Tuesday December 06, 2022 @05:37AM (#33877840)
If you reflect on trusting trust too long, you’ll drive yourself mad.
Re:Linux Certificate Authority root stores have a too simple... by cryptonector on Tuesday December 06, 2022 @10:47AM (#33881940)
If you can name a set of trust anchors (e.g., with an environment variable, in a configuration parameter, in a command-line argument, as a function/method parameter), then you've got the power to specify what to trust contextually. The problem is that a) apps usually don't give you such a control, and b) the names of these sets of trust anchors have to be meaningful to users.

(b) is a pretty tough problem!