Skip to content
IDOR Write-up Beginner

Testing Cookies worth $500

A cookie token contained a sequential numeric identifier that determined which user was logged in. By changing that number, an attacker could log in as other users, including one from another country.

Sankalpa Acharya Follow

Published on sankalpa02.medium.com

Bounty$500 View original

Hey everyone, I’m Sankalpa Acharya from Nepal. A few weeks ago, I discovered an IDOR vulnerability that was worth $500 to me.

Sankalpa Acharya, on sankalpa02.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. 5 min read.

Context

This is a write-up of an IDOR that led to account takeover, found on a single sign-on (SSO) login flow and paid a $500 bounty. The researcher is Sankalpa Acharya from Nepal, and this was his first bounty. The target is referred to only as sso.example.io; the real website name is not disclosed.

The feature involved is the login flow itself. After a user submits an ID and password, the application identifies them on subsequent requests through a cookie rather than through a JWT or any other token in the response body. The report's stated impact is account takeover.

;)
;) From the original on sankalpa02.medium.com

Setup

  1. Two accounts were created on the target.
  2. The login flow was observed with an intercepting proxy, inspecting both the login request and its response.
  3. Cookies were compared between the two accounts.

No tool versions are given. The precondition for the attack is simply that the attacker holds one valid account on the same application, because the cookie format has to be seen for a legitimate session before it can be manipulated.

Before the technical work, the report offers a tip for people chasing a first bounty: if you are finding bugs on targets listed on HackerOne and Bugcrowd, consider switching target. Use Google dorks to discover other bug bounty programmes, because there is less competition:

Text
inurl: /responsible-disclosure/ bounty

Finding it

The researcher arrived at the target while searching for material about SSO login vulnerabilities, and picked sso.example.io from the search results.

New beginning, New Target with some positive energy From the original on sankalpa02.medium.com

New beginning, New Target with some positive energy

With two accounts in hand, the first attempts were on other features. CSRF was tested with no result.

Next, the password reset functionality was tested in the hope that an OTP code or token would leak in the Referer header or in the response. Again there was no result.

Attention then moved to the login flow, initially hoping for a JWT misconfiguration if the site used JWT tokens to identify users. The request was intercepted after entering the ID and password and clicking Login, but there was not much in the request. The response was intercepted too, and there was no JWT token or any other code in the response body.

Wait a Minute From the original on sankalpa02.medium.com

Wait a Minute

The reasoning that followed is the pivot of the whole report: what identifies the user to the browser? Cookies. So cookie testing began.

Response From Server From the original on sankalpa02.medium.com

Response From Server

Exploitation

Step 1: Swap cookies between accounts

Every cookie header was replaced, one by one, with the corresponding value from the second account. One Set-Cookie header stood out:

This was the cookie identifying the user.

Step 2: Read the token structure

Looking deeper into that header, the value was made of several parts separated by pipes, in this shape:

Text
1|random_string_and_integer|4-digit code|4-digit code|random_string_and_integer|

What caught the researcher's eye was the numeric code, because it was repeated in the header and, comparing the two accounts, only one character differed between them.

Cookies From the original on sankalpa02.medium.com

Cookies

Step 3: Change the code to the second account's value

In the token shown in the report, a 5-digit code, 47402, was being repeated, and the second account had the code 47403. Replacing the code with the second account's value logged the researcher into that second account.

Step 4: Change the code to a neighbouring value

To be doubly sure, the code 47402 was replaced with 47401. The result was a session in another user's account, located in China.

From the original on sankalpa02.medium.com

The vulnerability was then reported.

From the original on sankalpa02.medium.com

A few days later a response to the report arrived.

Root cause

The cookie that identifies the user carries a numeric code that appears to be used directly to decide which account the session belongs to. Because the code is predictable (the two owned accounts differed by one character, and the next value down belonged to a different, unrelated user), changing it in the cookie is enough to be treated as that user. The application appears to trust the cookie's contents as the identity, since editing the code was enough to be treated as another user. The report does not describe the server-side implementation, so this last point is likely rather than confirmed.

Impact

