8000 [CVE-2026-97175] Block auto-linking when IdP email is unverified by msdaly200 · Pull Request #54900 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

[CVE-2026-97175] Block auto-linking when IdP email is unverified - #54900

Merged
rmartinc merged 1 commit into
keycloak:mainfrom
msdaly200:54707
Nov 12, 2026
Merged

rmartinc merged 1 commit into
keycloak:mainfrom
msdaly200:54707

Conversation

@msdaly200
Copy link
Copy Markdown
Contributor

Closes #54707

Unverified IdP emails could be used to auto-link a brokered identity to an existing consumer account, enabling account takeover without any user interaction.

IdpAutoLinkAuthenticator did not check whether the email provided by the IdP was actually verified before using it to link an existing user account. Change is also documented.

@msdaly200
msdaly200 requested a review from a team as a code owner November 9, 2026 09:54
Copilot AI balanced review requested due to automatic review settings November 9, 2026 09:54
@msdaly200 msdaly200 changed the title Added check for trusted email [CVE-2026-97175] Block auto-linking when IdP email is unverified Nov 9, 2026
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 email-trust guard still permits unverified-email account linking through username collisions and rejects legitimate links after email ownership confirmation.

2 open issues
What changed in this PR

This PR hardens identity-provider auto-linking against unverified-email account takeover, addressing #54707.

Changes:

  • Adds email trust and verification checks and blocks auto-linking after email or username edits during profile review.
  • Expands broker-login regression coverage for trusted, unverified, edited, and mapped identities.
  • Documents the behavior change and upgrade considerations.
File Description
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​broker/​KcOidcFirstBrokerLoginDetectExistingUserTest.java Marks the successful auto-link test’s provider email as verified.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​broker/​IdpCreateUserIfUniqueAuthenticatorTest.java Adds auto-link security, success, and fallback scenarios.
services/​src/​main/​java/​org/​keycloak/​authentication/​authenticators/​broker/​IdpAutoLinkAuthenticator.java Adds profile-edit and email-trust guards before linking.
server-spi-private/​src/​main/​java/​org/​keycloak/​broker/​provider/​BrokeredIdentityContext.java Exposes the broker email’s verification status.
docs/​documentation/​upgrading/​topics/​changes/​changes-27_0_0.adoc Documents auto-link restrictions and Trust Email upgrade guidance.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 9, 2026 11:23
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

An attacker-controlled mapped email can retain the original email_verified flag and bypass the auto-link guard even with Trust Email disabled, enabling account takeover.

1 open issue
2 resolved since last review

Review effort: Balanced

@sschu
sschu commented Nov 11, 2026
Copy link
Copy Markdown
Contributor

@msdaly200 The changes introduced here (ead08a2) broke existing behaviour. Before 26.6.8, when the external IDP does not set email_verified and Trust email was enabled on the IDP, Keycloak would set email_verified to true. Now it is set to false when it is not set by the UserInfo Endpoint.

This change here (#54268) would only check the ID token for email_verified in addition to the UserInfo Endpoint.

Was this breaking change intended? It breaks for example with Entra ID because they never send email_verified but a special claim containing the list of verified email addresses. IMHO, the old behaviour was useful and since it is not the default to have Trust email enabled, it was safe. When I enable it, I know what I am doing.

8000
@msdaly200
msdaly200 commented Nov 11, 2026 •
Copy link
Copy Markdown
Contributor Author

Thanks @sschu for pointing this out. This was not intentional. The issue is addressed in #54268, which is currently waiting for approval.

Once #54268 is backported, providers like Entra ID that omit email_verified will correctly retain the previous behavior and set email_verified=true when Trust Email is enabled. There is also a test - testTrustEmailWhenEmailVerifiedClaimIsMissingFromUserInfo for this.

@sschu
sschu commented Nov 11, 2026
Copy link
Copy Markdown
Contributor

@msdaly200 From my understanding of #54268 , it would not fix this issue. It just adds a lookup into the ID Token when the claim is missing in the Userinfo endpoint. The behavior is the same when email_verified is missing in UserInfo and ID Token. Or am I missing something?

@msdaly200
Copy link
Copy Markdown
Contributor Author

@sschu You're right that #54268 specifically adds the ID token fallback logic, so had to dig a bit, but it was branched after #53580 (commit 34bcada - "Regression with Trust Email when the userinfo endpoint is used"), which fixed the Boolean.parseBoolean parsing bug from ead08a2.

That regression fix (#53580) was backported to 26.8 (#53594), but was never backported to 26.6.

Because #54268 includes both #53580 and the ID token fallback, backporting #54268 to 26.6 (or cherry-picking #53580) should restore the expected behavior for Entra ID where email_verified is omitted.

8000

@sschu
sschu commented Nov 12, 2026
Copy link
Copy Markdown
Contributor

@msdaly200 Thanks, sounds good!

Closes keycloak#54707

Signed-off-by: Marie Daly <marie.daly1@ibm.com>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 08:31
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 confirmation-flow reset clears edited-email provenance, allowing an attacker to auto-link a victim’s account without ownership confirmation after returning to profile review.

1 open issue
1 resolved since last review

Review effort: Balanced

Comment on lines +46 to +47
String emailChanged = context.getAuthenticationSession().getAuthNote(AbstractIdentityProvider.UPDATE_PROFILE_EMAIL_CHANGED);
boolean emailWasEdited = "true".equals(emailChanged);
@rmartinc rmartinc 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.

Thanks @msdaly200! Same changes than in branches!

@rmartinc
rmartinc merged commit affbfb9 into keycloak:main Nov 12, 2026
96 checks passed
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-97175] Unverified IdP email auto-linking enables account takeover

4 participants

0