Repository navigation
Description
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.
Metadata
Metadata
Assignees
Labels
Type
Fields
Projects
- StatusShow more project fieldsOpen
Activity