An attacker with a valid account on the application could reach another user's account by editing the numeric code in the identifying cookie. The report demonstrates this against a user in China, and the stated impact is account takeover. The report shows the attack starting from a legitimate session of the researcher's own, used to learn the cookie format.

Fix

The report does not say what was changed after disclosure. What the finding calls for is a session identifier that cannot be guessed or edited into another user's session: an opaque, high-entropy value mapped server-side to the authenticated user, or a signed token whose integrity is verified on every request, rather than a sequential numeric code embedded in the cookie.

Variants to test

  1. Compare the identifying cookie across two accounts you own and look for any component that changes by a small amount. A positive result is a component that differs by one, or that maps directly to a user or account number.
  2. Change that component to a neighbouring value and reload an authenticated page. A positive result is being served another account's data or session.
  3. Walk the value in one direction (for example one lower) to see whether neighbouring values belong to other accounts. A positive result is a different, unrelated account.
  4. Look for the same numeric component repeated elsewhere in the cookie or in other headers, as it was here. A positive result is the same value appearing in more than one place, which suggests it is the identity field.
  5. Apply the same comparison to other tokens issued by the application, such as password reset tokens or OTPs, since the report's earlier tests targeted exactly those places. A positive result is a token whose structure reveals a predictable or sequential part.

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 from Nepal, Sankalpa Acharya, found a way to log into other people's accounts on a website. He did not need their password. He only needed an account of his own, and a browser tool that lets you look at and change the messages your computer sends to a website. The website paid him $500 for telling them about it. It was his first paid bug.

The trick was in a cookie. A cookie is a small piece of text that a website asks your browser to store and to send back on every later visit. It works like the wristband you get at a festival: the staff do not check your ID at every door, they just look at the wristband. On this website, the wristband contained a number. Change the number, and the website thought you were somebody else.

The number was easy to guess: his two test accounts had codes that differed by one character, and the next number down belonged to a real person in China. That kind of flaw, where a program lets you reach another user's data by changing an identifier, is called IDOR (Insecure Direct Object Reference). Because the result was full access to another person's account, the impact is called account takeover.

;)
;) From the original on sankalpa02.medium.com

Before we start: the words you need

A few everyday ideas will make the rest of this easy to follow.

  • A website is a program running on a computer somewhere else (the server). Your browser asks it for pages, and it sends them back.
  • A request is the message your browser sends: "give me this page", or "here is my username and password, log me in". A response is the message the server sends back.
  • An API is the part of a website that answers requests with raw data rather than pretty pages. Think of the difference between asking a waiter for a dish (the page) and asking the kitchen directly for the list of ingredients (the API).
  • A cookie is a small label the server sticks on your browser. Your browser shows it back on every request, so the server can recognise you without asking for your password each time. The server hands it over with a Set-Cookie header, which is just a line in the response saying "store this".
  • A header is a labelled line in a request or response, like the address block on an envelope. Headers carry things such as the cookie, the browser type, or where you came from.
  • A token is a value that stands in for something else, usually your identity. A cookie often contains a token.
  • JWT (JSON Web Token) is one popular kind of token: a bundle of information that the server can check has not been altered, a bit like a sealed envelope with your name inside.
  • SSO (single sign-on) is a login system where one account lets you into several websites, the way one key card opens the office, the car park and the gym.
  • CSRF (Cross-Site Request Forgery) is an attack where a malicious page makes your browser send a request to another site while you are logged in there. The defence is usually a secret value that only the real site knows.
  • OTP (one-time password) is the short code sent by text or email to prove it is really you.
  • Referer is a header that tells the server which page you came from, like a "referred by" note.
  • An intercepting proxy is a tool that sits between your browser and the website and lets you pause, read and edit every message in both directions. It is the security researcher's equivalent of opening the envelope, reading the letter, and putting it back with a change.
  • Recon (reconnaissance) means looking around a target before attacking it: finding its pages, its features and its technologies.
  • A Google dork is a search query built with special operators that finds very specific pages, for example pages that mention a bug bounty programme.
  • HackerOne and Bugcrowd are platforms where companies list bug bounty programmes and researchers submit findings.
  • A bug bounty programme is a company's offer to pay people who report security problems in its products.
  • Entropy, in this context, means randomness. A high-entropy value is one that is very hard to guess.
  • Opaque means you cannot read anything useful out of it: it is just a random string that only the server can interpret.

