Fix JWE request object signature bypass - #50565
Merged
Merged
Conversation
Closes keycloak#49429 Signed-off-by: Giuseppe Graziano <g.graziano94@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses CVE-2026-9793 by ensuring that when a client requires signed OIDC request objects, a JWE-encrypted request object whose decrypted payload is raw JSON (not a nested signed JWS) is rejected, and adds an integration test to cover the bypass scenario.
Changes:
- Enforce rejection of decrypted JWE payloads that are not a signed JWS when
requestObjectSignatureAlgis configured. - Add an integration test that submits a JWE-wrapped unsigned JSON request object and asserts the request is rejected.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
services/src/main/java/org/keycloak/jose/jws/DefaultTokenManager.java |
Adds enforcement when JWE plaintext is not a JWS and the client requires request-object signatures. |
testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/oidc/OIDCAdvancedRequestParamsTest.java |
Adds a regression test for rejecting JWE-wrapped unsigned JSON request objects when signatures are required. |
Comment on lines
155
to
165
| try { | ||
| JOSE jws = JOSEParser.parse(new String(content)); | ||
|
|
||
| if (jws instanceof JWSInput) { | ||
| jwtValidator.accept(jws, client); | ||
| return verifyJWS(client, clazz, (JWSInput) jws, allowNoneAlgorithm); | ||
| } | ||
| } catch (Exception ignore) { | ||
| // try to decrypt content as is | ||
| } catch (Exception e) { | ||
| logger.debug("Decrypted JWE content is not a valid JWS", e); | ||
| rejectUnsignedContentIfSignatureRequired(client); | ||
| } |
Comment on lines
+1587
to
+1592
| KeysMetadataRepresentation.KeyMetadataRepresentation encKey = KeyUtils | ||
| .findActiveEncryptingKey(managedRealm.admin(), Algorithm.PS256); | ||
| PublicKey encryptionKey = keysForUse.get(encKey.getKid()); | ||
|
|
||
| JWE jwe = new JWE().header(new JWEHeader(RSA_OAEP, JWEConstants.A256GCM, null)).content(contentBytes); | ||
| jwe.getKeyStorage().setEncryptionKey(encryptionKey); |
jimmychakkalakal
approved these changes
Jul 10, 2026
jimmychakkalakal
left a comment
Contributor
There was a problem hiding this comment.
Thanks @graziang for PR. Look good to me, I approve the PR
graziang
added a commit
to graziang/keycloak
that referenced
this pull request
Jul 14, 2026
Closes keycloak#49429 Signed-off-by: Giuseppe Graziano <g.graziano94@gmail.com> (cherry picked from commit 959a48d)
graziang
added a commit
to graziang/keycloak
that referenced
this pull request
Jul 15, 2026
Closes keycloak#49429 Signed-off-by: Giuseppe Graziano <g.graziano94@gmail.com> (cherry picked from commit 959a48d)
pskopek
pushed a commit
that referenced
this pull request
Jul 15, 2026
pskopek
pushed a commit
that referenced
this pull request
Jul 15, 2026
graziang
added a commit
to graziang/keycloak
that referenced
this pull request
Jul 20, 2026
Closes keycloak#49429 Signed-off-by: Giuseppe Graziano <g.graziano94@gmail.com> (cherry picked from commit 959a48d)
stianst
pushed a commit
that referenced
this pull request
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #49429