8000 Admin events record an incorrect resource path when realm name casing differs in the request · Issue #55222 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Admin events record an incorrect resource path when realm name casing differs in the request #55222

Description

@pedroigor

Before reporting an issue

  • 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?

  1. Configure a database with a case-insensitive collation and create a realm named ab.
  2. Enable saving admin events for the realm.
  3. Update a user through the Admin API using /admin/realms/Ab/users/{userId}.
  4. 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.

Activity

  1. added
    kind/bugCategorizes a PR related to a bug
    area/admin/apiAdmin REST API (v1) — managing realms, users, clients, roles, groups
    on Nov 16, 2026
  2. added theissue type on Nov 16, 2026
  3. keycloak-github-bot commented on Nov 16, 2026

    @keycloak-github-bot

    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.

  4. Inf1mum commented on Nov 16, 2026

    @Inf1mum
    Contributor

    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.

  5. ahus1 commented on Nov 16, 2026

    @ahus1
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    No fields configured for bug.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0