8000 Add validation for blocked session note names in UserSessionNoteMapper by jimmychakkalakal · Pull Request #53559 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Add validation for blocked session note names in UserSessionNoteMapper - #53559

Merged
mposolda merged 5 commits into
keycloak:mainfrom
jimmychakkalakal:cve/53545-Fixes-an-issue-where-UserSessionNoteMapper
Nov 5, 2026
Merged

mposolda merged 5 commits into
keycloak:mainfrom
jimmychakkalakal:cve/53545-Fixes-an-issue-where-UserSessionNoteMapper

Conversation

@jimmychakkalakal
@jimmychakkalakal jimmychakkalakal commented Oct 5, 2026 •
Copy link
Copy Markdown
Contributor

Fixes a security vulnerability (CVE-2026-105302 / #53545) where OIDC and SAML UserSessionNoteMapper could expose sensitive broker credentials stored in user session notes (such as FEDERATED_ACCESS_TOKEN, FEDERATED_REFRESH_TOKEN, etc.) to unauthorized clients.

Closes #53545

Fixed with help of Claude

Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Client updates and existing or imported mappers can bypass validation and still expose credentials.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Adds validation intended to prevent OIDC session-note mappers from exposing federated credentials.

Changes:

  • Blocks four credential-bearing session-note names.
  • Adds create, update, bulk, and allowed-name tests.
File Description
UserSessionNoteMapper.java Adds blocked-note validation.
UserSessionNoteMapperValidationTest.java Tests mapper configuration validation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

8000
@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.adapter.servlet.SAMLServletAdapterTest#salesPostEncSignedAssertionsAndDocumentTest

Keycloak CI - Adapter IT Strict Cookies

org.opentest4j.AssertionFailedError: expected: <true> but was: <false>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertTrue.failNotTrue(AssertTrue.java:63)
	at org.junit.jupiter.api.AssertTrue.assertTrue(AssertTrue.java:36)
...

Report flaky test

@jimmychakkalakal
jimmychakkalakal force-pushed the cve/53545-Fixes-an-issue-where-UserSessionNoteMapper branch from fd6513f to 1f96a3a Compare October 6, 2026 10:34
@jimmychakkalakal
jimmychakkalakal requested a balanced review from Copilot October 6, 2026 10:37
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Client-scope validation remains bypassable, runtime protections lack integration coverage, and the documentation incorrectly describes V2 authorization.

Review effort: Balanced
Findings: 1 High severity · 4 Low severity

Open (5)
Resolved since last review (1)

@jimmychakkalakal
jimmychakkalakal force-pushed the cve/53545-Fixes-an-issue-where-UserSessionNoteMapper branch 2 times, most recently from 5aa39c0 to e774a1e Compare October 7, 2026 07:55
@jimmychakkalakal
jimmychakkalakal requested a balanced review from Copilot October 7, 2026 07:56
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Security-critical issuance fallback and client-scope validation paths lack regression coverage.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
Resolved since last review (5)

@jimmychakkalakal
jimmychakkalakal force-pushed the cve/53545-Fixes-an-issue-where-UserSessionNoteMapper branch from e774a1e to 9f9e3b1 Compare October 7, 2026 08:41
@jimmychakkalakal
jimmychakkalakal requested a balanced review from Copilot October 7, 2026 08:41
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The legacy-mapper issuance guard lacks regression coverage, and the upgrade documentation remains inaccurate for API V2.

Review effort: Balanced
Findings: 2 Low severity

Open (2)
Resolved since last review (1)

@jimmychakkalakal
jimmychakkalakal force-pushed the cve/53545-Fixes-an-issue-where-UserSessionNoteMapper branch from 9f9e3b1 to e701d59 Compare October 7, 2026 09:25
@jimmychakkalakal
jimmychakkalakal requested a balanced review from Copilot October 7, 2026 09:26
@jimmychakkalakal
jimmychakkalakal force-pushed the cve/53545-Fixes-an-issue-where-UserSessionNoteMapper branch from e701d59 to 24a4268 Compare October 7, 2026 09:26
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Import-time validation can reject valid client scopes before their referenced clients are created.

Review effort: Balanced
Findings: 1 High severity · 1 Low severity

Open (2)
Resolved since last review (2)

@jimmychakkalakal
jimmychakkalakal force-pushed the cve/53545-Fixes-an-issue-where-UserSessionNoteMapper branch 2 times, most recently from cbc79d5 to 0b0479a Compare October 7, 2026 11:14
@jimmychakkalakal
jimmychakkalakal requested a balanced review from Copilot October 7, 2026 11:15
Copilot AI left a comment
Copy li 10BC8 nk
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

OIDC issuance protection remains untested, and the documented legacy-client upgrade impact is incomplete.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
Resolved since last review (2)

Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Security-sensitive issuance changes and expanded import validation require maintainer review and integration-test confirmation.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 15, 2026 14:26
@jimmychakkalakal
jimmychakkalakal force-pushed the cve/53545-Fixes-an-issue-where-UserSessionNoteMapper branch from 6e5dcee to 0346798 Compare October 15, 2026 14:26
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Security-sensitive issuance changes and expanded mapper validation require maintainer compatibility review and integration-test confirmation.

0 open findings

🧠 Review effort: Balanced

@mposolda mposolda left a comment •
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jimmychakkalakal Thanks! I've added 2 comments inline.

Besides it, can you please also check if we don't have other "user session notes" in Keycloak, which have similar problems like those and which allow to disclose some data, which are not supposed to be added to tokens?

AFAIK we have built-in support for Kerberos GSS credential, which is OK (and it is even documented ). I do not recall anything else, but can you please doublecheck and confirm?
EDIT: I've asked this to you before, can you please confirm if you did not found anything else?

Copilot AI balanced review requested due to automatic review settings October 27, 2026 12:22
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Security-sensitive issuance changes and validation across provisioning paths warrant human review and integration-test confirmation.

No open issues 🎉

Review effort: Balanced

@jimmychakkalakal
Copy link
Copy Markdown
Contributor Author

@jimmychakkalakal Thanks! I've added 2 comments inline.

Besides it, can you please also check if we don't have other "user session notes" in Keycloak, which have similar problems like those and which allow to disclose some data, which are not supposed to be added to tokens?

AFAIK we have built-in support for Kerberos GSS credential, which is OK (and it is even documented ). I do not recall anything else, but can you please doublecheck and confirm? EDIT: I've asked this to you before, can you please confirm if you did not found anything else?

@mposolda Thanks for the comments. I checked every place that writes a session note in the core server. Only the IdP tokens and the transient-user model are sensitive, and both are blocked. The Kerberos credential is allowed on purpose. Everything else is harmless metadata.

Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Security-sensitive issuance filtering and expanded write/import validation need final human review supported by integration-test results.

No open issues 🎉

Review effort: Balanced

Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Security-sensitive changes to credential issuance, mapper validation, and import rollback require human review and integration validation beyond the source inspection available here.

No open issues 🎉

Review effort: Balanced

Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test module fails to compile because createSamlUnsignedRequest() returns HttpUriRequest, but its result is assigned to an HttpPost variable.

1 open issue

Review effort: Balanced

Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Security-sensitive changes to OIDC/SAML issuance and mapper validation need human review and integration testing to verify legacy compatibility and transactional rollback for rejected imports.

1 open issue

Review effort: Balanced

Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Client registration responses omit newly persisted pairwise mapper salts, so reusing a response in a subsequent PUT can regenerate the salt and change users’ subject identifiers.

1 open issue
1 resolved since last review

Review effort: Balanced

Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human review is needed to confirm third-party compatibility and issuance/import behavior because whole-client writes and realm imports invoke every installed mapper’s validator, including configuration-mutating validators.

1 open issue

Review effort: Balanced

@mposolda mposolda left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jimmychakkalakal Thanks for the updates! Can you please rebase to fix the conflict?

Also there is one inline comment (related to copilot review). Can you please check it and confirm if it is valid or not? If valid comment, can you please fix it?

Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical issues cause valid client creation to fail with NullPointerException/500 and registration-token-authenticated updates to fail with 401 after token rotation.

2 open issues
1 resolved since last review

Review effort: Balanced

@jimmychakkalakal
Copy link
Copy Markdown
Contributor Author

@jimmychakkalakal Thanks for the updates! Can you please rebase to fix the conflict?

Also there is one inline comment (related to copilot review). Can you please check it and confirm if it is valid or not? If valid comment, can you please fix it?

Thanks @mposolda I have rebased the branch with latest changes. I have fixed the issue related to copilot comment

Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical authentication regressions cause valid client creation requests to return 500 and registration-token updates to return 401, while rebuilding the creation response also drops default roles.

3 open issues

Review effort: Balanced

Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed because realm-import validation may miss the separately imported admin-permissions client when fine-grained permissions V2 is enabled, allowing a blocked session-note mapper.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

Prevent OIDC/SAML session note mappers from exposing federated IdP tokens (e.g. FEDERATED_ACCESS_TOKEN), which allowed bypassing the broker read-token role.

- Reject sensitive notes in mapper and client validation (APIs, DCR, CIMD, imports).
- Omit blocked notes at token issuance to safeguard legacy or imported mappers.
- Return HTTP 400 instead of 500 for invalid clients during realm import.
- Document breaking change in 26.8.1 upgrading guide.

Closes keycloak#53545

Signed-off-by: Jimmy Chakkalakal <jimmy.chakkalakal@ibm.com>

# Conflicts:
#	docs/documentation/upgrading/topics/changes/changes-26_8_1.adoc

# Conflicts:
#	docs/documentation/upgrading/topics/changes/changes-26_8_1.adoc

# Conflicts:
#	services/src/main/java/org/keycloak/validation/DefaultClientValidationProvider.java
Prevent OIDC/SAML session note mappers from exposing federated IdP tokens (e.g. FEDERATED_ACCESS_TOKEN), which allowed bypassing the broker read-token role.

- Reject sensitive notes in mapper and client validation (APIs, DCR, CIMD, imports).
- Omit blocked notes at token issuance to safeguard legacy or imported mappers.
- Return HTTP 400 instead of 500 for invalid clients during realm import.
- Document breaking change in 26.8.1 upgrading guide.

Closes keycloak#53545

Signed-off-by: Jimmy Chakkalakal <jimmy.chakkalakal@ibm.com>

# Conflicts:
#	docs/documentation/upgrading/topics/changes/changes-26_8_1.adoc
Closes keycloak#53545

Signed-off-by: Jimmy Chakkalakal <jimmy.chakkalakal@ibm.com>

# Conflicts:
#	docs/documentation/upgrading/topics/changes/changes-27_0_0.adoc

# Conflicts:
#	docs/documentation/upgrading/topics/changes/changes-27_0_0.adoc
…nses

Validators can initialize protocol mapper configuration (e.g. pairwise mapper salt).
The current implementation returns a response built BEFORE validation, so
validation-generated values are lost.

For CREATE and UPDATE, refresh the client representation from the database after
validation to ensure validation-generated config is included in the response.

Fixes Copilot comment on protocol mapper validation: if the salt is omitted from
the CREATE/UPDATE response, a subsequent PUT with that response overwrites the
stored salt, causing regeneration and changing users' sub values.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

Signed-off-by: Jimmy Chakkalakal <jimmy.chakkalakal@ibm.com>
Closes keycloak#53545

Signed-off-by: Jimmy Chakkalakal <jimmy.chakkalakal@ibm.com>
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The CVE remediation changes OIDC/SAML credential-exposure boundaries across client and realm-import paths, requiring end-to-end security and import-compatibility validation beyond static review.

No open issues 🎉

Review effort: Balanced

@mposolda mposolda left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jimmychakkalakal Thanks for the patience with this one! I hope to finally merge once tests are OK (hope there will not be another conflict in the meantime :-) )

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CVE-2026-105302] SECURITY] Keycloak 26.7.3: User Session Note mapper exposes upstream access tokens to managed clients

3 participants

0