NokiaTube | New address | Mode Phone | On high quality
Skip to content

Authorization resource URI templates are not validated when imported #55592

Description

@sguilhen

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

authorization-services

Bug Description

Authorization resource URI templates are validated only when a resource is created or updated through the resource endpoints. Every path that stores resources from a ResourceServerRepresentation skips the validation entirely, so URI templates that the resource endpoints reject with a 400 are accepted and persisted without complaint.

PathMatcher.validateTemplate has a single call site, ResourceSetService.validateUris, reached from create and update. The import paths go through RepresentationToModel.toModel straight to Resource.updateUris, with no validation in between.

Validated:

  • POST/PUT /admin/realms/{realm}/clients/{id}/authz/resource-server/resource
  • Protection API resource_set create and update, which delegate to the same ResourceSetService

Not validated:

  • POST /admin/realms/{realm}/clients/{id}/authz/resource-server/import
  • Client create and update carrying authorizationSettings
  • Realm import and partial import, through RepresentationToModel.importAuthorizationSettings
  • Dynamic client registration update, through DefaultClientRegistrationProvider.updateAuthorizationSettings

The validation was added in 26.7.0 by #50291. Resources registered on earlier versions are also still stored as they were, since no migration inspects them.

Version

26.8.2, and main

Expected behavior

A URI template that the resource endpoints reject is rejected consistently, whichever way the resource reaches the store, or is at least reported rather than silently persisted.

Realm import deserves a decision of its own. Realms exported from 26.6 or earlier can legitimately contain templates that validation now rejects, so failing the whole import would turn this into an upgrade blocker. Logging a warning and importing the realm anyway may be the better trade-off there, even if the Admin API endpoints reject outright.

Actual behavior

The import paths accept the template and store it. The resource is then matched by PathMatcher like any other, so a pattern the Admin API refuses to register is fully live at runtime.

How to Reproduce?

Against 26.8.2 (quay.io/keycloak/keycloak:26.8.2 start-dev), with a client that has authorization services enabled.

  1. Create a resource on the resource endpoint:
POST /admin/realms/master/clients/{id}/authz/resource-server/resource
{"name":"via-resource-endpoint","uris":["/a/*.x/b"]}

Returns 400: URI [/a/*.x/b] is not a valid template: wildcard '*' is only supported as trailing '/*' or as a suffix pattern '/*.ext'

  1. Send the same URI to the import endpoint:
POST /admin/realms/master/clients/{id}/authz/resource-server/import
{"policyEnforcementMode":"ENFORCING","resources":[{"name":"via-import","uris":["/a/*.x/b"]}],"policies":[],"scopes":[]}

Returns 204, and a subsequent GET .../authz/resource-server/resource lists via-import with /a/*.x/b.

  1. The same URI is also accepted when creating a client with authorizationSettings (201), and when importing a realm whose client carries authorizationSettings (201, storing both /a/*.x/b and /api/*/info).

Anything else?

Follow-up to #55466. It is not the cause of that CVE, which involves /public/*.json, a template validation accepts, and is therefore reachable through the validated endpoints as well. It came up while reviewing how reachable the remaining wildcard shapes are.

The documentation should be corrected as part of this issue. docs/documentation/authorization_services/topics/resource-create.adoc currently states:

A wildcard in the middle of a path, such as /api/*/info, never matches and will be rejected when creating or updating resources.

Both halves are inaccurate.

A wildcard in the middle of a path matches whenever it takes the /*.ext form. A * is recognized as a wildcard only when it is the pattern's last character, or when it is preceded by / and followed by ., so /a/*.x/b is read as the prefix /a/, a wildcard, and the extension .x/b, and matches /a/evil.x/b. It is /api/*/info that is the special case: its * is followed by /, is never recognized as a wildcard, and the pattern is therefore treated as a literal path that matches only a request for /api/*/info itself.

The rejection applies to the resource endpoints only, which is the subject of this issue.

Activity

  1. added
    kind/bug
    on Nov 26, 2026
  2. added theissue type on Nov 26, 2026
  3. added
    area/authorization-services
    on Nov 26, 2026
  4. self-assigned this
    on Nov 26, 2026
  5. added a commit that references this issue on Nov 27, 2026
    94ec569
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/authorization-serviceskind/bugpriority/normalrelease/27.0.0team/core-iam

Type

Fields

No fields configured for bug.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions