-
Notifications
You must be signed in to change notification settings - Fork 18k
crypto/x509: Verify fails to find valid path when some paths have EKU constraint violations #48869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
cc @FiloSottile |
Thank you for the report! This is indeed something we don't handle in the path building logic. We are thinking a lot about these "alternative path" situations right now because of #46287, and I am curious how you encountered this. Since we don't do AIA nor we extract system intermediates, for this to happen in TLS the peer would have to send both A and C, which feels unlikely, right? What other scenario leads to this? (I am asking not because we wouldn't like to fix this instance, but because there are other similar cases that would be way more complex to fix, and we need to understand how likely they are.) /cc @golang/security @rolandshoemaker |
Yea, this was part of a synthetic set of tests I've been putting together to evaluate path building in TLS clients. I've been building them through a few real-life examples of things like previous CA expiration but also some artificial examples from RFCs, etc. This was the only thing where the Go implementation did anything unexpected. I would completely agree that anything like this seems unlikely to come up in a real-life use-case. If fixing it in general is complex, especially in the context of those other changes, I certainly wouldn't sweat this corner case. :) |
Excellent, thank you! We'll look at how complex it would be to handle this, and the adjacent case where there is a name constrained path and an unconstrained path, which would break in the same way. My guess is that we'll be able to make it work with the Go path builder, but might have to take the hit when using platform verifiers, because we can't easily dictate rules at path building time, and if the system verifier doesn't do EKUs (we do them nested) or NCs (we apply them to all leaf names) the same way we do, it will give us only the "wrong" path. This sounds like an extremely useful testing effort, by the way. Thank you for doing it. If you'd like to upstream the test cases, we'd be more than glad to merge them! |
For reference, it looks like this is the result of running the https://github.com/Netflix/bettertls scanner. |
Change https://go.dev/cl/389555 mentions this issue: |
What version of Go are you using (
go version
)?1.17.2
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?What did you do?
The path building in x509/verify.go appears to fail to find a valid path when some paths are invalid due to EKU constraints on intermediate CAs.
The certificates in this test case form the following graph (lifted from RFC 4158, figure 7):
There are seven certificates (besides the self-signed certificate for the trust anchor), but the certificate "C => B" has an "Email Protection" EKU which causes it to be considered invalid for this x509.Verify call (which requires CAs to allow for Server Authentication EKU). Despite this certificate being invalid, x509.Verify should be able to find a path such as "Trust Anchor => C => A => B => EE".
A test case reproducing this is below. Note that simply excluding the first intermediate cert below allows x509.Verify to find the expected path.
The text was updated successfully, but these errors were encountered: