Skip to content
Account takeover Write-up Beginner

JWT Algorithm Confusion → Admin Account Takeover

The server accepted JWTs with the 'none' algorithm and trusted the email claim inside them, so an authenticated low-privileged user could change their token to claim an administrator's email and be treated as that administrator.

mehrankiya272 Follow

Published on medium.com

Bug Bounty

Mehrankiya, on medium.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

The target was a web application the author had tested before: he had already reported a different vulnerability on the same application. This time the goal was a high-impact issue, and the entry point was the login page. After authentication the application issued a JWT (JSON Web Token) to manage the user session, and the token carried a field identifying the authenticated user, in this case an email value.

The report does not name the application, the program or the platform it was reported on. It describes the behaviour of the session mechanism and the result of tampering with it.

Setup

The only tool named in the report is Burp Suite, used to intercept the login request and to capture and replay the token. The precondition is an ordinary authenticated account: the author was logged in as a regular, low-privileged user. The attack also requires knowing the identifier (email address) of the account to be impersonated, in this case an administrator account. No versions, endpoints or parameter names are given in the report.

Finding it

While analysing the login request and its response, the author noticed that the session was carried in a JWT. He captured the token and examined its structure and how the server validated it. A JWT has three parts:

Header.Payload.Signature

A correctly implemented server validates both the signing algorithm and the signature. The author decided to test the classic algorithm confusion scenario together with the alg:none algorithm, that is, whether the server would accept a token that declares no signature algorithm at all.

Exploitation

Step 1: Change the header algorithm to none

The author modified the JWT header and set the algorithm to:

none

This tells a compliant verifier that the token is unsigned. A server that honours the header value instead of enforcing its own expected algorithm will skip signature verification entirely.

Step 2: Rewrite the identity in the payload

The payload contained a field used to identify the authenticated user, and its value was an email address. For testing, the author replaced his own email with the email address associated with an administrator account. The result was a forged token that claimed to represent the administrator, with no valid cryptographic signature.

Step 3: Replay the forged token

The author replaced his original token with the forged JWT and sent the request back to the server. The server accepted the modified token, and the application then identified the session as the Administrator user.

No raw request or response is reproduced in the report, so the exact header, payload and endpoint are not shown here.

From the original on medium.com

The image sits at the end of the write-up, after the conclusion that the server did not detect the modification.

Root cause

The root cause is improper JWT validation on the server side. The server trusted the algorithm named in the token header, including none, and accepted a token without requiring a valid signature. It also trusted user-controlled claims in the payload, so changing the email claim changed the identity the application acted on.

The author's summary of the rule that was broken:

The client should never be able to decide how the server validates its authentication token.

The signature and algorithm must be strictly validated server-side against an expected, trusted configuration. The report does not describe any other defence that was present or bypassed.

Impact

An authenticated low-privileged user could manipulate the JWT and impersonate an administrator without knowing the administrator's credentials. In the author's testing, the authenticated identity changed from a regular user to an Administrator.

The author is explicit about the limits: he did not obtain the administrator's original credentials or session, and he did not demonstrate access to every administrative function. He therefore rated the issue Medium (P2) based on the demonstrated impact.

Potential impact listed in the report:

  • Administrator identity impersonation
  • Unauthorized privilege escalation
  • Authentication bypass for the affected identity
  • Potential access to privileged functionality if authorization relies on the JWT identity

The condition for abuse is knowing the identifier or email of another account: anyone who knows it could potentially impersonate that user.

Fix

The report states what should be done rather than what was changed. The server must not blindly trust the algorithm specified in the JWT header, tokens using the none algorithm must not be accepted for authenticated sessions, and the signature and algorithm must be strictly validated server-side against an expected, trusted configuration.

Variants to test

  1. Algorithm confusion with asymmetric keys. If the application signs with RS256, try presenting an HS256 token signed with the public key as the HMAC secret. A positive result is the server accepting the token and honouring the claims.
  2. Case and whitespace variants of none. Try None, NONE and padded values in the alg field. A positive result is acceptance where the exact lowercase none was rejected.
  3. Claim tampering with a valid signature. Change the identity claim in a token you legitimately own and see whether the server rejects it. Acceptance indicates the claims are trusted without binding them to the signature.
  4. Other identity-bearing claims. If the payload carries a user id, username or role alongside the email, modify each in turn. A positive result is any change that alters the server-side identity or privileges.
  5. Signature stripping. Remove the third segment of the token entirely and send it. A positive result is the server treating the token as valid.
  6. Key and algorithm pinning checks. Present a token signed with a different key or algorithm than the one the server expects. A positive result is acceptance, showing the server is not pinning to its configured algorithm.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

What happened, in plain words

A security researcher was testing a website he had looked at before. On an earlier visit he had already found and reported one problem there, so he knew the site a little. This time he wanted to find something bigger: a flaw that would let an ordinary user do things only an administrator should be able to do.

