Skip to content
IDOR Write-up Intermediate

Bypassing an IDOR A couple of times — $$$$

A user profile API endpoint returned other users' data when the numeric user ID in the path was changed, and the author found two successive ways to bypass the access check. This leaked personal information such as first name, last name, display name and email address of arbitrary users.

Omar ElSayed Follow

Published on medium.com

Bounty$2,000 View original

This writeup is about an IDOR, I’ma share How I was able to find and bypass an IDOR twice which leaked users PII.

Omar ElSayed, 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. 8 min read.

Context

The target was a web application for sharing projects and ideas, described in the report as being more like a forum. Users can register and log in, reply to posts and projects, and each user has a profile. A profile supports reading, updating and deleting information such as first name and email, and every user has a numeric ID. The profile settings page lives at /profile/settings, and loading it causes the browser to call an API endpoint under /api/v4/user/.

The researcher had already reported some low severity bugs in this application, and chose to test it deeply because it was old and large.

Photo by Enciphers From the original on medium.com

Setup

The only tooling mentioned is Burp, which the researcher turned on before navigating to the profile settings page. The work was done against a logged-in account whose numeric user ID was 22652. The requests shown use HTTP/2 over TLS, with the Host, Cookie and Referer values redacted in the report, and a Firefox 122 user agent on Windows. No other accounts, roles or versions are described.

Finding it

Visiting /profile/settings sent a request to /api/v4/user/22652, the researcher's own ID in the path:

The response returned the user object for that ID:

HTTP
HTTjP/2 200 OKServer: nginxDate: Wed, 07 Feb 2024 00:19:56 GMTContent-Type: application/jsonVary: Accept-EncodingExpires: Thu, 19 Nov 1981 08:52:00 GMTCache-Control: no-store, no-cache, must-revalidatePragma: no-cacheStrict-Transport-Security: max-age=31536000;preloadReferrer-Policy: strict-origin-when-cross-origin{"id":22652,"isMe":true,"created":{"date":"2023-11-23 08:24:19.000000","timezone_type":3,"timezone":"Europe\/Berlin"},"updated":{"date":"2024-02-07 01:15:33.000000","timezone_type":3,"timezone":"Europe\/Berlin"},"deleted":null,"inactive":null,"isEmployee":false,"meta":{"language":"en","model":"User","modelnameIndex":{"User":[""]}}}

A numeric identifier in the path, with the object returned straight from it, is the classic shape of an IDOR candidate, so the researcher tried a series of manipulations:

  1. Changing the ID to another ID.
  2. Changing the API version, for example /api/v1/user/1.
  3. Adding an extension to the end of the user ID, for example /api/v4/user/1.json.
  4. Sending the request without an ID, for example /api/v4/user/.
  5. Sending the request without an ID using the plural form, for example /api/v4/users/.
  6. Replacing the ID with an asterisk, for example /api/v4/user/*.
  7. Path traversal, for example /api/v4/user/22652/../1.
  8. Sending a page or pageSize parameter, for example /api/v4/user/?page=1, which the researcher notes worked a few times.

Two error responses came back during this probing. A forbidden response:

HTTP
HTTP/2 403 ForbiddenServer: nginxDate: Wed, 07 Feb 2024 00:43:39 GMTContent-Type: text/html; charset=UTF-8Vary: Accept-EncodingExpires: Thu, 19 Nov 1981 08:52:00 GMTCache-Control: no-store, no-cache, must-revalidatePragma: no-cacheStrict-Transport-Security: max-age=31536000;preloadReferrer-Policy: strict-origin-when-cross-origin{"errors":{"status":403,"title":"Forbidden"},"data":[]}

And a not found response:

Exploitation

Step 1: change the request method

After a few hours the researcher returned to the same endpoint and started playing with request methods:

  • Changing the method to POST produced no 404.
  • Changing the method to PATCH produced a 500 error code.
From the original on medium.com

Step 2: PUT with a method override

The next attempt was a PUT request with a _method parameter in the body set to PATCH:

HTTP
PUT /api/v4/user/1 HTTP/2Host: redactedCookie: redcatedUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0Accept: application/json, text/plain, */*Accept-Language: en-US,en;q=0.5Accept-Encoding: gzip, deflateReferer: redactedX-Requested-With: XMLHttpRequestSec-Fetch-Dest: emptySec-Fetch-Mode: corsSec-Fetch-Site: same-originTe: trailersContent-Length: 12_method=PATCH