The setup

  1. He created two accounts on the target website. Two accounts are essential: you need a second, legitimate session to compare against the first, so you can see which parts of the cookie change from user to user.
  2. He watched the login flow with an intercepting proxy, looking at both the request (what the browser sent when he clicked Login) and the response (what the server sent back).
  3. He compared the cookies of the two accounts.

The report does not name the tool or its version. The only precondition for the attack is that the attacker can register a normal account on the same website, because you have to see a real cookie before you can start editing it.

Before the technical part, the report gives a tip for people still looking for their first bounty. If you are hunting on targets listed on HackerOne and Bugcrowd, consider switching target: those platforms are crowded. Use Google dorks to find other bug bounty programmes, because there is less competition, and as a beginner that is what you want. The dork he gives is:

Text
inurl: /responsible-disclosure/ bounty

Line by line: inurl: tells Google to return only pages whose web address contains the text that follows. /responsible-disclosure/ is the path many companies use for the page that explains how to report a security problem. bounty is an ordinary search word, so Google also requires the page to mention a bounty. The result is a list of pages that look like bug bounty or vulnerability disclosure pages, which is a good starting point for finding programmes that are not on the big platforms.

Finding it

He arrived at the target while searching for material about SSO login vulnerabilities, and picked sso.example.io from the search results. The real name of the website is not disclosed, so sso.example.io is a stand-in.

New beginning, New Target with some positive energy From the original on sankalpa02.medium.com

New beginning, New Target with some positive energy

With two accounts ready, he first tried other features. He tested for CSRF and found nothing.

Next he tested the password reset feature, hoping that an OTP code or a token would leak into the Referer header or into the response. The idea is that if a secret appears somewhere it should not, an attacker can read it. Again, nothing.

He then turned to the login flow itself. His first hope was a JWT misconfiguration: if the site used JWT tokens to recognise users, a badly configured JWT might be forgeable. He intercepted the request after typing his ID and password and clicking Login, but there was not much in the request. He intercepted the response too, and there was no JWT token or any other code in the response body.

Wait a Minute From the original on sankalpa02.medium.com

Wait a Minute

Then came the thought that unlocked the whole report: what actually tells the browser's owner apart from other users? Cookies. So he started testing the cookies.

Response From Server From the original on sankalpa02.medium.com

Response From Server

Exploitation

Step 1: Swap cookies between accounts

He replaced every cookie header, one at a time, with the matching value from his second account. One Set-Cookie header stood out:

Line by line: Set-Cookie is the header name the server uses to give the browser a cookie to store. example_token is the cookie's name, the label on the wristband. token is the value, the actual content. This was the cookie that identified the user: when he swapped it, the website treated him as the other account.

Step 2: Read the token structure

Looking more closely at that header, the value was made of several parts separated by pipe characters (|), in this shape:

Text
1|random_string_and_integer|4-digit code|4-digit code|random_string_and_integer|

Line by line: the value is a list of fields glued together with | as the separator. The first field is the number 1. The second is a mix of random letters and digits. The third and fourth are short numeric codes. The fifth is another mix of random letters and digits, and the value ends with a trailing separator. What caught his eye was the numeric code, because it appeared twice in the same value, and when he compared his two accounts only one character differed between them.

Cookies From the original on sankalpa02.medium.com

Cookies

Step 3: Change the code to the second account's value

In the token shown in the report, a 5-digit code, 47402, was repeated, and his second account had the code 47403. He replaced the code with the second account's value, and he was logged into that second account. That proved the code was the identity field: the website was reading it to decide who he was.

Step 4: Change the code to a neighbouring value

To be doubly sure, he replaced 47402 with 47401. This time he landed in the account of a different user, located in China. That is the moment the flaw became serious: the next value down belonged to a stranger, so neighbouring values appear to map to other accounts.

From the original on sankalpa02.medium.com

He then reported the vulnerability.

From the original on sankalpa02.medium.com

A few days later a response to his report arrived.

Why it worked

