Skip to content
IDOR Write-up Intermediate

How Source code reading helped me find an IDOR

A hidden 'secret' tab parameter was discovered in commented-out HTML source code, which when used in a request returned sensitive data for other users. An attacker could access other users' sensitive information by manipulating the user_id and tab parameters.

Sanjay Verdu Follow

Published on hack4bounty.com

by sanjayPosted onMay 22, 2020May 22, 2020

Sanjay Verdu (@codersanjay), on hack4bounty.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. 6 min read.

Context

The target was an e-commerce website. The report does not disclose the real name, so the author refers to it as https://www.example.com. The feature at the centre of the finding is the profile page, which loads its tabs through an AJAX request to /php/filter_user_tab_content.php. The tabs shown in the UI are things like orders, address and credit cards. Each tab is fetched by posting a user_id and a tab value to that endpoint, and the response is JSON.

The weakness is an IDOR combined with information disclosure: a tab that was never exposed in the UI (secret) was still served by the backend when named in the tab parameter.

Setup

  • A normal account on the site, created by signing up.
  • Burp Suite, used for its proxy history and Intruder.
  • Firefox 68.0 on macOS 10.14, as shown in the captured requests.
  • No special role or privilege is described. The researcher worked from his own account.

The report was not disclosed at the time of writing, which is why the host is anonymised.

Finding it

The author starts every engagement the same way: sign up, then browse the whole site for a while to learn what requests exist and where they go. On this target he spent around 15 minutes and found nothing obvious, such as sensitive information leaking through external links or login pages served over HTTP instead of HTTPS.

He then turned on Burp and clicked through every link while watching the HTTP history. He does not intercept from the first request; he first wants to see the shape of the traffic. He spent another 20 to 30 minutes on this.

Click Everywhere From the original on hack4bounty.com

While doing that, the profile page stood out. Its tabs (orders, address and so on) were loaded by a single endpoint, and the request looked like this:

HTTP
POST /php/filter_user_tab_content.php HTTP/1.1`
Host: www.example.com`
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://www.example.com/
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 92
Connection: close
Cookie: XXXXXXXXXXXXX

user_id=1234&tab=address

The body carries two parameters: user_id, which identifies whose data is being fetched, and tab, which selects which section of the profile to return. The X-Requested-With: XMLHttpRequest header shows it is called from JavaScript, and the Accept header shows the client expects JSON.

Exploitation

Step 1: brute force user_id

The obvious parameter is user_id. The author sent it to Intruder and brute forced it. Many responses came back as 200 OK.

Yesss From the original on hack4bounty.com

On inspection, every response except his own was empty. A 200 OK with an empty body is not a finding.

There is nothing in the response From the original on hack4bounty.com

Step 2: repeat on the other tabs

He tried the same approach on the other tabs, such as address and orders. The orders request was:

HTTP
POST /php/filter_user_tab_content.php HTTP/1.1`
Host: www.example.com`
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://www.example.com/
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 92
Connection: close
Cookie: XXXXXXXXXXXXX

user_id=1234&tab=orders

The address request was the same, only the tab value changed:

Text
user_id=1234&tab=address

He ran Intruder on both. The responses were empty again.

Empty responses again! From the original on hack4bounty.com

By this point it was around 3 AM and he was getting sleepy, but he did not stop.

From the original on hack4bounty.com

Step 3: enumerate the tab parameter from the source

He shifted his attention from user_id to tab and asked himself what names could go into it. From the profile page he already knew about orders, address and credit cards, and none of those were vulnerable.

So he read the page source. There he found a data attribute on the tab links, holding exactly the names used for the tab parameter:

HTML
<a href="x" data="orders">orders</a>
<a href="x" data="address">address</a>
....

That confirmed the values in data are what the request sends as tab. Continuing to scroll, he found a block that was commented out:

HTML
<a href="x" data="orders">orders</a>
<a href="x" data="address">address</a>
....
....
....
....
....
<!-- //commented
<a href="x" data="secret">secret</a>
-->

The commented-out link had the value secret and was not linked anywhere in the profile UI. His reasoning was that the secret tab had probably not been filtered yet and was still under development. He decided to try that name against the tab parameter.

Step 4: send tab=secret

HTTP
POST /php/filter_user_tab_content.php HTTP/1.1`
Host: www.example.com`
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://www.example.com/
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 92
Connection: close
Cookie: XXXXXXXXXXXXX