This returned another user's object, but inconsistently: sometimes the response was a 500 error.

HTTP
HTTP/2 500 Internal Server ErrorContent-Length: 97Cache-control: no-cacheContent-type: text/html<html><body><h1>500 Internal Server Error</h1></body></html>

Sometimes it was a 200 with the user information:

HTTP
HTTP/2 200 OKServer: nginxDate: Wed, 07 Feb 2024 19:23:18 GMTContent-Type: application/jsonVary: Accept-EncodingExpires: Thu, 19 Nov 1981 08:52:00 GMTCache-Control: no-store, no-cache, must-revalidatePragma: no-cacheStrict-Transport-Security: max-age=31536000;preloadReferrer-Policy: strict-origin-when-cross-origin{"id":1,"isMe":false,"created":{"date":"2010-06-01 18:00:01.000000","timezone_type":3,"timezone":"Europe\/Berlin"},"updated":{"date":"2022-05-31 18:54:41.000000","timezone_type":3,"timezone":"Europe\/Berlin"},"deleted":null,"inactive":null,"isEmployee":false,"meta":{"language":"de","model":"User","modelnameIndex":{"User":[""]}}}

Step 3: add the include parameter to leak PII

The base object was not enough information, so the researcher dug into the application and found a parameter called include that accepts values such as firstname, lastname and email. When it is used, the response contains those fields for the current user, for example firstname,lastname,displayName,email,image,isMe. The request became:

And the response carried the personal data:

Step 4: the triager cannot reproduce it

The researcher reported it in this form. The next day the triager said he was not able to reproduce the vulnerability: it was no longer working and he was getting 401 unauthorized.

From the original on medium.com

Step 5: resend the PUT with an empty body

The researcher tried again. He does not know why it happened, but when he removed the whole body and sent the PUT request with nothing in it, the request went through:

Finally, it worked!! From the original on medium.com

Step 6: the fix, and a new request shape

After a long time the researcher was testing the same subdomain and returned to the same API endpoint. He asked himself whether the old IDOR still worked (no) and whether any of the bypasses worked (no).

He then changed the profile firstname to see what the request looked like:

The interesting part was that this is the same PUT request, but the ID is now set with the id parameter in the body, which suggested a bypass was possible. Two attempts failed:

  • Changing the ID to another ID returned 403.
  • HTTP parameter pollution, for example id=22652&id=1, returned 403.
From the original on medium.com

Step 7: body and path are both processed

After hours of testing the researcher discovered that the request takes and processes both the body and the path. As an example, this request would change his firstname and also respond with his email, which normally does not happen:

Step 8: own ID in the path, victim ID in the body

The final request sends the researcher's own user ID in the path, /api/v4/user/22652, and the victim's ID in the request body:

It worked. The researcher notes that he had to remove firstname because it would return a 403.

HTTP
HTTP/2 200 OKServer: nginxDate: Thu, 08 Feb 2024 19:08:52 GMTContent-Type: application/jsonVary: Accept-EncodingExpires: Thu, 19 Nov 1981 08:52:00 GMTCache-Control: no-store, no-cache, must-revalidatePragma: no-cacheStrict-Transport-Security: max-age=31536000;preloadReferrer-Policy: strict-origin-when-cross-origin{"id":22651,"firstname":"","lastname":"","displayName":"","email":"","isMe":false,"created":{"date":"2023-11-23 02:32:16.000000","timezone_type":3,"timezone":"Europe\/Berlin"},"updated":{"date":"2023-11-23 02:32:48.000000","timezone_type":3,"timezone":"Europe\/Berlin"},"deleted":null,"inactive":null,"isEmployee":false,"meta":{"language":"de","model":"User","modelnameIndex":{"User":[""]}}}
From the original on medium.com

Root cause

The report does not describe the server-side code, so the following is inferred from behaviour. The report does not describe the server-side code. One possible explanation is that the request is authorised against the path identifier while the returned object is selected by the body id, but the report does not confirm this. The two identifiers are never checked against each other, so a request that is authorised for one user returns another user's record. The include parameter then controls which fields are serialised into the response, which is what turns a bare user object into a leak of first name, last name, display name and email.

