Skip to content
IDOR Write-up Intermediate

IDOR via Websockets allow me to takeover any users account

A WebSocket request sent during signup accepted a user-supplied UUID, allowing an attacker to change another user's email address. The attacker could then log in as that user, taking over the account.

Mohsin Khan Follow

Published on mokhansec.medium.com

Bounty$450 View original

Hi everyone I hope you all are doing great and scoring lots of bounties. I am Mohsin khan I am from India and I do bug bounty full time for 1 year now.

Mohsin khan, on mokhansec.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

Mohsin Khan (@tabaahi_) describes a finding on a private program that he refers to as example.com, because the program did not permit disclosure of the target. The product is an online meeting platform. Users can create a team, invite users, follow other users, and assign permissions such as admin or normal user.

The bug is an IDOR that runs over a WebSocket rather than over a normal HTTP endpoint. By changing a UUID in the WebSocket request sent during signup, the researcher was able to change the email address of another account and then log in to it. The affected domain was out of scope, and the researcher says it was P2 but he was rewarded a P3 bounty.

Setup

The researcher worked with two accounts of his own:

  • Account A, an existing account whose password he already knew.
  • Account B, a second account created during testing.

He used Burp Suite to intercept and inspect requests and responses, starting with the name and email change functionality. He notes that he does not know many bug classes and mostly tests login, save info and signup flows, which is why he created the second account and examined every request and response of the signup process.

Finding it

While testing the change of name and email, he noticed an X-token header carrying a JWT. He reasoned that a JWT makes CSRF almost impossible on the site, and confirmed this by removing the token and trying to change information: the website returned 401.

He then moved to signup. He found that after the signup POST request, a WebSocket request is sent which contains the UUID, email, username and other fields. That request is the object of the attack.

From the original on mokhansec.medium.com

Exploitation

Step 1: Change the UUID to another account

He changed the UUID in the WebSocket request to the UUID of his first account (Account A). The response was an error:

Text
Email already exists.

He understood the reason: the email in the request still belonged to Account B, and Account B had already been created, so the same email could not be used again.

From the original on mokhansec.medium.com

Step 2: Change the UUID and the email together

He sent the request again with Account A's UUID and a different email address. This time he got no response. When he went back to Account A and reloaded the page, he was logged out.

He tried to log in again with Account A's original email and got an error. He took the logout after the email change as confirmation that Account A's email had been changed successfully. Since he already knew Account A's password, and now controlled the email address as well, he could also have requested a password reset link. He logged in with the new email and was inside Account A.

Step 3: Obtaining the victim's UUID

A reader question in the write-up asks how the UUID was found. The answer: on the online meeting platform, going to a user's profile and clicking the follow user button lets you grep the user's UUID easily.

From the original on mokhansec.medium.com

The report was rated P2 but rewarded as P3 because the domain was out of scope.

From the original on mokhansec.medium.com

Root cause

The WebSocket request sent after signup carries a UUID and an email, and changing the UUID to another account's value changed that account's email. Because the email field is processed in the same request, an attacker who knows a victim's UUID can rewrite the victim's email address. Removing the X-token JWT from HTTP requests gave a 401, but the WebSocket request still acted on another user's UUID.

The report does not show the WebSocket payload itself, so the exact field names and message format are not available.

Impact

An attacker who knows a victim's UUID can change the victim's email address; the researcher did this to his own account and logged in with the new email. The UUID can be obtained from a user's profile by using the follow user button. The researcher describes the finding as allowing him to take over all users' accounts. The affected domain was out of scope, and the report was rated P2 but rewarded as P3.

Fix

The report does not describe a fix. The change that would address the issue is for the server to derive the account from the authenticated session or token instead of accepting a client-supplied UUID, and to reject any request where the UUID does not match the authenticated user.

Variants to test

  1. Signup and profile WebSocket messages. Intercept the WebSocket frames sent after signup and during profile updates, and replace any identifier (UUID, user id, team id) with one belonging to another account. A positive result is a response that modifies the other account, such as an email change or a permission change.
  2. Email change combined with identifier change. If changing the identifier alone returns an error such as an existing email, change the email in the same request. A positive result is a successful change on the victim account, followed by a logout of the victim.
  3. Permission fields. In a team product, try changing the role or permission fields in the same WebSocket message alongside another user's identifier. A positive result is the victim being granted or losing admin rights.
  4. Identifier harvesting. Check whether user identifiers are exposed on public profiles or through follow, invite or search actions, as they were here. A positive result is a UUID or id that can be matched to a target account.
  5. HTTP equivalents. Test the same identifier substitution on ordinary REST endpoints for name, email and team management, since the WebSocket path may not be the only one that trusts client-supplied identifiers.

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. 10 min read.