He started at the login page, the screen where you type your email and password. He used a tool called Burp Suite, which sits between your browser and the website and lets you read and change every message that passes between them. While watching the login traffic, he noticed something: after you log in, the site hands your browser a small piece of text called a JWT to manage your session. short for JSON Web Token. Your browser sends that text back with every later request, and the server reads it to decide who you are.

That design is extremely common and not a problem by itself. The problem was how the server checked that token. A JWT is supposed to be signed, a bit like a wax seal on an envelope: if anyone opens the envelope and changes the letter inside, the seal no longer matches and the receiver should notice. This server accepted a token that declared it had no seal at all. The researcher changed the token's email claim to an administrator's address, set the algorithm to none, and sent it back. The server believed it. His ordinary account was suddenly treated as the administrator's account.

He rated the issue Medium (P2). He was careful to say what he had and had not proved: he did not get the administrator's password, he did not steal the administrator's real session, and he did not show that every administrative screen was reachable. What he did show was that he could make the application treat him as the administrator, which is serious on its own.

The pieces you need to know first

Before walking through the steps, here are the few ideas the whole story rests on. None of them requires any technical background.

A web application is a program that runs on a company's server and that you use through your browser. When you click a button, your browser sends a message to the server and the server sends one back. You never see the server itself, only these messages.

A request and a response. Every action in a browser is a request ("please show me my profile") followed by a response ("here it is"). Think of posting a letter and getting a reply. Burp Suite lets you open the letter, read it, rewrite it and post it again.

Authentication means proving who you are, usually with an email and a password. Authorisation means what you are allowed to do once you are known. A normal user and an administrator both authenticate, but they are authorised for different things.

A session is the server's memory of the fact that you logged in. Because the web was built to forget everything between requests, something has to remind the server who you are on each new request. That something is a token.

A token is a short string of text your browser stores and sends back with each request, like a cloakroom ticket. You hand in the ticket and get your coat; the attendant does not ask your name again. If someone can forge a ticket, they get a coat that is not theirs.

A JWT (JSON Web Token) is one particular kind of token. It has three parts separated by dots:

Header.Payload.Signature

  • The header is a small block of data that says, among other things, which signing method was used. That method is called the algorithm, and its short name is alg.
  • The payload is another small block of data holding facts about you, called claims. A claim might be your email, a user id or a role.
  • The signature is the seal. The server creates it with a secret key that only the server knows. Anyone can read the header and payload, because they are only encoded, not encrypted, but nobody without the key should be able to produce a valid signature for changed contents.

Algorithm confusion is the name of a family of attacks where the attacker abuses the fact that the token itself declares which algorithm was used. If the server simply believes that declaration instead of enforcing its own rule, the attacker can pick a weak or empty algorithm. The none algorithm is the extreme case: it literally means "no signature". A correct server should refuse such a token for a logged-in session.

Burp Suite is a program used by people who test websites. It places itself between the browser and the site so that every request can be paused, inspected and edited before it is sent on. The researcher used it to capture the login request and the token, and to replay a modified token.

Setting up

The report names only one tool, Burp Suite. The other precondition is simply an account on the site: the researcher was logged in as a normal, low-privileged user. To impersonate somebody, he also needed to know that person's identifier, which in this application was an email address. He used the email of an administrator account.

The report does not name the application, the company, the bug bounty programme or the platform it was reported through, and it gives no version numbers, no page addresses and no parameter names. What it describes is the behaviour of the login and session mechanism.

Finding it

  1. He opened the login page and logged in normally.
  2. With Burp Suite intercepting, he read the login request and its response.
  3. In the response he saw that the site was issuing a JWT to carry the session.
  4. He captured that token and looked at its structure and at how the server checked it.

A JWT has three parts:

Header.Payload.Signature

This line is not code to run; it is a way of writing the shape of a token. The three words stand for the three chunks of text, and the dots are the separators. When you see a real token it looks like a long string with two dots in it, and each chunk is a scrambled-looking block of letters and digits.

A well-built server checks two things: that the algorithm named in the header is one it expects, and that the signature is valid for the exact header and payload it received. The researcher decided to test the classic algorithm confusion scenario together with the none algorithm, which means asking a simple question: will this server accept a token that declares it has no signature at all?

Exploitation

Step 1: Change the header algorithm to none

He edited the header of the token and set the algorithm to:

none

In plain words: he told the server "this token is unsigned". A server that follows its own rule ignores that claim and still demands a valid signature. A server that instead obeys whatever the token says will skip the signature check entirely, because the token has told it there is nothing to check. That single word is the heart of the attack.

Step 2: Rewrite the identity in the payload

The payload contained a field that the application used to identify the logged-in user, and the value of that field was an email address. For testing, he replaced his own email with the email address of an administrator account.

Why this step matters: the payload is where the server reads who you are. If the server trusts the payload without tying it to a valid signature, then editing the payload is the same as editing your identity card. The result was a forged token that claimed to represent the administrator, with no valid cryptographic signature behind it.

Step 3: Replay the forged token