The responses were inconsistent, and the researcher says he does not know why removing the body made the request succeed.

Impact

An authenticated user could read the profile data of other users by ID, including first name, last name, display name and email when the include parameter listed them. The researcher describes the leak as users' PII.

Fix

Based on the behaviour, the fix should be to derive the target user from the authenticated session or from the path identifier only, and to reject any request where the body id differs from the authorised user.

Variants to test

  1. Send a PUT or PATCH to a user endpoint with your own ID in the path and another ID in the body, and add ?include= with fields such as email. A positive result is a 200 containing the other user's fields.
  2. Try the same split between path and body on other verbs and endpoints, for example POST /api/v4/user/ with id=<victim>. A positive result is a created or updated object belonging to another user.
  3. Add _method=PATCH or _method=PUT to a PUT body and repeat the request several times. A positive result is a 200 with another user's object where the plain method returns 403 or 404.
  4. Remove the request body entirely and resend the same PUT. A positive result is a 200 where the request with a body failed.
  5. Try HTTP parameter pollution in the body, for example id=<own>&id=<victim>, and in the query string. A positive result is a response for the victim's ID.
  6. Try the include parameter with different field lists on endpoints that return your own object. A positive result is extra fields such as email appearing in the response.
  7. Try the enumeration tricks listed in the report against other numeric-ID endpoints: version changes, .json suffixes, *, path traversal, and page or pageSize parameters. A positive result is any response containing an object that is not yours.

Timeline

Date Event
Feb 8, 2024 Reported
Mar 4, 2024 2000 USD bounty rewarded

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

What happened, in plain words

A security researcher found a bug in a website where people share projects and ideas, a site that works a bit like a forum. On that site every user has a profile, and every profile has a number attached to it, called an ID. The bug let one logged-in user ask the site for another user's profile and get back personal details such as first name, last name, display name and email address. This kind of bug is called an IDOR, short for Insecure Direct Object Reference: the site takes a number from the user and uses it to look up a record directly, without checking that the person asking is allowed to see that record. Think of a hotel where the receptionist hands you the key to room 22652 because you asked for it, without ever checking that you are the guest in that room.

The researcher found the bug, reported it, was told it could no longer be reproduced, found a way to make it work again, and later, after the site was fixed, found another bypass. The report was rewarded with a 2000 USD bounty. The timeline at the end of the report gives two dates: reported on 8 February 2024, bounty paid on 4 March 2024.

Photo by Enciphers From the original on medium.com

The target and the tools

The application is described in the report as a web application for sharing projects and ideas, more like a forum. People can register and log in, reply to posts and projects, and each user has a profile. A profile supports reading, updating and deleting information such as first name and email, and every user has a numeric ID. The profile settings page lives at /profile/settings, and simply opening it makes the browser call an API endpoint under /api/v4/user/.

A few words that come up constantly from here on:

  • API: the part of a website that the page talks to behind the scenes, exchanging data instead of pretty pages. When you open your profile settings, the page does not contain your name and email in its HTML; it asks the API for them and fills them in. An API is like the kitchen of a restaurant: you (the page) place an order, the kitchen (the API) sends back a plate of data.
  • Endpoint: one specific address on that API, for example /api/v4/user/22652. It is the equivalent of one particular counter in the kitchen.
  • Request: the message your browser sends to ask for something. It has a method (a verb saying what you want to do), a path (which endpoint), headers (extra information) and sometimes a body (data you attach).
  • Response: the message the server sends back, usually with a status code (a three-digit number saying how it went) and a body (the data).
  • Cookie: a small piece of data the site stores in your browser after you log in, and which your browser sends back with every request so the site knows who you are. It works like a wristband at a festival: you show it at the gate and you are let in without showing your ticket again.
  • Burp: a tool that sits between your browser and the website and lets you read, pause and edit every request and response. It is like a recording machine on the phone line between you and the site.

The researcher had already reported some low severity bugs in this application, and chose to test it deeply because it was old and large. Old and large means lots of features and lots of code written over the years, which is where mistakes tend to hide.