What happened, in plain words

A security researcher found a way to take over other people's accounts on a website. The website was an online meeting platform, a bit like a video-call service where people form teams, invite colleagues, follow each other and give some people admin rights. The company ran a bug bounty programme: a scheme where companies pay people for reporting security holes instead of punishing them.

The hole was in a part of the website that most people never look at: the WebSocket. A WebSocket is a two-way connection between your browser and the server that stays open, like a phone call that is never hung up, instead of the usual pattern where you ask a question and get one answer. When someone signed up, the browser sent a WebSocket message containing a UUID (a long random-looking identifier for an account) and an email address. The server acted on whatever UUID the browser sent. By putting his other account's UUID in that message and changing the email, the researcher changed that account's email address and then logged in as it.

The report calls the target example.com because the programme was private and the researcher was not allowed to name it. The domain where the bug was found was out of scope, meaning it was not officially part of the programme's rules. The researcher says it was P2 but he was rewarded a P3 bounty.

From the original on mokhansec.medium.com

The setup: two accounts and a tool

To test safely, the researcher used two accounts that both belonged to him:

  • Account A: an existing account. He already knew its password.
  • Account B: a second account he created during testing.

Having two accounts is the standard way to test for this kind of bug. You need one account to act as the attacker and one to act as the victim, and you need to be allowed to touch both.

He used Burp Suite, a program that sits between your browser and a website and lets you read and edit every request before it is sent. Think of it as a postal worker who lets you open every letter you send and rewrite it before delivery. He started with the name and email change screens, because those are the places where a website lets you modify account details, and modification is where this class of bug usually lives.

He is honest that he does not know many bug classes and mostly tests login, save info and signup. That is why he created the second account and watched every request and response of the signup process. The lesson is not that you need to know everything; it is that you need to look carefully at a few flows.

First observation: the X-token header

While changing his name and email, he noticed a header called X-token carrying a JWT. Two concepts need unpacking here.

A header is a small line of extra information that travels with every request, like the label on a parcel. A JWT (JSON Web Token) is a signed piece of text that the server gives you after you log in, and that your browser sends back with each request so the server knows who you are. It is signed, so you cannot change it without the server noticing. It works a bit like a wristband at a festival: the staff gave it to you, it is hard to forge, and it proves you paid to get in.

He reasoned that if every request carries a JWT, then CSRF is almost impossible on this site. CSRF (Cross-Site Request Forgery) is an attack where a malicious website makes your browser send a request to another site while you are logged in there, relying on the fact that your browser automatically attaches your credentials. If the site requires a token that a malicious site cannot know, that trick fails.

To confirm, he removed the token and tried to change information. The website answered 401. HTTP status 401 means "not authorised": the server did not recognise you, so it refused. This told him the normal HTTP requests were well protected, and he needed to look elsewhere.

Finding the WebSocket

He moved to signup. When you fill in the signup form and click the button, the browser first sends a normal POST request (the standard way a browser submits a form) and then, he found, a WebSocket request is sent which contains the UUID, email, username and other fields.

This is the key moment of the whole report. Most testers stop at the POST request. The WebSocket message that follows is easy to miss because it does not look like a normal page load, and many tools show it in a separate tab. That message is the object of the attack.

Step 1: Change the UUID to another account

He changed the UUID in the WebSocket request to the UUID of Account A, his first account. The server replied with an error:

Text
Email already exists.

Line by line, this is simple: it is the text of the error message the server sent back. There is no code to read here, just the server's words.

Why did it happen? The email in the request still belonged to Account B, and Account B had already been created, so the same email could not be used again. The server was trying to update the account identified by the UUID (Account A) with the email of Account B, and it refused because that email was taken. The error showed the email was the obstacle, so he changed the email in the same request. It just needs a valid email to go with it.

From the original on mokhansec.medium.com

Step 2: Change the UUID and the email together

He sent the request again, this time with Account A's UUID and a different email address. He got no response. When he went back to Account A and reloaded the page, he was logged out.

He tried to log in again with Account A's original email and got an error. He took the logout after the email change as confirmation that the email had been changed. That logout was the confirmation that Account A's email had been changed successfully. Since he already knew Account A's password, and now controlled the email address as well, he could also have requested a password reset link. He logged in with the new email and was inside Account A.

This is the takeover. The important detail for a beginner is the order of events: the error in step 1 was not a dead end, it was a hint. Changing one field was not enough; changing two fields together was. Many people give up at the first error message.

Step 3: Where does the victim's UUID come from?

