8040 Commits

Author SHA1 Message Date
Kosiorkosa47 c3f34c3515 Tighten UNSAFE_PATH_PATTERN against encoded path-traversal terminators (#49000)
* Tighten UNSAFE_PATH_PATTERN against encoded path-traversal terminators

Fixes #48978

Extends the regex to cover encoded forms that previously bypassed
detection:
  - %3B / %3b (encoded semicolon)
  - %09, %0A, %0D, %00 (control characters)
  - %252E (double-encoded dot)

These encodings do not produce actual path traversal on conformant
servers per RFC 3986 (percent-encoded characters are literals, not
delimiters), but are semantically close enough to the patterns the
regex was designed to block to warrant defense-in-depth coverage.

The end-of-input anchor ($) is moved into the terminator class to
collapse the two pattern alternatives into one, keeping the diff
minimal.

Test changes:
  - 8 new assertions covering encoded semicolons, control character
    terminators, and double-encoded dots.
  - 3 prior assertEquals flipped to assertNull (lines that previously
    asserted %252E%252E/, %252E%252E/#fragment, and ..%3Bsomething/
    were allowed are now expected to be blocked).
  - 1 new negative test confirming %3B as legitimate path content (not
    following a parent-folder sequence) still resolves.

Triple-encoded variants (e.g., %25252E) remain allowed; out of scope
for this issue.

Signed-off-by: Michał Kosiorek <michal.kosiorek@arklink.co>

* Update OAuthRedirectUriTest expectations for double-encoded dots

Follow-up to 36b0b10dd2 — Base IT (6) CI run for #49000 caught a
cross-module integration test that needed updating alongside the
regex change. Local verification of the previous commit covered the
services module (RedirectUtilsTest); testsuite/integration-arquillian
was outside that scope, so the existing OAuthRedirectUriTest.testWildcard
expectations for %252E%252E variants didn't flip with the regex.

Four assertions in testWildcard flipped from true → false to match the
Option A semantic introduced in 36b0b10dd2 (double-encoded dots are
now blocked by UNSAFE_PATH_PATTERN):

  http://example.com/foo/%252E%252E/
  http://example.com/foo/%252E%252E/?some_query_param=some_value
  http://example.com/foo/%252E%252E/?encodeTest=a%3Cb
  http://example.com/foo/%252E%252E/#encodeTest=a%3Cb

Triple-encoded (%25252E) and septuple-encoded variants remain
expected:true — recursive decoding is explicitly out of scope for
#48978.

Verified locally:
  - mvn -pl services -Dtest=RedirectUtilsTest test → 11/11 green.
  - Direct regex match against the four flipped URIs confirms
    UNSAFE_PATH_PATTERN matches each rawPath, mechanically equivalent
    to the verifyRedirectUri code path exercised by the arquillian test.

Refs #48978

Signed-off-by: Michał Kosiorek <michal.kosiorek@arklink.co>

---------

Signed-off-by: Michał Kosiorek <michal.kosiorek@arklink.co>
2026-05-21 17:23:27 +02:00
Martin Kanis 3b940e65b5 Account API: Resource sharing endpoints ignore userManagedAccessAllowed realm setting
Closes #48987

Signed-off-by: Martin Kanis <mkanis@ibm.com>
2026-05-21 15:28:04 +02:00
Martin Kanis ba5d4bf165 Account resource sharing resolves recipient by username before email, granting access to wrong user
Closes #49086

Signed-off-by: Martin Kanis <mkanis@ibm.com>
2026-05-21 15:27:30 +02:00
Giuseppe Graziano 4a1defaeab adds missing tests to TokenIntrospectionTest
Closes #49208

Signed-off-by: Giuseppe Graziano <g.graziano94@gmail.com>
2026-05-21 14:47:01 +02:00
Šimon Vacek feca053c2e Refactor legacy test suite's ExportImportResource (#48967)
Closes: #48966

Signed-off-by: Simon Vacek <simonvacky@email.cz>
2026-05-21 09:15:19 +00:00
rmartinc 69b3503a0f Use runOnServerMaster on LightWeightAccessTokenTest
Closes #49192

Signed-off-by: rmartinc <rmartinc@redhat.com>
2026-05-21 09:41:12 +02:00
Šimon Vacek 440f9a90f2 Move the rest of TestingResource methods to a utils-shared helper class (1/2) (#48722)
* Move the rest of TestingResource methods to a utils-shared helper class (1/2)

Closes: #48708

Signed-off-by: Simon Vacek <simonvacky@email.cz>

* rename runOnServer field

Signed-off-by: Simon Vacek <simonvacky@email.cz>

* remove realm name from method input

Signed-off-by: Simon Vacek <simonvacky@email.cz>

---------

Signed-off-by: Simon Vacek <simonvacky@email.cz>
2026-05-21 05:55:20 +00:00
Giuseppe Graziano a1405663f7 Token introspection now validates audience claim. UserInfo endpoint rejects lightweight access tokens.
Closes #49113

Signed-off-by: Giuseppe Graziano <g.graziano94@gmail.com>
2026-05-20 18:23:06 +02:00
mposolda 6ef5a79876 [OID4VCI] Integration of user verifiable-credentials with credentials-endpoint and credential-offers
closes #48547

Signed-off-by: mposolda <mposolda@gmail.com>
2026-05-20 16:06:19 +02:00
rmartinc d0e0b0f1f7 Use EventAssertion in some remaining tests.
Closes #49142

Signed-off-by: rmartinc <rmartinc@redhat.com>
2026-05-20 13:44:14 +02:00
Pedro Igor 33f6f873fd Prevent access to user info if not the owner or requested of a resource (#49122)
Closes #49116

Signed-off-by: Pedro Igor <pigor.craveiro@gmail.com>
2026-05-20 07:54:53 +02:00
Lukas Hanusovsky 69182286ef Refactor AssertEvents expect() and related methods to use EventAssertion equivalents. (#48752)
Signed-off-by: Lukas Hanusovsky <lhanusov@redhat.com>
2026-05-20 07:18:03 +02:00
Pedro Igor 4e9b17cbed Enforce owner checks when calling the resource set service (#49121)
Closes #392

Signed-off-by: Pedro Igor <pigor.craveiro@gmail.com>
2026-05-20 05:24:16 +02:00
Ricardo Martin d791b270b9 Better check for authSessionCookie in SessionCodeChecks (#603) (#49134)
Closes CVE-2026-7507
Closes #49111

Signed-off-by: rmartinc <rmartinc@redhat.com>
2026-05-20 05:16:17 +02:00
Giuseppe Graziano c5bda802e9 fix not before validation
Closes #49118

Signed-off-by: Giuseppe Graziano <g.graziano94@gmail.com>
2026-05-19 19:39:54 +02:00
Giuseppe Graziano 56bbfa3d8a set only redirect_uri from client_data during restart
Closes #49110

Signed-off-by: Giuseppe Graziano <g.graziano94@gmail.com>
2026-05-19 19:17:44 +02:00
Yike Gao 4aff9a43ce migrated RequiredActionUpdateProfileTest. Closes #48149 (#48648)
Signed-off-by: Yike Gao <yikegao8@gmail.com>
2026-05-19 11:12:12 +02:00
Steve Hawkins ce38c5b135 fix: making the embedded resteasy server work again
closes: #49058

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
2026-05-18 19:21:03 +02:00
Steven Hawkins 74cbbe75eb fix: further rationalizing how we are creating temporary files (#48608)
closes: #48566

Signed-off-by: Steve Hawkins <shawkins@redhat.com>
2026-05-18 12:18:47 +02:00
Martin Bartoš 0981d2411c RAR scope parsing should explicitly accept client reference (#48981)
Closes #48980

Closes #45716

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
2026-05-18 08:48:37 +02:00
Palash Thakur 6d3dd321e7 Return invalid_client for introspection client auth failures
Closes #48721

Signed-off-by: Palash Thakur <117917450+palasht75@users.noreply.github.com>
2026-05-15 15:42:13 +02:00
Thomas Diesler ce12c7184c [OID4VCI] Add a client policy to require a credential offer (#47286)
closes #44317


Signed-off-by: Thomas Diesler <tdiesler@proton.me>
2026-05-14 17:04:36 +02:00
rmartinc 4cca6f7088 Allow using the parameter in the consent text for dynamic scopes
Closes #9915

Signed-off-by: rmartinc <rmartinc@redhat.com>
2026-05-14 10:30:23 -03:00
Umberto Toniolo bc5444d082 Fix NPE in OrganizationGroupMembershipMapper when no organization scope is requested
OrganizationGroupMembershipMapper.resolveFromRequestedScopes() calls
OrganizationScope.valueOfScope() which returns null when the request does
not include an organization scope. The method then calls
resolveOrganizations() on the null reference, causing a NullPointerException.

This mirrors the null guard already present in OrganizationMembershipMapper.

Closes #48834

Signed-off-by: Umberto Toniolo <amountainram@gmail.com>
2026-05-14 10:29:56 -03:00
Šimon Vacek e52ea63766 Refactor legacy test suite's TimeOffset (#48756)
* Create fake timeoffset object

Signed-off-by: Simon Vacek <simonvacky@email.cz>

* Remove AbstractKeycloakTest#invokeTimeOffset

Signed-off-by: Simon Vacek <simonvacky@email.cz>

* Remove TestinResource#setTimeOffset & #getTimeOffSet

Signed-off-by: Simon Vacek <simonvacky@email.cz>

* Remove AbstractKeycloakTest#setTimeOffset & getTimeOffset

Signed-off-by: Simon Vacek <simonvacky@email.cz>

---------

Signed-off-by: Simon Vacek <simonvacky@email.cz>
2026-05-13 06:53:32 +02:00
vramik 97d1f46038 Migrate OrganizationTest
Closes #48922

Signed-off-by: vramik <vramik@redhat.com>
2026-05-12 16:22:12 -03:00
Peter Skopek a3cac62f18 Migrate OID4VCJWTIssuerEndpointDisabledTest and OID4VCSdJwtIssuingEndpointDisabledTest
Closes #48743

Signed-off-by: Peter Skopek <peter.skopek@ibm.com>
2026-05-12 19:18:23 +02:00
Peter Skopek 0cb7046dc2 Migrate JwtCredentialSignerTest, SdJwtCredentialSignerTest
Closes #48543

Signed-off-by: Peter Skopek <peter.skopek@ibm.com>
2026-05-12 19:16:23 +02:00
Giuseppe Graziano 868db724f5 remove oid4vc protocol from create client form
Closes #46853

Signed-off-by: Giuseppe Graziano <g.graziano94@gmail.com>
2026-05-12 15:22:49 +02:00
Stian Thorgersen 38600730a4 Unify mail in old and new testsuites (#48785)
Closes #48784

Signed-off-by: stianst <stianst@gmail.com>

# Conflicts:
#	testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/ssl/TrustStoreEmailTest.java
2026-05-11 15:20:14 +02:00
Ryan Emerson 81af44c0e9 Allow Token Exchange of sender constrained tokens issued for the
original client

Closes #47314

Signed-off-by: Ryan Emerson <remerson@ibm.com>
2026-05-11 13:47:22 +02:00
Jon Koops 087e03b0da Add OAuth 2.0 compliant redirect URI validation
Enforce RFC 6749 Section 3.1.2 redirect URI rules (no fragments, no wildcards) via a new "OAuth 2.0 Compliant" client policy flag. This is less strict than the existing OAuth 2.1 flag, which additionally bans localhost and requires HTTPS.

Also fixes the "complient" typo in the existing OAuth 2.1 field and method names.

Closes #41164

Signed-off-by: Jon Koops <jonkoops@gmail.com>
2026-05-11 13:42:21 +02:00
Giuseppe Graziano b814ff8003 rest credential offer experimental feature
Closes #46279

Signed-off-by: Giuseppe Graziano <g.graziano94@gmail.com>
2026-05-11 10:24:36 +02:00
Michal Vavřík b3602649f6 chore(tests): migrate ssl package to new test framework (#48407)
* Closes: https://github.com/keycloak/keycloak/issues/47812

Signed-off-by: Michal Vavřík <michal.vavrik@aol.com>
2026-05-11 10:16:33 +02:00
Pedro Ruivo e4bfc408ab Fix MSSQL queries to work with case sensitive collations
Closes #48584

Signed-off-by: Pedro Ruivo <1492066+pruivo@users.noreply.github.com>
Co-authored-by: Pedro Ruivo <1492066+pruivo@users.noreply.github.com>
2026-05-07 16:10:17 +02:00
Martin Bartoš 8e808ca15f [CVE-2026-7500] Improper Access Control on Keycloak Server when the account Account API feature is disabled
Closes #48709

Signed-off-by: Martin Bartoš <mabartos@redhat.com>
2026-05-07 15:57:04 +02:00
Yike Gao 4692aeee5d Reject CORS requests with invalid Origin before endpoint logic runs
Closes #45957

Signed-off-by: Yike Gao <yikegao8@gmail.com>
2026-05-07 09:16:15 +02:00
Pedro Igor 1ccce63aa4 Resolve SA before resolving users from username or email
Closes #48592

Signed-off-by: Pedro Igor <pigor.craveiro@gmail.com>
2026-05-07 07:32:43 +02:00
Šimon Vacek c5eacd473e Remove unused TestingResource methods (#48711)
Closes: #48710

Signed-off-by: Simon Vacek <simonvacky@email.cz>
2026-05-06 15:26:13 +02:00
Lukas Hanusovsky ba108b0c5f Rewrite AssertEvents expectLogout and expectLogoutError into EventAssertion methods. (#48638)
Signed-off-by: Lukas Hanusovsky <lhanusov@redhat.com>
2026-05-06 12:53:01 +02:00
Šimon Vacek ccdf98228d Refactor runonserver APIs for easier test migration (#48363)
Signed-off-by: Simon Vacek <simonvacky@email.cz>
2026-05-06 12:52:21 +02:00
Sar 263d44be88 Changes to address Org subdomain matching (#45190)
Signed-off-by: sar <sar.haidar@gmail.com>
2026-05-05 08:53:15 +02:00
Giuseppe Graziano 7691ba4840 DPoP for implicit flow
Closes #48428

Signed-off-by: Giuseppe Graziano <g.graziano94@gmail.com>
2026-05-05 08:44:04 +02:00
Sven-Torben Janus 67ef87bd21 Make OrganizationGroupMembershipMapper claim name configurable (#47852)
* Make OrganizationGroupMembershipMapper claim name configurable

The OrganizationGroupMembershipMapper introduced in 26.6.0 hardcoded
the token claim name to "organization", unlike OrganizationMembershipMapper
which already exposes the claim name as a configurable property.

- Add TOKEN_CLAIM_NAME config property to OrganizationGroupMembershipMapper
  via OIDCAttributeMapperHelper.addTokenClaimNameConfig()
- Override getEffectiveModel() to default the claim name to
  OAuth2Constants.ORGANIZATION when not set, preserving backward
  compatibility for existing mapper configurations
- Set TOKEN_CLAIM_NAME default in the static create() factory method
- Refactor OIDCAttributeMapperHelper.getOrInitializeOrganizationClaimAsMap()
  to accept a ProtocolMapperModel instead of a raw String, delegating
  to mapClaim() for correct claim placement (including nested path support)

Closes #47851

Signed-off-by: Sven-Torben Janus <sven-torben.janus@conciso.de>

* Fix nested claim path read and add custom claim name tests

The read side of getOrInitializeOrganizationClaimAsMap was doing a flat
Map.get() on the dotted claim name, while the write side (mapClaim) already
creates a nested structure by splitting on dots. This caused the group mapper
to find nothing when the claim name contained a dot, overwriting the
membership data written by OrganizationMembershipMapper.

Fix by splitting the claim path via splitClaimPath() and traversing the
nested map with a new private getNestedClaimValue() helper in
OIDCAttributeMapperHelper. The helper belongs there rather than in JsonUtils
because it operates on Map<String,Object>, not JsonNode.

Also add integration tests covering:
- Custom flat claim name ("my_orgs") for both OrganizationMembershipMapper
  and OrganizationGroupMembershipMapper, verifying the claim appears at the
  configured name and not at "organization"
- Dotted claim name ("custom.org") for OrganizationGroupMembershipMapper,
  verifying the token contains nested otherClaims["custom"]["org"] and that
  group composition is preserved

Signed-off-by: Sven-Torben Janus <sven-torben.janus@conciso.de>

---------

Signed-off-by: Sven-Torben Janus <sven-torben.janus@conciso.de>
2026-05-04 16:30:59 +02:00
Lukas Hanusovsky 8cfd971c7f Refactor SSSD tests to use JUnit5 Assertions. (#48673)
Signed-off-by: Lukas Hanusovsky <lhanusov@redhat.com>
2026-05-04 14:24:48 +00:00
Tomohiko Ozawa d55a25a92d fix: trigger INVITE_ORG and REGISTER event when a new user is invited
Signed-off-by: Tomohiko Ozawa <kota65535@gmail.com>
2026-05-04 10:10:23 -03:00
Alexander Schwartz c045765b45 Prevent ASCII control characters in query parameters
Closes #46740

Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
2026-05-04 15:02:34 +02:00
Pedro Igor fd47bda1fc Enforce resource server predicates if one was given despite the IS_ADMIN flag (#48385)
Closes #48324

Signed-off-by: Pedro Igor <pigor.craveiro@gmail.com>
2026-05-04 11:27:46 +02:00
Lukas Hanusovsky 4f47022641 Rewrite AssertEvents expectLoginEvent to EventAssertion. (#48467)
Signed-off-by: Lukas Hanusovsky <lhanusov@redhat.com>
2026-05-04 11:26:47 +02:00
Peter Zaoral 310f61a84f [quarkus-next] Model tests fail due to ByteBuddy removal from Hibernate runtime classpath (#48560)
Closes: #48559

Signed-off-by: Peter Zaoral <pzaoral@redhat.com>
2026-04-30 07:10:54 +00:00