user_id=1234&tab=secret

The responses were still 200 OK, but this time they were not empty, and they contained sensitive data.

Finally! From the original on hack4bounty.com

He wrote the report and sent it to the program. A few hours later it came back ACCEPTED, with a bounty.

From the original on hack4bounty.com

The program also asked how he had found an endpoint with a parameter name that appeared nowhere in the UI. His answer: recon.

Submitted, resolved and bounty awarded all happened on the same day.

Root cause

The endpoint /php/filter_user_tab_content.php took the tab value from the client and served whatever section matched, including a secret section that was never meant to be reachable from the UI. The commented-out link in the page source shows the feature existed in the front end but was hidden only by being commented out, not by any server-side authorisation check. The empty responses on other users' user_id values suggest some per-user check existed for the normal tabs. That last point is inferred from the behaviour described; the report does not show the server code.

Impact

An authenticated user could request the secret tab and receive sensitive data in the response. The report does not describe what that data was, how many users were affected, or whether the secret tab returned data for arbitrary user_id values or only for the researcher's own. The normal tabs (orders, address) returned empty bodies for other users' IDs, so the exposure was specific to the hidden tab.

Fix

The fix that follows from the finding is to enforce authorisation on the server for every tab, including ones not exposed in the UI, and to check that the authenticated session is allowed to read the requested user_id rather than trusting the posted value. Hiding a feature by commenting it out of the HTML is not access control.

Variants to test

  1. Read the page source for hidden parameter values. Look for data attributes, commented-out markup, disabled options and JavaScript constants that name values the UI never sends. A positive result is a value the backend accepts and returns content for.
  2. Enumerate the selector parameter, not just the identifier. When a request has both an object ID and a section or view name, brute force the section name with a wordlist built from the source. A positive result is a 200 with a non-empty body for a section not in the UI.
  3. Compare response bodies, not status codes. Many 200 OK responses were empty. Filter on response length or content to find the ones that matter.
  4. Test each tab separately against other users' IDs. A check may exist for one tab and not another. A positive result is another user's data returned for a tab that was previously empty.
  5. Check development and staging leftovers. Names like secret, admin, internal, test and debug in commented code are worth trying against the same endpoint.

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

What happened, in plain words

A security researcher spent a night looking at an online shop. He signed up for a normal account, clicked around the site with a tool that records every request his browser makes, and noticed that his profile page loaded its sections (orders, address, credit cards) by asking the server for them one at a time. Each of those requests carried two pieces of information: a number saying whose profile it was, and a word saying which section to show.

He first tried changing the number, hoping to see other people's orders. Every attempt came back empty. He then read the page's source code (the HTML that the browser receives and renders) and found a section name that was commented out, meaning it was written in the code but deliberately disabled so the browser would not display it. The name was secret. He sent that name to the server anyway, and the server returned sensitive data. He reported it, the program accepted it, and he was paid a bounty.

That is the whole story. The rest of this article walks through it slowly, explaining each tool and each idea as it appears.

The setting

The target was an e-commerce website, the kind where you register, browse products and manage your account. The report was not publicly disclosed at the time it was written, so the author hides the real address and calls the site https://www.example.com throughout. Whenever you see example.com in this article, read it as "the real shop, name withheld".

The part of the site that matters is the profile page. A profile page usually has several tabs: one for your orders, one for your saved addresses, one for your stored credit cards. On many modern sites those tabs are not separate web pages. Instead, when you click a tab, the browser quietly asks the server for just that piece of content and slots it into the page without reloading. That kind of background request is often called an API call, or an AJAX request.

An API is best pictured as a serving hatch at a restaurant. You do not walk into the kitchen; you pass a small written order through the hatch and a plate comes back. The web page is the dining room, the server is the kitchen, and the request is the written order. The important consequence is that the written order is composed by your browser, and anything your browser composes can be changed by you.

The request that fetched a profile tab went to a file called /php/filter_user_tab_content.php. The name is descriptive: it filters (selects) the content of a user tab. It accepted two values, user_id and tab, and answered with JSON, a plain text format for structured data that JavaScript can read easily.

The weakness, named

The finding is an IDOR, short for Insecure Direct Object Reference. The phrase sounds heavy; the idea is simple. A direct object reference is when a request names the thing it wants directly, for example "give me the record numbered 1234". It is insecure when the server hands over whatever number you ask for without checking that the number belongs to you. Compare it to a hotel where the receptionist gives you a key to any room number you say out loud, instead of only the room you booked.