The only tooling mentioned is Burp, which the researcher turned on before navigating to the profile settings page. The work was done against a logged-in account whose numeric user ID was 22652. The requests shown use HTTP/2 over TLS, with the Host, Cookie and Referer values redacted in the report, and a Firefox 122 user agent on Windows. No other accounts, roles or versions are described.

Finding it

Visiting /profile/settings sent a request to /api/v4/user/22652, the researcher's own ID in the path:

Line by line:

  • GET /api/v4/user/22652 HTTP/2 is the request line. GET is the method used to read something without changing it. /api/v4/user/22652 is the path: version 4 of the API, the user resource, and the number 22652. HTTP/2 is the version of the protocol used to speak to the server.
  • Host: redacted is the site's domain name, hidden in the report.
  • Cookie: redacted is the login wristband, also hidden. Without it the server would not know who is asking.
  • User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0 tells the server which browser sent the request: Firefox 122 on 64-bit Windows.
  • Accept: application/json, text/plain, */* says the browser is happy to receive JSON (a text format for structured data), plain text, or anything else.
  • Accept-Language: en-US,en;q=0.5 says the browser prefers English.
  • Accept-Encoding: gzip, deflate says the browser can accept compressed responses.
  • Referer: https://redacted says which page the request came from, hidden here.
  • X-Requested-With: XMLHttpRequest is a header many JavaScript libraries add to mark a request as coming from script rather than a page navigation.
  • Sec-Fetch-Dest: empty, Sec-Fetch-Mode: cors, Sec-Fetch-Site: same-origin are modern browser headers describing what kind of request this is and that it goes to the same site.
  • Te: trailers says the client can accept trailing headers at the end of the response.

The response returned the user object for that ID:

HTTP
HTTjP/2 200 OKServer: nginxDate: Wed, 07 Feb 2024 00:19:56 GMTContent-Type: application/jsonVary: Accept-EncodingExpires: Thu, 19 Nov 1981 08:52:00 GMTCache-Control: no-store, no-cache, must-revalidatePragma: no-cacheStrict-Transport-Security: max-age=31536000;preloadReferrer-Policy: strict-origin-when-cross-origin{"id":22652,"isMe":true,"created":{"date":"2023-11-23 08:24:19.000000","timezone_type":3,"timezone":"Europe\/Berlin"},"updated":{"date":"2024-02-07 01:15:33.000000","timezone_type":3,"timezone":"Europe\/Berlin"},"deleted":null,"inactive":null,"isEmployee":false,"meta":{"language":"en","model":"User","modelnameIndex":{"User":[""]}}}

Line by line:

  • HTTjP/2 200 OK is the status line. 200 OK means the request succeeded. (The protocol token is garbled in the report as HTTjP/2; it is the HTTP/2 status line.)
  • Server: nginx says the web server software is nginx.
  • Date: Wed, 07 Feb 2024 00:19:56 GMT is when the server answered.
  • Content-Type: application/json says the body is JSON.
  • Vary: Accept-Encoding tells caches that the response depends on the compression the client accepts.
  • Expires: Thu, 19 Nov 1981 08:52:00 GMT is a date in the past, a common trick to say the response is already expired.
  • Cache-Control: no-store, no-cache, must-revalidate and Pragma: no-cache tell browsers and proxies not to keep a copy.
  • Strict-Transport-Security: max-age=31536000;preload tells the browser to always use HTTPS for this site for a year.
  • Referrer-Policy: strict-origin-when-cross-origin limits how much of the referring page is shared with other sites.
  • The body is a JSON object. "id":22652 is the user's number. "isMe":true says this record belongs to the person asking. created and updated hold timestamps with a timezone. deleted and inactive are null, meaning empty. isEmployee is false. meta holds small extras such as the language and the internal model name.

A numeric identifier in the path, with the object returned straight from it, is the classic shape of an IDOR candidate. The number is right there in the address, and the server seems to use it directly to fetch a record. The obvious question is: what happens if I change the number? So the researcher tried a series of manipulations:

  1. Changing the ID to another ID. The simplest test: ask for someone else's number.
  2. Changing the API version, for example /api/v1/user/1. Older versions of an API sometimes lack checks added later.
  3. Adding an extension to the end of the user ID, for example /api/v4/user/1.json. Some servers treat the .json suffix differently and route the request to a different handler.
  4. Sending the request without an ID, for example /api/v4/user/. Maybe the server falls back to listing users.
  5. Sending the request without an ID using the plural form, for example /api/v4/users/. A plural resource often means a collection, and collections sometimes return everything.
  6. Replacing the ID with an asterisk, for example /api/v4/user/*. A wildcard might mean all users to some routers.
  7. Path traversal, for example /api/v4/user/22652/../1. The .. means go up one level, so the path may be normalised to /api/v4/user/1 after any check on the original string has already passed.
  8. Sending a page or pageSize parameter, for example /api/v4/user/?page=1, which the researcher notes worked a few times. Pagination parameters suggest the endpoint can return lists, and lists can contain other people's records.

Two error responses came back during this probing. A forbidden response:

HTTP
HTTP/2 403 ForbiddenServer: nginxDate: Wed, 07 Feb 2024 00:43:39 GMTContent-Type: text/html; charset=UTF-8Vary: Accept-EncodingExpires: Thu, 19 Nov 1981 08:52:00 GMTCache-Control: no-store, no-cache, must-revalidatePragma: no-cacheStrict-Transport-Security: max-age=31536000;preloadReferrer-Policy: strict-origin-when-cross-origin{"errors":{"status":403,"title":"Forbidden"},"data":[]}

Line by line:

  • HTTP/2 403 Forbidden means the server understood the request but refused to allow it. This is the healthy answer when you ask for someone else's record.
  • The headers repeat the same security and caching settings as before.
  • The body is a small JSON error object: "status":403, "title":"Forbidden", and an empty data array.

And a not found response:

Line by line:

  • HTTP/2 404 Not Found means there is nothing at that address, at least as far as the server is concerned.
  • Content-Security-Policy: redacted is a header that restricts what a page may load; its value is hidden here.
  • X-Content-Type-Options: nosniff stops the browser from guessing a different content type than the one declared.
  • X-Download-Options: noopen is an old Internet Explorer setting about downloaded files.
  • X-Permitted-Cross-Domain-Policies: none restricts cross-domain policy files.
  • X-Powered-By: redacted would normally reveal the framework; it is hidden.
  • X-Xss-Protection: 1; mode=block is a legacy browser filter setting.
  • The body is {"errorCode":"redacted"}, a generic error code.

Notice the difference between the two: 403 means "not allowed", 404 means "not here". Both are refusals, but they come from different layers of the application, and that difference matters later.

Accessing users PII (bypass)

PII stands for Personally Identifiable Information: data that identifies a specific person, such as a name or an email address. The goal of the attack is to make the API return that data for someone other than the logged-in user.

After a few hours the researcher returned to the same endpoint and started playing with request methods. The method is the verb at the start of the request: GET reads, POST usually creates, PUT usually replaces, PATCH usually updates part of something, DELETE removes. Different verbs often reach different code on the server, and that code may have different checks.

  • Changing the method to POST produced no 404.
  • Changing the method to PATCH produced a 500 error code. A 500 means the server hit an unexpected error while handling the request, which is a sign that the request reached code that was not written to expect it.
From the original on medium.com

The next attempt was a PUT request with a _method parameter in the body set to PATCH:

HTTP
PUT /api/v4/user/1 HTTP/2Host: redactedCookie: redcatedUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0Accept: application/json, text/plain, */*Accept-Language: en-US,en;q=0.5Accept-Encoding: gzip, deflateReferer: redactedX-Requested-With: XMLHttpRequestSec-Fetch-Dest: emptySec-Fetch-Mode: corsSec-Fetch-Site: same-originTe: trailersContent-Length: 12_method=PATCH

