8000 Keycloak Policy Enforcer: an extra leading slash turns a denied request into a granted one · Issue #55374 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Keycloak Policy Enforcer: an extra leading slash turns a denied request into a granted one #55374

Description

@abstractj

Describe the bug

The Keycloak policy enforcer can be made to skip authorization checks for a protected path when the request uses an extra leading slash. The enforcer has a shortcut: when an incoming request targets the configured on-deny-redirect-to page (the access-denied page, which must be publicly reachable), it short-circuits the request as granted without evaluating any role, scope, or UMA permission.

To decide whether a request is for that deny page, the enforcer parses the request path with java.net.URI. Per RFC 3986, a path beginning with // is read as a network-path reference, so the text up to the next slash is treated as an authority rather than part of the path. A request target such as //admin/ is therefore parsed down to /, which matches a deny page configured as /, and the enforcer grants the request. On a servlet container that preserves the // in getRequestURI() while routing the request on the collapsed path, the container then dispatches the request to the protected resource (/admin/), so a caller who is not authorized for that resource reaches it with all policy checks skipped.

This is an incomplete fix of CVE-2026-9800 (GHSA-f5p5-6xmx-p252). That fix replaced the earlier substring comparison in the deny-page check with an exact comparison after normalization, but it normalizes with java.net.URI alone, which does not collapse a leading //. The sibling PathMatcher.normalizeUri() already collapses repeated slashes before URI parsing and documents this exact pitfall; the deny-page check was not given the same treatment.

The effect is limited: only the first path segment is consumed as the authority, so only single-segment paths of the form //<segment>/<deny-page> are reachable, and the on-deny-redirect-to option must be set (it is unused in the default 403 behavior). In practice the exposed set is meaningful only when the deny page is /. The behavior reproduces on the generic Jakarta servlet filter on Apache Tomcat; it does not reproduce on the supported WildFly (Undertow) or Quarkus (Vert.x) stacks, where the request either is not dispatched to the protected resource or is normalized before the enforcer evaluates it. Because it is not reachable on a supported stack, it is handled as a weakness rather than a CVE.

Version

keycloak-policy-enforcer 26.0.10 through 26.0.12 as reported, and unchanged on main (commit 88d55ade). The same code is present through the latest release, 26.0.13.

Expected behavior

The deny-page check should normalize the request path the same way PathMatcher.normalizeUri() does — collapsing repeated slashes before parsing — so that //<segment>/<path> and /<segment>/<path> are compared as equal. A request to a protected path should be denied regardless of a leading //, and a relative path that parses with an authority component should be rejected rather than reduced to its path.

Actual behavior

The deny-page check parses the request path with java.net.URI without collapsing a leading //. A request such as //admin/ is parsed to the deny page, so the enforcer grants it and skips every role, scope, and UMA permission check; on a container that routes the // request to the protected resource, the unauthorized caller reaches that resource.

Acknowledgement

Thank you to Yunfei Yang for reporting this issue. As the behavior is only reachable through the generic servlet filter on Apache Tomcat and not on a supported Keycloak stack, it is handled as a weakness and addressed publicly.


This issue was originally tracked in the private repository. Migrated by @abstractj.

Activity

  1. added
    area/authorization-services
    priority/important
    area/admin/client-java
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/admin/client-javaarea/authorization-serviceskind/weaknesspriority/importantteam/core-iamteam/core-shared

    Fields

    No fields configured for weakness.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0