The second label is information disclosure: data that should have stayed private was handed out. Here the two combine. The server was willing to serve a section called secret that was never shown in the interface, purely because the client named it in the tab parameter.

Setting up

The author's setup, as described:

  • A normal account on the site, created by signing up. No special role or privilege is mentioned; he worked from his own account.
  • Burp Suite, a tool that sits between your browser and the internet and records every request and response. It has two features used here: the proxy history, a log of everything that passed through, and Intruder, which resends one request many times with one part swapped for each value in a list.
  • Firefox 68.0 on macOS 10.14, which is simply what the captured requests show in their headers.

If Burp is new to you: think of it as a recording clerk standing between you and the kitchen, writing down every order you send and every plate that comes back. Once the clerk is in place, you can also hand him a stack of variant orders and ask him to try them all.

Finding it

The author starts every engagement the same way: sign up, then browse the whole site for a while to learn what requests exist and where they go. On this target he spent around 15 minutes and found nothing obvious, such as sensitive information leaking through external links or login pages served over HTTP instead of HTTPS. HTTPS is the encrypted version of the web's transport protocol; a login page served over plain HTTP means the password travels in a form others on the network could read.

He then turned on Burp and clicked through every link while watching the HTTP history. He does not intercept from the first request; he first wants to see the shape of the traffic. He spent another 20 to 30 minutes on this.

Click Everywhere From the original on hack4bounty.com

The screenshot is captioned "Click Everywhere" and shows the browsing phase: the point is to click every link and watch what the browser asks for, before trying to break anything.

While doing that, the profile page stood out. Its tabs (orders, address and so on) were loaded by a single endpoint, and the request looked like this:

HTTP
POST /php/filter_user_tab_content.php HTTP/1.1`
Host: www.example.com`
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://www.example.com/
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 92
Connection: close
Cookie: XXXXXXXXXXXXX

user_id=1234&tab=address

Line by line, in plain words:

  • POST /php/filter_user_tab_content.php HTTP/1.1 is the request line. POST means "I am sending data to the server", as opposed to GET which means "I want to read a page". The path names the script being called, and HTTP/1.1 is the version of the protocol.
  • Host: www.example.com says which website the request is for. One server can host many sites, so the request must name the one it wants.
  • User-Agent describes the browser and operating system that sent the request. Here it identifies Firefox 68.0 on macOS 10.14.
  • Accept lists the formats the browser is willing to receive. application/json means structured data, and the rest are fallbacks.
  • Accept-Language says the browser prefers English (US).
  • Accept-Encoding says the browser can accept compressed responses, to save bandwidth.
  • Referer says which page the request was made from. Here it is the site's front page.
  • Content-Type: application/x-www-form-urlencoded says how the body below is formatted: as name=value pairs joined by &, the same format a web form uses.
  • X-Requested-With: XMLHttpRequest is a marker that JavaScript added it. It tells the server the call came from code running in the page, not from a person typing an address.
  • Content-Length: 92 is the size of the body in bytes.
  • Connection: close asks the server to close the connection after answering.
  • Cookie: XXXXXXXXXXXXX carries the session cookie. A cookie is a small piece of text the site stored in your browser when you logged in, and the browser sends it back with every request so the server knows who you are. Think of it as the wristband you get at an event: you show it at every door instead of showing your ticket again. The value is masked here because it is a secret; anyone holding it could act as the logged-in user.
  • The blank line separates the headers from the body.
  • user_id=1234&tab=address is the body. user_id identifies whose data is being fetched, and tab selects which section of the profile to return.

The X-Requested-With header shows the call is made from JavaScript, and the Accept header shows the client expects JSON back. Both are clues that this is a background data call, which is exactly the kind of place where access checks are easy to forget.

Exploitation

Step 1: brute force user_id

The obvious parameter is user_id. It is a number, and numbers can be counted through. The author sent the request to Intruder and brute forced it. Brute forcing here means trying a long list of values in the same request, one after another, and comparing the answers. Many responses came back as 200 OK.

Yesss From the original on hack4bounty.com

The screenshot is captioned "Yesss" and shows the moment the many 200 OK responses appeared, which looked like success.