Line by line:

  • PUT /api/v4/user/1 HTTP/2 sends a PUT to user number 1, which is not the researcher's own ID.
  • The headers are the same as before, with the cookie and referer hidden.
  • Content-Length: 12 says the body is 12 bytes long.
  • The body is _method=PATCH. This is a convention used by some frameworks: the real HTTP method is PUT, but the framework reads _method and treats the request as a PATCH. It exists because old browsers could not send PATCH directly. The effect here is that the request arrives as PUT, passes whatever check applies to PUT, and is then handled as PATCH.

This returned another user's object, but inconsistently: sometimes the response was a 500 error.

HTTP
HTTP/2 500 Internal Server ErrorContent-Length: 97Cache-control: no-cacheContent-type: text/html<html><body><h1>500 Internal Server Error</h1></body></html>

Line by line:

  • HTTP/2 500 Internal Server Error means the server crashed while handling the request.
  • Content-Length: 97 is the size of the body.
  • Cache-control: no-cache and Content-type: text/html describe the body.
  • The body is a minimal HTML page with the heading 500 Internal Server Error.

Sometimes it was a 200 with the user information:

HTTP
HTTP/2 200 OKServer: nginxDate: Wed, 07 Feb 2024 19:23:18 GMTContent-Type: application/jsonVary: Accept-EncodingExpires: Thu, 19 Nov 1981 08:52:00 GMTCache-Control: no-store, no-cache, must-revalidatePragma: no-cacheStrict-Transport-Security: max-age=31536000;preloadReferrer-Policy: strict-origin-when-cross-origin{"id":1,"isMe":false,"created":{"date":"2010-06-01 18:00:01.000000","timezone_type":3,"timezone":"Europe\/Berlin"},"updated":{"date":"2022-05-31 18:54:41.000000","timezone_type":3,"timezone":"Europe\/Berlin"},"deleted":null,"inactive":null,"isEmployee":false,"meta":{"language":"de","model":"User","modelnameIndex":{"User":[""]}}}

