-
Notifications
You must be signed in to change notification settings - Fork 25.7k
X509AuthnToken cache key change for proxied-PKI #44810
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
X509AuthnToken cache key change for proxied-PKI #44810
Conversation
|
Pinging @elastic/es-security |
bizybot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! LGTM, Thank you.
|
Can you explain the source of these inconsistencies that you mention? |
When we authenticate against cache we do not do cert chain validation, in case the incoming request has the same end-entity certificate but just different CA certs (ordered but not the CA certs that issued certificate) then we just authenticate using the certificate thumbprint and allow authentication, that would be wrong. |
|
@tvernum Sorry I've been too abstract in the description. A simple example is when a client calls the API with the full chain, and another client calls the API only with the end entity cert (the same end entity cert from the other client's chain). The first one is correct, according to our specs, and the second one is wrong. When you factor in the current cache implementation, the call from the second client might be successful if the call from the first client came in first and populated the cache. |
|
I don't have a problem with this change, but I still don't understand why we need it. You say
But where do we enforce that? I can't see it in So if we don't enforce it, why does the caching behaviour make any difference? |
|
But we do enforce a complete chain.
For example, given this chain: |
|
Let's discuss offline. |
x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/pki/PkiRealm.java
Outdated
Show resolved
Hide resolved
|
@tvernum where the javadoc for with the relevant part mentioning that this is an Given what we've discussed, does this PR look OK for merging? (I think it does) |
|
@albertzaharovits In that case (as a separate piece of work) should we require that the chain passed in to the delegated_pki API must also be a full chain from client to root CA? I think it would be more consistent for the realm to know that chains are always complete, than have delegated-pki be a bit different. From a Kibana perspective, the Node.js APIs are similar to the Java ones (at least according to the docs, I haven't done thorough testing) you can get the client certificate itself, or the end-to-end chain but I don't believe that Kibana will ever have, or pass to us, a partial chain. |
No this is not necessary. From RFC 5280:
However, the JRE doesn't mind if it is included or not (this is covered in tests as well).
Just to be clear, it does not matter if we're talking about the delegation scenario or the usual one, the certificates in the |
The
X509AuthenticationTokencontains the certificate chain that the PKI realm validates and parses out the principal from. This validation is guarded by a cache for which the key computation, given anX509AuthenticationToken, does a sha256 of the encoding of the first certificate in the chain. Given that the same end entity certificate cannot be validated by different CAs with different certification paths (at least in practice) the cache key computation saves cycles by not evaluating the complete chain. This assumption does not hold anymore, in the case that the certificate chain is passed by the delegate-pki-authn API, because in that case the certificate chain given must be a complete chain, it must not be a prefix of another chain. The current implementation exposes inconsistencies in cases where only the client certificate (not the full path) are passed in the API request after (and not before) the complete path for that same certificate has been cached.Relates #34396