A 200 OK is the standard status code for "the request worked". It is easy to read that as "I got in", but it only means the server processed the request without an error. On inspection, every response except his own was empty. A 200 OK with an empty body is not a finding: the server politely answered, and the answer was nothing.

There is nothing in the response From the original on hack4bounty.com

The screenshot is captioned "There is nothing in the response" and shows those empty answers, which is the lesson of this step: check the body, not just the status code.

Step 2: repeat on the other tabs

He tried the same approach on the other tabs, such as address and orders. The orders request was:

HTTP
POST /php/filter_user_tab_content.php HTTP/1.1`
Host: www.example.com`
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://www.example.com/
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 92
Connection: close
Cookie: XXXXXXXXXXXXX

user_id=1234&tab=orders

This is the same request as before with one change: the body now ends in tab=orders instead of tab=address. Everything above the blank line is identical, because the browser sends the same headers for every call to this script. The only thing that selects a different section is the tab value.

The address request was the same, only the tab value changed:

Text
user_id=1234&tab=address

He ran Intruder on both. The responses were empty again.

Empty responses again! From the original on hack4bounty.com

The screenshot is captioned "Empty responses again!" and shows the second round of empty answers, this time for the orders and address tabs.

By this point it was around 3 AM and he was getting sleepy, but he did not stop.

From the original on hack4bounty.com

This image sits at the point in the story where the author says he was sleepy but did not want to give up.

Step 3: enumerate the tab parameter from the source

He shifted his attention from user_id to tab and asked himself what names could go into it. This is a change of question, and it is the turning point. Instead of asking "whose data can I reach?", he asked "which sections exist at all?". From the profile page he already knew about orders, address and credit cards, and none of those were vulnerable.

So he read the page source. Every browser can show it: the source is the HTML the server sent, before the browser drew it on screen. It often contains things the screen does not show, such as disabled buttons, hidden fields and comments. There he found a data attribute on the tab links, holding exactly the names used for the tab parameter:

HTML
<a href="x" data="orders">orders</a>
<a href="x" data="address">address</a>
....

Line by line:

  • <a ...> is a link element. href="x" is where the link would point; here it is a placeholder, because the real action is handled by JavaScript rather than by following the link.
  • data="orders" is a custom attribute. HTML allows attributes that start with data- to carry extra information for scripts, and this one carries the name of the tab.
  • >orders</a> is the text the visitor sees on screen.
  • .... stands for more lines of the same kind, omitted for brevity.

That confirmed the values in data are what the request sends as tab. In other words, the page itself was publishing the list of valid section names. Continuing to scroll, he found a block that was commented out:

HTML
<a href="x" data="orders">orders</a>
<a href="x" data="address">address</a>
....
....
....
....
....
<!-- //commented
<a href="x" data="secret">secret</a>
-->

Line by line:

  • The first lines are the same visible tab links as before.
  • <!-- opens an HTML comment. Everything between <!-- and --> is ignored by the browser: it is not drawn, not clickable, and not part of the visible page. Developers use comments for notes, and sometimes to switch a feature off without deleting it.
  • //commented is a note left inside the comment, saying that this part is commented out.
  • <a href="x" data="secret">secret</a> is a link for a tab named secret, written exactly like the visible ones.
  • --> closes the comment.

The commented-out link had the value secret and was not linked anywhere in the profile UI. His reasoning was that the secret tab had probably not been filtered yet and was still under development. This is a reasonable guess: commenting a link out hides it from visitors but does nothing to the server, which still knows the name. He decided to try that name against the tab parameter.

Step 4: send tab=secret

HTTP
POST /php/filter_user_tab_content.php HTTP/1.1`
Host: www.example.com`
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Firefox/68.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://www.example.com/
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Content-Length: 92
Connection: close
Cookie: XXXXXXXXXXXXX

user_id=1234&tab=secret

Again the same request, with only the last word of the body changed: tab=secret. The headers are unchanged because the browser sends the same ones for every call to this script, and the cookie is the same because it is still the same logged-in session.

The responses were still 200 OK, but this time they were not empty, and they contained sensitive data.

Finally! From the original on hack4bounty.com

The screenshot is captioned "Finally!" and shows the moment the secret tab returned content instead of an empty body.

He wrote the report and sent it to the program. A few hours later it came back ACCEPTED, with a bounty. A bounty is the payment a company gives a researcher for reporting a security problem responsibly instead of exploiting it.

From the original on hack4bounty.com