A reader asked how the UUID was found. The answer: on the online meeting platform, going to a user's profile and clicking the follow user button lets you grep the user's UUID easily. To grep means to search text for a pattern; here it means looking at the data the page receives and picking out the identifier. The follow button needs to know which user you are following, so the page has to carry that user's identifier somewhere, and it was visible.

This matters because the attack needs a target's UUID. If identifiers were secret, the bug would be much harder to use. They were not secret.

From the original on mokhansec.medium.com

The report was rated P2 but rewarded as P3 because the domain was out of scope.

From the original on mokhansec.medium.com

Why it worked

The WebSocket request sent after signup carries a UUID and an email, and changing the UUID to another account's value changed that account's email. In plain words: the server asked the browser "which account should I update?" and believed the answer. It should have looked up the account from the JWT instead, the way a bank teller checks your ID rather than taking your word for who you are.

Because the email field is processed in the same request, an attacker who knows a victim's UUID can rewrite the victim's email address. Removing the X-token JWT from HTTP requests gave a 401, but the WebSocket request still acted on another user's UUID. Protection in one place does not automatically cover another.

The report does not show the WebSocket payload itself, so the exact field names and message format are not available.

What an attacker could do

An attacker who knows a victim's UUID can change the victim's email address; the researcher did this to his own account and logged in with the new email. The UUID can be obtained from a user's profile by using the follow user button. The researcher describes the finding as allowing him to take over all users' accounts. The affected domain was out of scope, and the report was rated P2 but rewarded as P3.

How to fix it

The report does not describe a fix. The change that would address the issue is for the server to derive the account from the authenticated session or token instead of accepting a client-supplied UUID, and to reject any request where the UUID does not match the authenticated user.

Things to try yourself

  1. Signup and profile WebSocket messages. Intercept the WebSocket frames sent after signup and during profile updates, and replace any identifier (UUID, user id, team id) with one belonging to another account. A positive result is a response that modifies the other account, such as an email change or a permission change.
  2. Email change combined with identifier change. If changing the identifier alone returns an error such as an existing email, change the email in the same request. A positive result is a successful change on the victim account, followed by a logout of the victim.
  3. Permission fields. In a team product, try changing the role or permission fields in the same WebSocket message alongside another user's identifier. A positive result is the victim being granted or losing admin rights.
  4. Identifier harvesting. Check whether user identifiers are exposed on public profiles or through follow, invite or search actions, as they were here. A positive result is a UUID or id that can be matched to a target account.
  5. HTTP equivalents. Test the same identifier substitution on ordinary REST endpoints for name, email and team management, since the WebSocket path may not be the only one that trusts client-supplied identifiers.

Glossary

  • Bug bounty programme: a scheme where a company pays researchers for reporting security problems in its systems.
  • Private programme: a bounty programme that only invited researchers can see and test.
  • Out of scope: a system or domain that the programme's rules do not cover, so findings there may not be rewarded in full.
  • P2 / P3: severity ratings used by bounty platforms, where P1 is usually the most severe and the numbers go up as severity goes down.
  • IDOR: Insecure Direct Object Reference, a bug where a website lets you access or change something by supplying its identifier, without checking that it belongs to you.
  • UUID: a long, random-looking identifier used to refer to an account or object.
  • WebSocket: a two-way connection between browser and server that stays open, unlike a normal request that ends with one response.
  • HTTP request: the message a browser sends to a server to ask for a page or submit data.
  • POST request: an HTTP request that sends data to the server, typically used for forms such as signup.
  • Header: a line of extra information attached to an HTTP request or response.
  • X-token: the name of a custom header used by this site to carry a token.
  • JWT: JSON Web Token, a signed piece of text that proves who you are after logging in.
  • CSRF: Cross-Site Request Forgery, an attack where another website makes your browser send a request to a site where you are logged in.
  • 401: an HTTP status meaning the server did not recognise you or your credentials.
  • Burp Suite: a tool that intercepts traffic between your browser and a website so you can read and edit requests.
  • Intercept: to catch a request before it reaches the server so you can inspect or change it.
  • Grep: to search text for a pattern, here used for picking an identifier out of page data.
  • Endpoint: a specific address on a server that accepts requests, such as a signup or profile-update URL.
  • REST endpoint: an ordinary HTTP address that a website uses to read or change data.
  • Root cause: the underlying mistake in the code that makes a bug possible.
  • Payload: the data sent inside a request, such as the fields in a WebSocket message.
  • Session: the period during which a server remembers that you are logged in.
  • Password reset link: an email link that lets you set a new password for an account, sent to the address on file.

More by Mohsin Khan

View all

3 more disclosed reports, best first.

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.