User impersonation via stolen UUID code in KeyCloak (CVE-2023-0264)
The token endpoint accepted a login code whose session identifier was not bound to the user who started the login, so an attacker with any valid account could swap in a victim's session identifier and receive that victim's tokens. This allowed impersonation and full account takeover of the victim.
Published on offensity.com
During a Web Security Assessment for one of our clients, we identified some abnormal behavior on the Single-Sign-On solution they were using: Red Hat’s Keycloak. After further investigation, we found a vulnerability that gave us the ability to impersonate other users.
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 authorisation code was not bound to the user or session that initiated the login, so the server trusted a client-supplied session identifier when issuing tokens.
Impact
An attacker could impersonate another user and take over their account, provided they hold a valid account in the same realm and can obtain the victim's session identifier, which may leak through the URL, browser history, referrer headers, analytics or cookies.
What the attacker needed
A valid account in the victim's realm; knowledge of the victim's session UUID
The fix
The vulnerability was fixed in Keycloak version 21.0.1.
How it was found
- Log in normally with a valid account and intercept the token request.
- Replace the second identifier in the code parameter with the victim's session identifier.
- Receive access, refresh and id tokens belonging to the impersonated user.
- Use those tokens to access the victim's account.
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.
When you log in to a website that uses a central login service, the service hands your browser a short code that it later swaps for tokens proving who you are. Here that code contained a session identifier that was not tied to the person logging in, so anyone who learned a victim's identifier could use their own login to collect the victim's tokens. Tokens are the digital keys to an account, so this meant taking over someone else's account.
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.