This image sits at the point where the author describes the report being accepted and the bounty being awarded.

The program also asked how he had found an endpoint with a parameter name that appeared nowhere in the UI. His answer: recon. Recon, short for reconnaissance, is the information-gathering phase: reading the site, its pages and its source before attacking anything.

Submitted, resolved and bounty awarded all happened on the same day.

Root cause

The endpoint /php/filter_user_tab_content.php took the tab value from the client and served whatever section matched, including a secret section that was never meant to be reachable from the UI. The commented-out link in the page source shows the feature existed in the front end but was hidden only by being commented out, not by any server-side authorisation check. Authorisation means the server deciding, for each request, whether this particular logged-in user is allowed to do this particular thing. The empty responses on other users' user_id values suggest some per-user check existed for the normal tabs. That last point is inferred from the behaviour described; the report does not show the server code.

Impact

An authenticated user could request the secret tab and receive sensitive data in the response. The report does not describe what that data was, how many users were affected, or whether the secret tab returned data for arbitrary user_id values or only for the researcher's own. The normal tabs (orders, address) returned empty bodies for other users' IDs, so the exposure was specific to the hidden tab.

Fix

The fix that follows from the finding is to enforce authorisation on the server for every tab, including ones not exposed in the UI, and to check that the authenticated session is allowed to read the requested user_id rather than trusting the posted value. Hiding a feature by commenting it out of the HTML is not access control. Access control is the server's decision about who may do what; hiding something in the page only stops honest visitors from stumbling on it.

Variants to test

  1. Read the page source for hidden parameter values. Look for data attributes, commented-out markup, disabled options and JavaScript constants that name values the UI never sends. A positive result is a value the backend accepts and returns content for.
  2. Enumerate the selector parameter, not just the identifier. When a request has both an object ID and a section or view name, brute force the section name with a wordlist built from the source. A positive result is a 200 with a non-empty body for a section not in the UI.
  3. Compare response bodies, not status codes. Many 200 OK responses were empty. Filter on response length or content to find the ones that matter.
  4. Test each tab separately against other users' IDs. A check may exist for one tab and not another. A positive result is another user's data returned for a tab that was previously empty.
  5. Check development and staging leftovers. Names like secret, admin, internal, test and debug in commented code are worth trying against the same endpoint.

Glossary

  • API: a way for one piece of software to ask another for data or an action, here the background call the profile page makes to the server.
  • AJAX: a request made by JavaScript running in a page, without reloading the whole page.
  • Access control: the server's decision about whether a given user may perform a given action.
  • Authorisation: the act of checking that a logged-in user is allowed to do what they are asking for.
  • Bounty: a payment a company gives a researcher for a responsibly reported security problem.
  • Brute force: trying many values in the same request, one after another, and comparing the answers.
  • Burp Suite: a tool that sits between browser and server, records requests and responses, and can resend a request many times with variations.
  • Cookie: a small piece of text a site stores in your browser and the browser sends back with every request, used here to identify the logged-in session.
  • Endpoint: the specific address and script on a server that a request is sent to.
  • GET: an HTTP method meaning "I want to read something".
  • HTML: the language web pages are written in; the source your browser receives and renders.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • HTTPS: HTTP with encryption, so others on the network cannot read the traffic.
  • IDOR (Insecure Direct Object Reference): a request names the record it wants directly, and the server hands it over without checking that it belongs to the requester.
  • Information disclosure: private data being handed to someone who should not have it.
  • Intruder: the Burp Suite feature that resends one request many times with one part swapped for each value in a list.
  • JSON: a plain text format for structured data that JavaScript can read easily.
  • Parameter: a named value sent with a request, such as user_id or tab.
  • POST: an HTTP method meaning "I am sending data to the server".
  • Proxy history: Burp's log of every request and response that passed through it.
  • Recon (reconnaissance): the information-gathering phase before attacking, reading pages and source to learn how a site works.
  • Request: the message a browser sends to a server asking for something.
  • Response: the message a server sends back.
  • Session: the state of being logged in, kept alive by the cookie.
  • Status code: a three-digit number in the response saying how it went; 200 OK means the request was processed without error.
  • Tab: a section of the profile page, such as orders, address or credit cards.
  • User-Agent: a header describing the browser and operating system that sent the request.
  • Wordlist: a list of candidate values to try, one per request.

More by Sanjay Verdu

View all

2 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.