Line by line:

  • HTTP/2 200 OK means success.
  • The headers are the usual set.
  • The body is user number 1's record. "id":1 and "isMe":false are the key parts: this is not the researcher's own account. The account was created in 2010 and last updated in 2022, and its language is German.

So the method override worked, but only sometimes. The researcher says he does not know why the results varied.

Adding the include parameter

The base object was not enough information, so the researcher dug into the application and found a parameter called include that accepts values such as firstname, lastname and email. When it is used, the response contains those fields for the current user, for example firstname,lastname,displayName,email,image,isMe. A parameter is a piece of data attached to the request, either in the query string after a ? or in the body. The include parameter is like asking a shop assistant to also put the receipt and the warranty card in the bag: by default you get the product, with include you get extra fields.

The request became:

Line by line:

  • The path is still /api/v4/user/1, someone else's ID.
  • ?include=firstname%2Clastname%2CdisplayName%2Cemail%2Cimage%2CisMe is the query string. %2C is the URL encoding of a comma, so the value is the list firstname,lastname,displayName,email,image,isMe. The server is being asked to include those fields in the answer.
  • The rest of the headers are unchanged, and the body is still _method=PATCH with Content-Length: 12.

And the response carried the personal data:

Line by line:

  • HTTP/2 200 OK again.
  • The body now has firstname, lastname, displayName and email fields, all shown as redacted in the report because they are personal data. image is null. isMe is false, so this is another user's data.
  • The meta block now also mentions UserBadge, a small extra that appears when the include list asks for more fields.

This is the leak: another user's name and email address, returned to an account that should not see them.

The triager cannot reproduce it

The researcher reported it in this form. A triager is the person on the bug bounty platform who first checks a report before passing it to the company. The next day the triager said he was not able to reproduce the vulnerability: it was no longer working and he was getting 401 unauthorized. A 401 means "you are not authenticated": the server did not accept the caller's identity at all. So between the researcher's test and the triager's test, the behaviour had changed.

From the original on medium.com

Resending the PUT with an empty body

The researcher tried again. He does not know why it happened, but when he removed the whole body and sent the PUT request with nothing in it, the request went through:

Line by line:

  • The request line and path are the same as the working one: PUT /api/v4/user/1 with the include list.
  • The headers are the same, but there is no Content-Length and no body at all. The _method=PATCH line is gone.

Line by line:

  • HTTP/2 200 OK and the same personal fields as before, for user 1, with isMe false.

So the same leak came back with an empty body. The researcher never established why.

Finally, it worked!! From the original on medium.com

Bypassing the bypass

After a long time the researcher was testing the same subdomain and returned to the same API endpoint. A subdomain is a part of a domain, for example shop.example.com under example.com. He asked himself whether the old IDOR still worked (no) and whether any of the bypasses worked (no). The site had been fixed, at least against everything found so far.

