-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Improve TLS handling in OpenIDConnectAuthenticator #4417
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
base: master
Are you sure you want to change the base?
Conversation
I’m sending a small security improvement for the OIDC authenticator. When the kubeconfig doesn’t include idp-certificate authority-data the code leaves sslContext as null and falls back to the OS trust store. This can behave differently depending on the environment and isn’t always secure. In this update I added a default SSLContext that always uses the system CA.... If the user provides a custom CA, that one is still loaded and used instead. No behavior change other than making TLS more consistent and safer. Thanks!
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: abnsy The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
|
|
Welcome @abnsy! |
|
Can you clarify (especially w/ pointers to documentation) why this is preferable to using the OS default key store? |
Sure....happy to clarify.....The main reason is consistency. When sslcontext is null Java falls back to whatever CA bundle the OS or JVM provides. On containers, Windows, Linux distros,or JVM vendors the trusted roots can be completely different....By initializing SSLContext explicitly, the client always behaves the same way and we know exactly what trust store is used... JSSE also recommends using your own SSLContext if you want predictable TLS behavior https://docs.oracle.com/javase/8/docs/technotes/guides/security/jsse/JSSERefGuide.html#Customization Not trying to override the OS trust store just avoiding the silent fallback that varies across environments... thanks |
| TrustManagerFactory defaultTmf = | ||
| TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); | ||
| defaultTmf.init((KeyStore) null); | ||
| SSLContext defaultSslContext = SSLContext.getInstance("TLS"); |
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.
Let's switch this to "TLSv1.2" to make it consistent with the code below, we may want to switch to configuring the SSL engine to support both TLSv1.2 and TLSv1.3, but I definitely don't want to potentially enable older versions of TLS.
|
So it seems to me that by specifying a It also seems to me based on reading https://docs.oracle.com/javase/8/docs/technotes/guides/security/jsse/JSSERefGuide.html#CustomizingStores that you can specify all this stuff via java properties and the defaults will just work. Perhaps it would be useful to add a unit test which illustrates the problem with the current code and then show how this update fixes it? Apologies for being picky here, but whenever we mess with encrypt/auth code I want to make sure it's for a good reason. |
Thanks for the detailed feedback that helps. About the null keystore part you’re right that when you do tmf.init((KeyStore) null), you end up with whatever CA set the JVM/OS provides The intent wasn’t to replace that, but to make the behavior explicit
So the fallback is whatever the platform feels like, while explicitly On the unit test idea.....yeah, that makes sense. I can put together a small test
|
I’m sending a small security improvement for the OIDC authenticator. When the kubeconfig doesn’t include idp-certificate authority-data the code leaves sslContext as null and falls back to the OS trust store. This can behave differently depending on the environment and isn’t always secure. In this update I added a default SSLContext that always uses the system CA.... If the user provides a custom CA, that one is still loaded and used instead. No behavior change other than making TLS more consistent and safer. Thanks!