The cookie that identifies the user carries a numeric code, and the application appears to use that code to decide which account the session belongs to. Because the code is predictable (his two accounts differed by one character, and the next value down belonged to an unrelated user), editing it in the cookie is enough to be treated as that user. The application appears to trust what the cookie says, since editing the code was enough to be treated as another user. The report does not describe the server-side code, so that last point is likely rather than confirmed.

A useful comparison: a good session cookie is like a cloakroom ticket. The ticket is a random number, and only the cloakroom's own list says which coat belongs to it. You cannot guess another ticket, and writing a different number on your ticket gets you nothing, because the attendant checks the list. Here, the ticket itself said "coat number 47402", so anyone could write a different number and collect a different coat.

Impact

An attacker with a valid account on the application could reach another user's account by editing the numeric code in the identifying cookie. The report demonstrates this against a user in China, and the stated impact is account takeover. The report shows the attack starting from a legitimate session of the researcher's own, used to learn the cookie format.

Fix

What the finding calls for is a session identifier that cannot be guessed or edited into another user's session: an opaque, high-entropy value that the server maps to the logged-in user, or a signed token whose integrity is checked on every request, rather than a sequential numeric code embedded in the cookie.

Variants to test

If you want to look for the same kind of bug, here is the routine, in the order the report followed it.

  1. Compare the identifying cookie across two accounts you own and look for any component that changes by a small amount. A positive result is a component that differs by one, or that maps directly to a user or account number.
  2. Change that component to a neighbouring value and reload a page that requires you to be logged in. A positive result is being served another account's data or session.
  3. Walk the value in one direction, for example one lower, to see whether neighbouring values belong to other accounts. A positive result is a different, unrelated account.
  4. Look for the same numeric component repeated elsewhere in the cookie or in other headers, as it was here. A positive result is the same value appearing in more than one place, which suggests it is the identity field.
  5. Apply the same comparison to other tokens the application issues, such as password reset tokens or OTPs, since the report's earlier tests targeted exactly those places. A positive result is a token whose structure reveals a predictable or sequential part.

Glossary

  • Account takeover: a security failure where an attacker gains full control of another person's account, usually without knowing their password.
  • API: the part of a website that answers requests with raw data rather than finished pages.
  • Bug bounty programme: a company's offer to pay people who report security problems in its products.
  • Bugcrowd: a platform where companies list bug bounty programmes and researchers submit findings.
  • Cookie: a small piece of text a website asks your browser to store and send back on later requests, used to recognise you.
  • CSRF (Cross-Site Request Forgery): an attack where a malicious page makes your browser send a request to another site while you are logged in there.
  • Entropy: the amount of randomness in a value; high entropy means hard to guess.
  • Google dork: a search query built with special operators that finds very specific pages.
  • HackerOne: a platform where companies list bug bounty programmes and researchers submit findings.
  • Header: a labelled line in a request or response carrying information such as the cookie or the browser type.
  • IDOR (Insecure Direct Object Reference): a flaw where a program lets you reach another user's data by changing an identifier such as a number in a request.
  • Intercepting proxy: a tool that sits between your browser and a website and lets you pause, read and edit every message in both directions.
  • JWT (JSON Web Token): a popular kind of token that bundles information and can be checked for tampering.
  • Opaque: a value you cannot read anything useful out of; only the server can interpret it.
  • OTP (one-time password): a short code sent by text or email to prove it is really you.
  • Recon (reconnaissance): looking around a target before attacking it, to find its pages, features and technologies.
  • Referer: a header that tells the server which page you came from.
  • Request: the message your browser sends to a server, such as a login attempt.
  • Response: the message a server sends back to your browser.
  • Server: the computer somewhere else that runs the website and answers requests.
  • Set-Cookie: the response header a server uses to give the browser a cookie to store.
  • SSO (single sign-on): a login system where one account lets you into several websites.
  • Token: a value that stands in for something else, usually your identity.
  • Website: a program running on a server that your browser asks for pages.

Similar reports

View all

Same bug class and techniques, clearest first.

Insecure direct object reference (IDOR)

The lesson behind this report.

One user can read or change another user's data, usually by changing an identifier the server trusts without checking who is asking. One of the most paid bug classes on web programs.