He then changed the profile firstname to see what the request looked like. This is a normal user action: edit your own profile, watch what the browser sends.

Line by line:

  • PUT /api/v4/user/ HTTP/2 has no ID in the path at all. The path ends at the resource name.
  • Content-Type: application/x-www-form-urlencoded;charset=UTF-8 says the body is in the same format as a web form submission: key=value pairs joined by &.
  • Content-Length: 25 is the body size.
  • Origin: redacted says which site the request came from, hidden here.
  • The body is id=22652&firstname=testaq: the user's own ID and a new first name. So the ID is now in the body, not in the path.

The interesting part was that this is the same PUT request, but the ID is now set with the id parameter in the body, which suggested a bypass was possible. If the server trusts the body ID for choosing the record, maybe it can be pointed at someone else. Two attempts failed:

  • Changing the ID to another ID returned 403.
  • HTTP parameter pollution, for example id=22652&id=1, returned 403. HTTP parameter pollution means sending the same parameter twice with different values. Different parts of the server may pick different copies: one layer might check the first id and another might use the last. It is like writing two different addresses on one envelope and hoping the sorting office and the postman read different lines.
From the original on medium.com

Body and path are both processed

After hours of testing the researcher discovered that the request takes and processes both the body and the path. As an example, this request would change his firstname and also respond with his email, which normally does not happen:

Line by line:

  • PUT /api/v4/user/?include=email has no ID in the path, and asks for the email field to be included.
  • The headers are the form-encoded set from the profile edit.
  • Content-Length: 26 is the body size.
  • The body is id=22652&firstname=testaqq: the user's own ID and a new first name.

The point is that the query string (include=email) and the body (id=...&firstname=...) are both read and acted on by the same request. That is unusual enough to be worth exploiting: if the server reads the ID from one place for the permission check and from another place for the lookup, the two can be made to disagree.

Own ID in the path, victim ID in the body

The final request sends the researcher's own user ID in the path, /api/v4/user/22652, and the victim's ID in the request body:

Line by line:

  • PUT /api/v4/user/22652 puts the researcher's own ID in the path, the ID the server will check permission against.
  • ?include=firstname%2Clastname%2CdisplayName%2Cemail%2CisMe asks for the personal fields in the answer.
  • The headers are the form-encoded set.
  • Content-Length: 8 is the size of the body.
  • The body is id=22651, the victim's ID. This is the ID the server will use to choose which record to load.

It worked. The researcher notes that he had to remove firstname because it would return a 403. In other words, the body contained only the id parameter; the researcher says he had to remove firstname because it would return a 403.

HTTP
HTTP/2 200 OKServer: nginxDate: Thu, 08 Feb 2024 19:08:52 GMTContent-Type: application/jsonVary: Accept-EncodingExpires: Thu, 19 Nov 1981 08:52:00 GMTCache-Control: no-store, no-cache, must-revalidatePragma: no-cacheStrict-Transport-Security: max-age=31536000;preloadReferrer-Policy: strict-origin-when-cross-origin{"id":22651,"firstname":"","lastname":"","displayName":"","email":"","isMe":false,"created":{"date":"2023-11-23 02:32:16.000000","timezone_type":3,"timezone":"Europe\/Berlin"},"updated":{"date":"2023-11-23 02:32:48.000000","timezone_type":3,"timezone":"Europe\/Berlin"},"deleted":null,"inactive":null,"isEmployee":false,"meta":{"language":"de","model":"User","modelnameIndex":{"User":[""]}}}

Line by line:

  • HTTP/2 200 OK means success.
  • The body is user 22651's record, with isMe false. The name and email fields are present but empty in this particular account, which still proves the record was returned.
From the original on medium.com

Why it works

The report does not describe the server-side code, so the following is inferred from behaviour. The report does not describe the server-side code. One possible explanation is that the request is authorised against the path identifier while the returned object is selected by the body id, but the report does not confirm this. The two identifiers are never checked against each other, so a request that is authorised for one user returns another user's record. The include parameter then controls which fields are serialised into the response, which is what turns a bare user object into a leak of first name, last name, display name and email.

The responses were inconsistent, and the researcher says he does not know why removing the body made the request succeed.