He replaced his original token with the forged one and sent the request back to the server. The server accepted it, and the application then treated his session as the Administrator user.

Why this is the decisive moment: everything before it was preparation. Sending the modified token is the actual test, because it is the server's answer that decides whether the flaw is real. The answer was yes. An authenticated low-privileged user could change the token and be treated as an administrator without knowing the administrator's password.

From the original on medium.com

The image appears at the very end of the write-up, after the author's conclusion that the server did not detect the modification.

No raw request or response is reproduced in the report, so the exact header, payload and page address are not shown here.

Root cause

The root cause is improper JWT validation on the server side. Two mistakes combine. First, the server trusted the algorithm named in the token header, including none, and accepted a token without requiring a valid signature. Second, it trusted the claims in the payload, so changing the email claim changed the identity the application acted on.

The author's one-line summary of the rule that was broken:

The client should never be able to decide how the server validates its authentication token.

The signature and the algorithm must be strictly checked on the server against an expected, trusted configuration. The report does not describe any other defence that was present or bypassed.

Impact

An authenticated low-privileged user could manipulate the JWT and impersonate an administrator without knowing the administrator's credentials. In the author's testing, the authenticated identity changed from a regular user to an Administrator.

The author is explicit about the limits. He did not obtain the administrator's original credentials or session, and he did not demonstrate access to every administrative function. He therefore rated the issue Medium (P2) based on the demonstrated impact.

Potential impact listed in the report:

  • Administrator identity impersonation
  • Unauthorized privilege escalation
  • Authentication bypass for the affected identity
  • Potential access to privileged functionality if authorization relies on the JWT identity

The condition for abuse is knowing the identifier or email of another account: anyone who knows it could potentially impersonate that user.

Fix

The report states what should be done rather than what was changed. The server must not blindly trust the algorithm specified in the JWT header, tokens using the none algorithm must not be accepted for authenticated sessions, and the signature and algorithm must be strictly validated server-side against an expected, trusted configuration.

Variants to test

These are further checks in the same family, useful if the first attempt had failed or if you are testing a similar site.

  1. Algorithm confusion with asymmetric keys. If the application signs with RS256, try presenting an HS256 token signed with the public key as the HMAC secret. A positive result is the server accepting the token and honouring the claims.
  2. Case and whitespace variants of none. Try None, NONE and padded values in the alg field. A positive result is acceptance where the exact lowercase none was rejected.
  3. Claim tampering with a valid signature. Change the identity claim in a token you legitimately own and see whether the server rejects it. Acceptance indicates the claims are trusted without binding them to the signature.
  4. Other identity-bearing claims. If the payload carries a user id, username or role alongside the email, modify each in turn. A positive result is any change that alters the server-side identity or privileges.
  5. Signature stripping. Remove the third segment of the token entirely and send it. A positive result is the server treating the token as valid.
  6. Key and algorithm pinning checks. Present a token signed with a different key or algorithm than the one the server expects. A positive result is acceptance, showing the server is not pinning to its configured algorithm.

Glossary

  • API: the set of messages a program accepts and answers, the way a restaurant menu lists what you can order.
  • Administrator: a user account with extra powers over a site, such as managing other users.
  • Algorithm (in a JWT): the method named in the token header that says how the signature was made, for example none or HS256.
  • Algorithm confusion: an attack that abuses a server trusting the algorithm named inside the token instead of enforcing its own.
  • Authentication: proving who you are, usually with an email and password.
  • Authorisation: what you are allowed to do once you are known.
  • Burp Suite: a tool that sits between browser and website so requests can be read, paused and edited.
  • Claim: a fact stored in a JWT payload, such as an email address or a role.
  • Credentials: the secret things you use to log in, such as a password.
  • Header (in a JWT): the first chunk of a token, holding metadata including the algorithm.
  • HMAC / HS256: a signing method that uses one shared secret key.
  • Impersonation: acting as another user, here by making the server believe you are them.
  • JWT (JSON Web Token): a three-part token, header, payload and signature, used to carry a session or identity.
  • Low-privileged user: an ordinary account without administrative powers.
  • none algorithm: a JWT setting meaning the token has no signature at all.
  • Payload (in a JWT): the middle chunk of a token, holding the claims about the user.
  • Privilege escalation: gaining powers you were not given, such as going from user to administrator.
  • Public key: the half of an asymmetric key pair that can be shared; the other half, the private key, stays secret.
  • Request / response: the message your browser sends and the message the server sends back.
  • RS256: a signing method that uses a private key to sign and a public key to verify.
  • Session: the server's memory that you are logged in, usually carried by a token.
  • Signature: the seal on a token, made with a secret key so changes can be detected.
  • Token: a short string your browser stores and sends back to prove who you are.
  • Validation: checking that something is genuine and allowed, here that a token's algorithm and signature are correct.
  • Vulnerability: a weakness in a program that someone can abuse to do something unintended.

More by mehrankiya272

View all

1 more disclosed report, best first.

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.