GPT-6.1 Sol · Heavy

implement-access-token-context-encoding-framework-keycloak

Keycloak · Java · L · 300–799 lines · 6 files

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Haiku 5.5.

Gold bugs found
0 of 0
Comments published
5
Comments matching a bug
0
Comments not matching
5
Cost of this PR
$2.597

Published comments (5)

mediumbugservices/src/main/java/org/keycloak/protocol/oidc/TokenManager.java:1052-1054

Client-credentials tokens encode an unknown grant instead of cc — Client-credentials tokens encode `na` because `ClientCredentialsGrantType.process` calls `generateAccessToken()` without the `Constants.GRANT_TYPE` attribute normally set by `createTokenResponse()`. Set that attribute before generating the access token so its encoded context identifies the actual grant.

mediumbugservices/src/test/java/org/keycloak/protocol/oidc/encode/DefaultTokenContextEncoderProviderTest.java:79-83

Incorrect-grant test passes on an unrelated NullPointerException — Catching `RuntimeException` lets the test pass on a `NullPointerException` from uninitialized `sessionFactory`, even if unknown-grant validation is removed. Initialize `sessionFactory` with an empty provider stream and assert `IllegalArgumentException` specifically.

mediumbugservices/src/main/java/org/keycloak/protocol/oidc/encode/DefaultTokenContextEncoderProviderFactory.java:73-76

Invalid-width grant shortcuts produce token IDs that cannot be decoded — Custom shortcuts longer than two characters make `encodeTokenId` produce IDs that `getTokenContextFromTokenId` rejects with `IllegalArgumentException`. Validate that `gtf.getShortcut()` returns exactly two characters before registration, including dynamic paths, and document this constraint on the factory interface declaring `getShortcut()`. **Also found in:** - `server-spi-private/src/main/java/org/keycloak/protocol/oidc/grants/OAuth2GrantTypeFactory.java:30-31`

mediumbugtestsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AssertEvents.java:483

Grant matcher checks the wrong substring and accepts mismatched grants — Tokens with incorrect grants pass event assertions because `substring(3, 5)` reads the wrong segment and equality rejects matches rather than mismatches. Check the prefix length before using `substring(4, 6)`, and return false when it differs from `expectedGrantShortcut`.

mediumbugservices/src/main/java/org/keycloak/protocol/oidc/encode/AccessTokenContext.java:73

Duplicated grantType check allows null rawTokenId — `AccessTokenContext` accepts a null `rawTokenId`, which `encodeTokenId` serializes as the literal suffix `:null` rather than preserving the original value. Change `Objects.requireNonNull` to check `rawTokenId` instead of checking `grantType` again.

Gold bugs found (0)

None.

Gold bugs missed (0)

None.