Impact

An authenticated user could read the profile data of other users by ID, including first name, last name, display name and email when the include parameter listed them. The researcher describes the leak as users' PII.

Fix

Based on the behaviour, the fix should be to derive the target user from the authenticated session or from the path identifier only, and to reject any request where the body id differs from the authorised user.

Variants to test

  1. Send a PUT or PATCH to a user endpoint with your own ID in the path and another ID in the body, and add ?include= with fields such as email. A positive result is a 200 containing the other user's fields.
  2. Try the same split between path and body on other verbs and endpoints, for example POST /api/v4/user/ with id=<victim>. A positive result is a created or updated object belonging to another user.
  3. Add _method=PATCH or _method=PUT to a PUT body and repeat the request several times. A positive result is a 200 with another user's object where the plain method returns 403 or 404.
  4. Remove the request body entirely and resend the same PUT. A positive result is a 200 where the request with a body failed.
  5. Try HTTP parameter pollution in the body, for example id=<own>&id=<victim>, and in the query string. A positive result is a response for the victim's ID.
  6. Try the include parameter with different field lists on endpoints that return your own object. A positive result is extra fields such as email appearing in the response.
  7. Try the enumeration tricks listed in the report against other numeric-ID endpoints: version changes, .json suffixes, *, path traversal, and page or pageSize parameters. A positive result is any response containing an object that is not yours.

Timeline

Date Event
Feb 8, 2024 Reported
Mar 4, 2024 2000 USD bounty rewarded

Glossary

  • API: the part of a website that pages talk to behind the scenes, exchanging data rather than pages.
  • Endpoint: one specific address on an API, such as /api/v4/user/22652.
  • Request: the message a browser sends to a server, made of a method, a path, headers and sometimes a body.
  • Response: the message a server sends back, with a status code and usually a body.
  • Method (HTTP verb): the word at the start of a request saying what you want, such as GET to read, POST to create, PUT to replace, PATCH to update, DELETE to remove.
  • Status code: a three-digit number in a response saying how it went, such as 200 for success, 401 for not authenticated, 403 for forbidden, 404 for not found, 500 for a server error.
  • Header: an extra line of information in a request or response, such as Content-Type or Cookie.
  • Body: the data attached to a request or returned in a response.
  • Query string: the part of a URL after a ?, holding parameters such as ?include=email.
  • Parameter: a named piece of data sent with a request, in the query string or in the body.
  • Cookie: a small piece of data stored in the browser after login and sent back with each request so the server knows who you are.
  • Session: the server-side record of a logged-in user, identified by the cookie.
  • JSON: a text format for structured data, using braces, quotes and colons.
  • URL encoding: writing special characters in a URL as % plus a code, for example %2C for a comma.
  • HTTP/2: a version of the protocol browsers and servers use to talk to each other.
  • TLS / HTTPS: the encryption layer that protects traffic between browser and server.
  • Burp: a tool that sits between browser and server and lets you read and edit requests and responses.
  • IDOR: Insecure Direct Object Reference, a bug where a site uses an identifier supplied by the user to fetch a record without checking that the user is allowed to see it.
  • PII: Personally Identifiable Information, data that identifies a specific person, such as a name or email address.
  • Enumeration: trying identifiers one after another, such as 1, 2, 3, to collect records.
  • Path traversal: using .. in a path to move up a level, for example /api/v4/user/22652/../1.
  • Method override: a convention where a request carries a parameter such as _method=PATCH so the framework treats it as a different method than the one in the request line.
  • HTTP parameter pollution: sending the same parameter twice with different values, hoping different parts of the server read different copies.
  • Triager: the person on a bug bounty platform who first checks a report before passing it to the company.
  • Bug bounty: a programme where companies pay researchers for reporting security bugs.
  • Bounty: the money paid for a valid report.
  • Subdomain: a part of a domain, such as shop in shop.example.com.
  • User agent: a header telling the server which browser and operating system sent the request.
  • Referer: a header telling the server which page the request came from.
  • Origin: a header telling the server which site a request came from.
  • nginx: a common web server software.
  • Redacted: hidden or removed from a report, usually to protect secrets or personal data.

More by Omar ElSayed

View all

1 more disclosed report, 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.