You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Admin events record an incorrect resource path when realm name casing differs in the request #55222
I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.
Area
admin/api
Bug Description
When a database uses a case-insensitive collation, an Admin API request can resolve a realm even if the realm name in the URL uses different casing from the stored name. The resulting admin event can contain an incorrect resourcePath because path extraction searches for the stored realm name using a case-sensitive comparison.
Version
main — the relevant code is present, but reproduction on the latest upstream release has not been verified.
Expected behavior
The admin event contains the path relative to the realm, regardless of the casing used to resolve the realm in the request.
Actual behavior
For a realm named ab, a request to /admin/realms/Ab/users/{userId} records lms/Ab/users/{userId} instead of users/{userId}.
How to Reproduce?
Configure a database with a case-insensitive collation and create a realm named ab.
Enable saving admin events for the realm.
Update a user through the Admin API using /admin/realms/Ab/users/{userId}.
Inspect the resulting admin event's resourcePath.
Anything else?
AdminEventBuilder.getResourcePath() searches the request path for /realms/{stored-realm-name}/. If the casing differs, the search returns -1, but the method still uses the result to calculate the substring offset.
The fix should cover all event paths derived from a request URI, not only user events. This includes both URI-based AdminEventBuilder.resourcePath overloads and the Admin API v2 builder, which uses a similar extraction pattern. Prefer shared extraction logic where practical, while accounting for the different API route prefixes.
I'm taking this on per the root cause analysis in the description — case-sensitive search for /realms/{stored-name}/ in AdminEventBuilder.getResourcePath() (and the matching pattern in the Admin API v2 event builder). A PR will follow.
Update: withdrawing — #55226 already covers this. Apologies for the noise.
Activity
keycloak-github-bot commentedon Nov 16, 2026
Due to the amount of issues reported by the community we are not able to prioritise resolving this issue at the moment.
If you are affected by this issue, upvote it by adding a 👍 to the description. We would also welcome a contribution to fix the issue.
Inf1mum commentedon Nov 16, 2026
I'm taking this on per the root cause analysis in the description — case-sensitive search for
/realms/{stored-name}/inAdminEventBuilder.getResourcePath()(and the matching pattern in the Admin API v2 event builder). A PR will follow.Update: withdrawing — #55226 already covers this. Apologies for the noise.
ahus1 commentedon Nov 16, 2026
Removing "help wanted" for now until the solution is clear.
IMHO realm names should be handled case-insensitively everywhere, other this is a normalization risk and security weakness.
With that, I suggest a request should be rejected (404) if the realm names do not match.