Replies: 8 comments 31 replies
-
One complicating factor here is that currently Admin APIs doesn't return the created the client representation when it is created, which makes it impossible to return the plain text secret if it's generated by Keycloak and stored as a hash. Another issue is that client secrets are for some reason validated by the ClientModel, which doesn't have access to the KeycloakSession and can't get access to a client secret hashing provider. |
Beta Was this translation helpful? Give feedback.
-
Not sure about the "not necessary to salt". If I am not mistaken, salts are not only used to add entropy to weak passwords but also to prevent using precomputed rainbow tables with key/hash values. |
Beta Was this translation helpful? Give feedback.
-
Started some rough prototype here: https://github.com/stianst/keycloak/tree/client-secret-hashing |
Beta Was this translation helpful? Give feedback.
-
As we discussed, another small issue (in addition to admin console and admin REST API) is client registration read request https://datatracker.ietf.org/doc/html/rfc7592#section-3 and similar request in client management specs https://datatracker.ietf.org/doc/html/rfc7592#section-3 . These are supposed to return client secret, which we won't be able to do with hashing. Also there is this "Installation" tab, which is supposed to return keycloak.json with client secret. If we want to improve this, we may need to encrypt the secret before storing to the DB with some "secret value", which is not stored in the DB (like vault option or something like that). But that is another complexity though? So I guess we just live with the fact that secrets are not returned from any of those places if secret hashing is enabled? |
Beta Was this translation helpful? Give feedback.
-
Hashing the client secret also impacts clients using the |
Beta Was this translation helpful? Give feedback.
-
Was there a continuation of this discussion? The last comment seems to be asking to clarify the priority. It surprises me that the client secrets are stored in plain text in the database. Are they considered that much less sensitive than user passwords? |
Beta Was this translation helpful? Give feedback.
-
I want a hashing secret feature, but it seems to be a hard work and breaking change. |
Beta Was this translation helpful? Give feedback.
-
I can take a stab on implementing client secret hashing. I collected some notes from here about possible impacts https://gist.github.com/tsaarni/be561c8ea8bdcdb2ebe02d30937eb7e0. Any other pointers? @stianst You mentioned you had a PoC at one point #8455 (comment) but it does not seem to exist anymore? It seems to me that the current password hashing support and |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
For clients, and especially service accounts, it would be beneficial to enabling hashing of client secrets, to prevent abuse if they are leaked.
Client secrets should be long and randomly generated as such do not need to be hashed with as computationally expensive hashing algorithms as user passwords, nor do they need to be salted as they should already be randomly generated. As such a straight-forward one-way hash is more than sufficient.
A realm should have an option to configure client secret hashing algorithm from:
This should be done through a ClientSecretHashingSPI to make it easy to introduce further hashing algorithms in the future if needed.
After the client secret hashing algorithm has been updated new client secrets should be hashed with the new algorithm. It is also required to store which hashing algorithm was used alongside the hashed client secret, since this can change overtime for a realm.
One thing to note is that once a client secret is hashed it is no longer possible to retrieve the client secret through the admin console after the client has initially been created, or the password has been updated. This can be considered an additional hardening as it prevents further leak of client secrets.
JIRA: https://issues.redhat.com/browse/KEYCLOAK-15842
Beta Was this translation helpful? Give feedback.
All reactions