IDOR in JWT and the shortest token you will ever see {}.{“uid”: “1234567890”}
The API accepted a JWT with an empty header and only a user ID in the payload, without validating the signature or session ID. An attacker could query order statuses for other users by supplying arbitrary user and order IDs, exposing personal and payment information.
API
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.
Context
The target was a bug bounty program on HackerOne, run by a company whose application let customers order products. The researcher refers to the main site as http://example.com and to a separate API host as customer-order-status.example.net. The application lets customers look up the status of their order through an API endpoint.
The API authenticates callers with a JSON Web Token (JWT) sent in the Authorization header as a bearer token. The token carries a session id and a user id and is signed with HS256.
Setup
The researcher worked from a fresh Burp Suite project after abandoning an earlier line of investigation. He logged in to the application using his girlfriend's account, explicitly because he did not want to order anything himself. Later, while using the app, his girlfriend ordered a product and could then check its status. No specific tool versions are given in the report.
Finding it
On login, the researcher noticed a cross-origin pre-flight request to an API endpoint. It looked roughly like this:
OPTIONS / HTTP/1.1
Host: customer-order-status.example.net
Content-Type: application/json
Connection: close
Later, after the girlfriend ordered a product, she could check the status of her order. The check order request looked roughly like this:
GET /api/v1/order_statuses/{order_id} HTTP/1.1
Host: customer-order-status.example.net
Authorization: Bearer JWT TOKEN
Content-Type: application/json
Connection: close
The JSON response contained personal account information including delivery address, order details, payment method and payment amount. That is the data the endpoint returned in the response.
The JWT itself had the session id and user id and was signed with HS256. The decoded structure was:
{"alg": "HS256","typ": "JWT"}.{"uid": "1234567890","sessionid": "ALPHANUMERIC ID"}.SIGNATURE
On paper that is a reasonable design: a signed token binding a user id and a session id. The problem was that the API did not validate any of it.
Exploitation
Step 1: Reduce the token to the minimum that still works
The researcher ended up using a much shorter version of the authorization token:
{}.{"uid": "1234567890"}
This is a JWT-shaped string with an empty JSON object as the header, a payload containing only the uid claim, and no signature at all. The report shows it without a trailing signature segment. The API accepted it: querying the endpoint with this token returned a valid response. The same worked when using past order ids.
Step 2: Query other users' orders
Because the token's uid is attacker-controlled and the order_id sits in the URL path, an attacker can substitute both values to reach another customer's order status. The report does not show a specific request against another user's data, but the mechanism is the same request as above with a different uid in the token and a different {order_id} in the path.
Step 3: Brute-force the two variables
The researcher is explicit about the practical limit: effective exploitation required some level of brute-forcing to query random users' information, because there are two variables, the user id and the order id. That made it harder to exploit. What made it dangerous, in his words, is that the server did not implement request limits, so the brute-force attack could potentially be made feasible.
Root cause
The API did not validate the JWT. The API did not validate the token at all: an unsigned token with only a uid was accepted. The uid in the token and the order_id in the path are both chosen by the caller.: the object reference in the path is trusted on its own, with the token acting only as a claim the caller writes for themselves.
The HS256 signing was therefore decorative. A correctly signed token offers nothing if the verifier never verifies it, and the report's phrasing is that the API "did not validate any of that".
Impact
An attacker who can reach the endpoint can read other customers' order status data: delivery address, order details, payment method and payment amount. The condition is that the attacker can guess or enumerate a valid pair of user id and order id. The absence of request limits makes that enumeration potentially feasible, though the report hedges this: it "could potentially" make the brute-force attack feasible. The researcher was paid 1,500 USD for the report.
Fix
The report does not describe what the program changed. Rate limiting on the endpoint would also reduce the feasibility of enumeration, but it is a mitigation, not the fix.
Variants to test
- Unsigned or stripped-signature JWTs. Send a token with
algset tonone, or with the signature segment removed entirely, and see whether the API still returns data. A positive result is a normal 200 response with the protected object. - Empty or minimal headers and payloads. Try
{}.{"uid": "..."}and similar reductions. A positive result is the API accepting a token that no legitimate client would ever send. - Claim substitution. Keep a valid signature but change
uidto another user's id. A positive result is data belonging to the other user. - Missing session binding. Drop the
sessionidclaim while keeping a valid signature. A positive result is the request succeeding, which shows the session is not actually checked. - Object reference swapping. With a valid token for your own account, change the
order_idin the path to another value. A positive result is another customer's order details. - Enumeration without limits. Send a burst of requests across a range of ids and watch for rate limiting. A positive result is a long run of responses with no throttling, which makes the two-variable brute-force practical.
What happened, in plain words
A security researcher was taking part in a bug bounty programme on HackerOne. A bug bounty programme is a deal offered by a company: if you find a security problem in our systems and report it responsibly, we pay you a reward (the bounty). The company in this story runs a shopping application where customers can order products.
The researcher found that the part of the application that lets you check the status of your order was trusting whatever the visitor told it about who they were. He could hand it a tiny, unsigned piece of text claiming to be a particular user, and the server would happily return that user's order details: delivery address, what was ordered, how it was paid for and how much. The report earned him 1,500 USD.
This article walks through the same story from the beginning, explaining every technical idea as it appears, so you can follow it with nothing more than a browser and a computer.
The pieces you need to know first
Before the story makes sense, here are a few everyday ideas.
An API is a way for one piece of software to talk to another. Think of a restaurant: the dining room (the website you see in your browser) does not cook; it passes your order through a hatch to the kitchen (the API), and the kitchen sends back the food (the data). When you click "check my order status" on a website, your browser usually sends a request to an API behind the scenes, and the API answers with the information.
A request is simply a message your browser sends to a server, asking for something. It has a method (a verb such as GET, meaning "give me this", or OPTIONS, meaning "tell me what is allowed here"), a path (which thing you want), a host (which server), and often extra lines called headers that carry context.
A header is a labelled line inside a request or response. For example, Host: says which server the request is for, and Authorization: carries proof of who you are.
A token is a small piece of text that acts as proof of identity, a bit like a cloakroom ticket: you hand in your coat, you get a ticket, and later the ticket gets your coat back. You do not need to prove who you are again; possession of the ticket is enough. On websites, a token is often stored in your browser and sent with every request so the server knows it is still you.
A JWT (JSON Web Token) is a particular format for such a token. It is three chunks of text joined by dots: a header, a payload, and a signature. The header says which signing method was used. The payload carries claims, which are just named values such as a user id. The signature is a cryptographic stamp that lets the server check the token was issued by it and not tampered with. Think of a wax seal on an envelope: the contents are readable by anyone, but the seal proves the letter came from the right sender and was not altered.
HS256 is one of the methods used to produce that seal. It uses a secret key that only the server knows, so in theory nobody else can produce a valid seal.
IDOR (Insecure Direct Object Reference) is the vulnerability class in this report. It means the application lets you refer to something by a simple identifier (an order number, a user number, a file name) and does not check that the thing belongs to you. Imagine a hotel where every room key is just the room number written on a card: if you can write any number on the card, you can open any room. The fix is for the hotel to check the card against its own records, not to trust what is written on it.
Brute-forcing means trying many possibilities in a row until one works, like spinning the dials on a combination lock through every combination. It only works if the number of possibilities is small enough and if nothing stops you from trying quickly.
Rate limiting is the defence against that: the server refuses to answer if you send too many requests in a short time, the way a website locks your account after several wrong passwords.
The target and the feature
The target was a bug bounty programme on HackerOne, run by a company whose application let customers order products. In the report the main site is called http://example.com and a separate API server is called customer-order-status.example.net. The feature is order status checking: after a customer places an order, the application lets them look up the status of that order through an API endpoint.
An endpoint is one specific address on a server that does one specific job, like one counter in a large office. The endpoint here is the one that answers "what is the status of order X?".
The API authenticates callers with a JWT sent in the Authorization header as a bearer token. "Bearer" means exactly what it sounds like: whoever bears (carries) the token is treated as the person it names. The token carries a session id and a user id and is signed with HS256.
A session id is a label for one logged-in visit. When you log in, the server starts a session and gives your browser an id for it, so it can tell your visit apart from everyone else's.
Setting up
The researcher started from a fresh Burp Suite project. Burp Suite is a tool that sits between your browser and the internet and lets you read and edit every request and response, like a postal worker who can open, read and rewrite letters in transit. He had abandoned an earlier line of investigation and decided to start over from the beginning.
He logged in to the application using his girlfriend's account, explicitly because he did not want to order anything himself. Later, while using the app, his girlfriend ordered a product and could then check its status.
Finding it
On login, the researcher noticed a cross-origin pre-flight request to an API endpoint. Two ideas there:
- Cross-origin means the request goes from one website's address to a different address. Browsers are cautious about this, because a page on one site should not silently read data from another.
- A pre-flight request is the browser asking permission before sending the real request. It uses the
OPTIONSmethod, which means "tell me what is allowed here", and the server replies with what the browser is permitted to do.
The pre-flight request looked roughly like this:
OPTIONS / HTTP/1.1
Host: customer-order-status.example.net
Content-Type: application/json
Connection: close
Line by line:
OPTIONS / HTTP/1.1is the request line.OPTIONSis the method, the question "what is allowed?"./is the path being asked about, here the root of the API server.HTTP/1.1is the version of the web protocol being spoken.Host: customer-order-status.example.netnames the server the request is addressed to. One physical server can host many sites, so the host name tells it which one is meant.Content-Type: application/jsonsays the body of the message is in JSON, a common text format for structured data (curly brackets, names and values).Connection: closeasks that the network connection be closed after this exchange rather than kept open for more.
Seeing this told the researcher that the browser was talking to a separate API server, which is where interesting data usually lives.
Later, after the girlfriend ordered a product, she could check the status of her order. The check order request looked roughly like this:
GET /api/v1/order_statuses/{order_id} HTTP/1.1
Host: customer-order-status.example.net
Authorization: Bearer JWT TOKEN
Content-Type: application/json
Connection: close
Line by line:
GET /api/v1/order_statuses/{order_id} HTTP/1.1is the request line.GETmeans "give me this data". The path/api/v1/order_statuses/{order_id}points at the order status endpoint;{order_id}is a placeholder for the actual order number, the way a form letter has a blank for your name.v1is just a version label in the address.Host: customer-order-status.example.netnames the API server.Authorization: Bearer JWT TOKENis the proof of identity. The wordBearersays the token that follows should be accepted from whoever presents it, andJWT TOKENstands for the actual token text.Content-Type: application/jsonsays the message body is JSON.Connection: closeasks to close the connection afterwards.
The JSON response contained personal account information including delivery address, order details, payment method and payment amount. That is the data the endpoint returned in the response.
The JWT itself had the session id and user id and was signed with HS256. The decoded structure was:
{"alg": "HS256","typ": "JWT"}.{"uid": "1234567890","sessionid": "ALPHANUMERIC ID"}.SIGNATURE
Line by line, the three dot-separated parts:
{"alg": "HS256","typ": "JWT"}is the header.algnames the signing method, HS256, andtypsays the token type is JWT.{"uid": "1234567890","sessionid": "ALPHANUMERIC ID"}is the payload.uidis the user id, the number that identifies the account.sessionidis the label for the logged-in session.ALPHANUMERIC IDis a placeholder for a string of letters and digits.SIGNATUREis the seal computed with the server's secret key.
On paper that is a reasonable design: a signed token binding a user id and a session id. The problem was that the API did not validate any of it. Validating means actually checking: recomputing the seal and comparing, confirming the session id is real, and confirming the user id matches the order being asked about. The API did not validate any of it, so the seal was decoration.
Exploitation
Step 1: Reduce the token to the minimum that still works
The researcher ended up using a much shorter version of the authorization token:
{}.{"uid": "1234567890"}
Line by line:
{}is an empty JSON object in place of the header. It declares nothing at all, not even a signing method.{"uid": "1234567890"}is a payload containing only the user id, with no session id.- There is no third part: no signature, no seal.
This is a JWT-shaped string with an empty header, a payload containing only the uid claim, and no signature at all. The report shows it without a trailing signature segment. The API accepted it: querying the endpoint with this token returned a valid response. The same worked when using past order ids.
Why does that matter? Because the token is now something the visitor writes entirely by themselves. There is no secret involved, no seal to forge. The server reads the uid and believes it. It is like a nightclub where the bouncer accepts a name written on a napkin as proof of age.
Step 2: Query other users' orders
Because the token's uid is attacker-controlled and the order_id sits in the URL path, an attacker can substitute both values to reach another customer's order status. The report does not show a specific request against another user's data, but the mechanism is the same request as above with a different uid in the token and a different {order_id} in the path.
In other words, the two things that decide whose data you get, the user id inside the token and the order number in the address, are both chosen by the person making the request. Nothing on the server cross-checks them against each other or against a real login.
Step 3: Brute-force the two variables
The researcher is explicit about the practical limit: effective exploitation required some level of brute-forcing to query random users' information, because there are two variables, the user id and the order id. That made it harder to exploit. What made it dangerous, in his words, is that the server did not implement request limits, so the brute-force attack could potentially be made feasible.
Think of a safe with two dials. Guessing one dial is easy; guessing both at once multiplies the possibilities enormously. That is why the two variables made the attack harder. But if the safe lets you try a million combinations a minute without ever locking, the difficulty drops sharply. That is what the missing request limits did.
Root cause
The API did not validate the JWT. It did not check the signature, so an unsigned token was accepted. It did not check that the sessionid claim was present or valid, so a token with only a uid was accepted. The uid in the token and the order_id in the path are both chosen by the caller.: the object reference in the path is trusted on its own, with the token acting only as a claim the caller writes for themselves.
The HS256 signing was therefore decorative. A correctly signed token offers nothing if the verifier never verifies it, and the report's phrasing is that the API "did not validate any of that".
Impact
An attacker who can reach the endpoint can read other customers' order status data: delivery address, order details, payment method and payment amount. The condition is that the attacker can guess or enumerate a valid pair of user id and order id. The absence of request limits makes that enumeration potentially feasible, though the report hedges this: it "could potentially" make the brute-force attack feasible. The researcher was paid 1,500 USD for the report.
Fix
The report does not describe what the programme changed. Rate limiting on the endpoint would also reduce the feasibility of enumeration, but it is a mitigation, not the fix.
In everyday terms: check the wax seal, insist the cloakroom ticket is a real one, and check that the coat you are handing back belongs to the person holding the ticket. Limiting how fast people can ask is a useful extra lock on the door, but it does not replace checking the ticket.
Variants to test
If you ever test a similar feature, these are the variations worth trying. Each one is a small change to the request above, and each has a clear sign of success.
- Unsigned or stripped-signature JWTs. Send a token with
algset tonone, or with the signature segment removed entirely, and see whether the API still returns data. A positive result is a normal 200 response with the protected object. A 200 is the standard "here is your data" answer from a web server. - Empty or minimal headers and payloads. Try
{}.{"uid": "..."}and similar reductions. A positive result is the API accepting a token that no legitimate client would ever send. - Claim substitution. Keep a valid signature but change
uidto another user's id. A positive result is data belonging to the other user. - Missing session binding. Drop the
sessionidclaim while keeping a valid signature. A positive result is the request succeeding, which shows the session is not actually checked. - Object reference swapping. With a valid token for your own account, change the
order_idin the path to another value. A positive result is another customer's order details. - Enumeration without limits. Send a burst of requests across a range of ids and watch for rate limiting. A positive result is a long run of responses with no throttling, which makes the two-variable brute-force practical.
Glossary
- API: a defined way for one piece of software to ask another for data or actions, like a service hatch between a dining room and a kitchen.
- Authentication: proving who you are to a system, for example by logging in.
- Authorization header: the line in a request that carries proof of identity, here a token.
- Bearer token: a token accepted from whoever presents it, with no further proof required.
- Brute-forcing: trying many possible values in sequence until one works.
- Bug bounty programme: a scheme where a company pays researchers who report security problems responsibly.
- Burp Suite: a tool that sits between browser and server and lets you read and edit requests and responses.
- Claim: a named value inside a token, such as a user id.
- Cross-origin request: a request from one website's address to a different address, which browsers treat with caution.
- Endpoint: one specific address on a server that performs one specific job.
- Enumeration: systematically walking through possible identifiers (numbers, names) to find valid ones.
- GET: the request method meaning "give me this data".
- Header: a labelled line in a request or response carrying context, such as the host or the content type.
- HS256: a signing method that uses a secret key only the server knows.
- HTTP: the protocol browsers and servers use to exchange requests and responses.
- IDOR (Insecure Direct Object Reference): a flaw where an application lets you name an object by a simple identifier and does not check it belongs to you.
- JSON: a text format for structured data using curly brackets, names and values.
- JWT (JSON Web Token): a token format made of a header, a payload and a signature, joined by dots.
- Mitigation: a measure that reduces the risk or difficulty of an attack without removing the underlying flaw.
- OPTIONS: the request method meaning "tell me what is allowed here", used in pre-flight requests.
- Payload: the middle part of a JWT, carrying the claims.
- Pre-flight request: a permission question a browser sends before a cross-origin request.
- Rate limiting: refusing to answer when too many requests arrive in a short time.
- Request: a message from a browser or client to a server asking for something.
- Response: the server's answer to a request.
- Session id: a label identifying one logged-in visit.
- Signature: a cryptographic stamp proving a token was issued by the server and not altered.
- Token: a piece of text used as proof of identity, like a cloakroom ticket.
- User id (uid): the number or string identifying one account.
- Validation: actually checking something, such as recomputing a signature or confirming a session id is real.
- Vulnerability class: a family of related security flaws, such as IDOR.