Skip to content
Account takeover Write-up Intermediate

Vulnerability Spotlight: CVE-2023-0264

A validation error in Keycloak's login flow allows any existing user to impersonate another existing user within the same realm by replacing the middle part of an OAuth code with the victim's session ID. An attacker with a valid account and knowledge of the victim's client session ID could escalate privileges, potentially to an administrative account.

Timo Müller Follow

Published on mogwailabs.de

1

Timo Müller, on mogwailabs.de

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the OAuth code's user session ID was not validated against the session that generated the code, allowing an attacker to substitute a victim's session ID.

Impact

An attacker with a valid account and the victim's session ID could impersonate the victim, potentially gaining administrative access to the Keycloak instance.

What the attacker needed

A valid user account; knowledge of victim's session ID; victim's session ID must be leaked

The fix

The vulnerability was fixed in Keycloak version 21.0.1 by adding validation of the user session ID in the OAuth code.

How it was found

  1. Register two accounts (attacker and victim).
  2. Log in with the victim account and obtain an access token.
  3. Extract the session_state claim from the victim's token.
  4. Log in with the attacker account to obtain a valid OAuth code.
  5. Replace the middle part of the attacker's code with the victim's session_state.
  6. Send the modified code to Keycloak to obtain an access token for the victim.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Keycloak is a system that handles logins for other applications. When you log in, it gives you a temporary code that proves who you are. This bug meant that if an attacker could find out a secret identifier for another user's session, they could swap part of their own code with that identifier and trick Keycloak into thinking they were that other user. This could let them access the other person's account, even an administrator's.

What is Account takeover?

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.

More by Timo Müller

View all

1 more disclosed report, best first.

More from Keycloak

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.