Issuer 45649: patch CVE-2026-0707. Add validation on Authorization Header with Bearer#45787
Conversation
rmartinc
left a comment
There was a problem hiding this comment.
Thanks @ValeriaEpifanova for the PR! I added some suggestions and besides we will need tests for this.
I created a quick test using the admin whoAmI endpoint in this class. You can create more methods that test other prefixes like commented in the issue (BEARER , Bearer , Bearer\t,...).
There is only snag for this, current implementations that uses some spaces or different case will fail after this PR. I don't know if we need a configuration to revert to the previous wrong behavior or not. We have used previously configurations in the OIDC factory to allow old behaviors (for example in this commit fa383bf). @mposolda WDYT? Do we allow previous behavior with a switch or do we just follow the spec?
services/src/main/java/org/keycloak/services/managers/AppAuthManager.java
Outdated
Show resolved
Hide resolved
services/src/main/java/org/keycloak/services/managers/AppAuthManager.java
Outdated
Show resolved
Hide resolved
services/src/main/java/org/keycloak/services/managers/AppAuthManager.java
Show resolved
Hide resolved
|
If the change is just the space I would go without any configuration switch. So just add the test class and check that several spaces or a tab is not valid. Let's see what the maintainers think about this. Thanks @ValeriaEpifanova! |
|
@ValeriaEpifanova @rmartinc +1 that bearer should be case-insensitive. It probably does not increase security to treat it case-sensitive, but rather introducing issues. We had already issues in the past when people using Hopefully we can go without config option on this. +1 to just have a test and should be good to go IMO. |
|
Thanks for the review @rmartinc @mposolda . I've added tests. I took the class you @rmartinc created for this purpose and added more tests. I've also fixed the code, but I've left the header validation case-insensitive. |
rmartinc
left a comment
There was a problem hiding this comment.
Thanks @ValeriaEpifanova! I think that it's OK, just a minor comment but I don't think that it is important. And it's usually better doing rebase instead of merge to update the branch. @mposolda please launch the tests and check if this is OK to you.
|
|
||
| String tokenString = split[1]; | ||
| if (ObjectUtil.isBlank(tokenString)) { | ||
| if (ObjectUtil.isBlank(tokenString) || tokenString.contains(" ")) { |
There was a problem hiding this comment.
Is there any difference adding the tokenString.contains(" ") or not adding it?
There was a problem hiding this comment.
There is a difference. For example, "Bearer 2SP token" is not blank, so the code would continue processing the token. If next space after first was before token value. Token value will be " token".
There was a problem hiding this comment.
But I suppose token would fail because it's not a valid token for the space at the beginning. But no problem, now we have tests, so we are covered.
There was a problem hiding this comment.
You're right, and at first I thought the same thing. But the point of the CVE is that, according to the RFC, there must be strictly one space between Bearer and token.
credentials = "Bearer" 1*SP b64token
|
Got it, thanks @rmartinc — I’ll keep your advice about using rebase instead of merge in mind for the future. |
0417d35 to
a1e5dc7
Compare
|
Hey @ValeriaEpifanova! The build is failing because the imports, just run |
e2c749f to
da8f486
Compare
…ader with Bearer, add tests Signed-off-by: Valeria Epifanova <[email protected]>
da8f486 to
fd5225a
Compare
|
Done @rmartinc |
mposolda
left a comment
There was a problem hiding this comment.
@ValeriaEpifanova @rmartinc Thanks!
…er, add tests (keycloak#45787) Closes keycloak#45649 Signed-off-by: Valeria Epifanova <[email protected]> (cherry picked from commit 05ff44b)
…er, add tests (keycloak#45787) Closes keycloak#45649 Signed-off-by: Valeria Epifanova <[email protected]> (cherry picked from commit 05ff44b) Signed-off-by: rmartinc <[email protected]>
…er, add tests (keycloak#45787) Closes keycloak#45649 Signed-off-by: Valeria Epifanova <[email protected]> (cherry picked from commit 05ff44b) Signed-off-by: rmartinc <[email protected]>
…er, add tests (keycloak#45787) Closes keycloak#45649 Signed-off-by: Valeria Epifanova <[email protected]>
Closes #45649
Add validation on Authorization Header to fix GHSA-gv94-wp4h-vv8p: