The forgotten content : information disclosure and reflected XSS on Tokopedia
An old API documentation page was still accessible on port 80, exposing sensitive API details including client ID and secrets, and a reflected XSS vulnerability existed in the 'url' parameter of the import functionality. An attacker could craft a link to execute script in a victim's browser, potentially stealing cookies.
Published on medium.com
{{media:0}}
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Tokopedia runs a bug bounty programme, and this write-up covers two issues found on a single forgotten host: an information disclosure through an exposed API documentation page, and a reflected XSS in that same page's import functionality.
The host in question is accounts-REDACTED.tokopedia.com. The researcher had come across it while working on a previous subdomain takeover write-up and returned to it because the name looked interesting. The front page of the subdomain returned only a 410 Gone HTTP status code, which indicates that the resource was intentionally removed and should have been purged from the server.
What the /docs/ path normally does is render API documentation with Swagger UI, an open source project that visually renders documentation for an API defined with the OpenAPI (Swagger) Specification. In this case the documentation described an API intended for third party partners of Tokopedia.
Setup
No accounts, roles or credentials were needed. The documentation was open: anyone could modify or update it without logging in or registering. The tools used for discovery were directory brute-force tools, named in the report as dirbuster, dirsearch and similar. The researcher tested in a browser, and later compared behaviour between Chrome and Firefox.
The precondition that made the finding possible was the port split: the same path behaved differently on port 80 and port 443.
Finding it
Because the subdomain name looked interesting, the researcher decided to dig further. The front page returned 410 Gone and nothing else. Directory brute-forcing with dirbuster, dirsearch and similar tools returned 410 Gone for every path, with one exception: accounts-REDACTED.tokopedia.com/docs/ returned a different response, a 200 OK.
Opening that path in a browser returned 410 Gone again.

The researcher was confident this was not a false positive. After double checking, the difference turned out to be the port: port 80 (http) returned 200 OK, while port 443 (https) returned 410 Gone. The browser automatically redirects to https when the protocol is not specified directly, which is why the browser saw the 410.
Opening the path over http revealed that /docs/ on port 80 was API documentation built with Swagger UI.

The documentation contained sensitive API definitions, including an API for retrieving user data and other sensitive PII such as National Identity Number. It was meant for third party partners of Tokopedia, and it even contained the client ID and client secrets for Authorization.

The API itself no longer worked. On previous Tokopedia hunts the researcher had seen the company using GraphQL, which is different from what this documentation described. The changelog showed that the last update by their staff was from around June 2019, so the researcher was about two months late and the web architecture had changed in the meantime. That explains the 410 Gone status code: the resource was supposed to be deleted, but was still there somehow.

Exploitation
Step 1: Look for a known Swagger UI vulnerability
The researcher started hunting for a CVE in that particular version of Swagger UI. One XSS CVE was found, but when tried it did not work.

That was puzzling, because the version was supposed to be vulnerable. After more digging the researcher concluded that the Swagger UI had probably been customised: the partially exposed source code even carried credit to their staff's names. So this Swagger UI was likely different from the official version.
Step 2: Notice that the documentation is writable
The researcher took a break of about one to two weeks, then continued. The key observation was that the documentation was open, meaning anyone could modify or update it without logging in or registering. The researcher accidentally deleted the whole documentation once, and recovered it by downloading the past data from the changelog and importing it again.

Step 3: Find the import URL and test the url parameter
From the import functionality the researcher found this URL:
http://accounts-REDACTED.tokopedia.com/docs/index.php?url=file.yaml
The researcher tried to find LFI and SSRF through it, and nothing worked. However, the file name was reflected on the HTML page, so the next attempt was an XSS payload.
Step 4: Get the payload reflected and executed
At first no pop up appeared, which looked like another failure. Inspecting the element to check the reflected result showed that the XSS actually fired but was blocked by Chrome's XSS auditor. It worked perfectly on another browser such as Firefox.

The final payload:
The url parameter carries a bracketed, quoted string containing a script tag that alerts the document cookie. The value is reflected into the HTML page; Chrome's XSS auditor blocked it, but it ran in Firefox.
The researcher also tried the payload against the latest version of Swagger UI and it did not work, and no CVE documenting the vulnerability on older versions could be found. The likely explanation is that the Tokopedia version was already customised, though the researcher also left open the possibility that no CVE had been assigned yet.
Root cause
Two separate mistakes combine here.
First, a resource that should have been deleted was still served. The host answered 410 Gone on https and on the front page, but the /docs/ path on port 80 still returned 200 OK. The removal was incomplete: the intent to purge was visible in the status codes, but the plain HTTP listener kept serving the old Swagger UI and its partner API documentation, including client ID and client secrets.
Second, the import functionality reflected the url value into the HTML page, and the script tag ran in Firefox. The existing defence that stopped it in one browser was Chrome's XSS auditor, a browser-side filter, not a server-side control; the same payload ran in Firefox. The report does not describe the server-side code, so the exact encoding failure is not shown.
Impact
The exposed documentation disclosed sensitive API definitions for retrieving user data and other PII such as National Identity Number, plus the client ID and client secrets used for Authorization. The API itself was no longer working at the time of testing, so the disclosure was of documentation and credentials rather than live data. The reflected XSS ran in the context of the documentation page; the researcher's payload called alert(document.cookie), and the report does not describe what that cookie carried.
Tokopedia's security team verified the report as valid with Medium Severity, responding about 20 minutes after it was sent.
Fix
Tokopedia fixed the bug and asked the researcher to re-test it. What the finding calls for is completing the purge so the /docs/ path is gone on every port and protocol, not only on https, and encoding the reflected url value on output so that markup in it cannot execute.
Variants to test
- Port and protocol splits on retired hosts. Brute-force a host that answers 410 on https, then repeat the same paths over plain http. A positive result is a path that returns 200 on port 80 while returning 410 on 443.
- Forgotten documentation endpoints. Look for
/docs/,/swagger/,/api-docs/and similar paths on partner-facing subdomains. A positive result is a rendered Swagger UI describing partner APIs, especially one containing client IDs or secrets. - Writable documentation. Check whether the documentation can be edited or imported without authentication. A positive result is a successful modification or import with no login.
- Reflected parameters in import or fetch features. In import functionality that takes a URL or file name, test whether the value is reflected into the page. A positive result is the value appearing unencoded in the HTML response.
- Browser-dependent XSS. When a payload does not fire in Chrome, inspect the reflected output and retry in another browser such as Firefox. A positive result is execution in one browser while the other blocks it, which points to a client-side filter rather than server-side encoding.
Timeline
| Date | Event |
|---|---|
| August 29 2019 | Report sent |
| August 29 2019 | Security team verified the report, valid with Medium Severity |
| September 17 2019 | Bug fixed; researcher asked to re-test; bank details requested for the reward |
| November 20 2019 | Reward paid |
What happened, in plain words
A security researcher found an old, forgotten corner of Tokopedia's website that was supposed to have been switched off but was still running. That forgotten page was an instruction manual for one of Tokopedia's internal systems, and it was sitting out in the open where anyone could read it. The manual described how to look up user information, and it even contained the client ID and client secrets used for Authorization by a partner company.
On top of that, the same page had a small flaw that let the researcher make it run a piece of JavaScript code of their choosing. This kind of flaw is called reflected XSS. The researcher reported both problems, Tokopedia's security team confirmed them within about 20 minutes, and the issues were fixed and a reward paid.
This article walks through the whole story from the beginning, assuming you have never done any security work before. You only need to know how to use a browser and a computer.
Some background ideas first
Before the steps, a few words that come up constantly.
- A subdomain is a smaller address that belongs to a bigger website. If
tokopedia.comis the main building, thenaccounts.tokopedia.comis a named office inside it. Companies often have many of these for different services. - An HTTP status code is a short number a web server sends back with every page to say how things went.
200 OKmeans "here is the page you asked for".410 Gonemeans "this page used to exist but has been deliberately removed and is not coming back". You can think of 410 as a shop that has closed down for good, with the sign still on the door. - A port is like a numbered door on a computer. A single server can listen on many doors at once. Two doors matter here: port 80 is the standard door for plain, unencrypted web traffic (addresses starting with
http://), and port 443 is the standard door for encrypted web traffic (addresses starting withhttps://). The same server can behave differently depending on which door you knock on. - An API (Application Programming Interface) is a way for one computer program to talk to another. Think of it as a service counter: you hand over a request in a fixed format, and you get data back. A website's API is what lets a mobile app or a partner company fetch information from the company's systems.
- API documentation is the manual that describes that counter: which requests you can make, what information you have to send, and what you get back. If the manual falls into the wrong hands, an attacker learns exactly how the system is built.
- Swagger UI is a free, open source tool that takes an API manual written in a standard format (the OpenAPI, formerly Swagger, Specification) and displays it as a friendly, clickable web page. It is very common and very useful, which is exactly why finding one exposed publicly is interesting.
- PII stands for Personally Identifiable Information: data that can identify a real person, such as a national identity number.
- A client ID and client secret are a username-and-password pair used by computer programs rather than people. A partner company's software uses them to prove to Tokopedia's system that it is allowed in. If a secret leaks, someone else can pretend to be that partner.
- XSS (Cross-Site Scripting) is a flaw where a website takes something a user typed or supplied and puts it into the page without cleaning it up first. "Reflected" XSS means the bad input bounces straight back into the page you are looking at, rather than being stored on the server.
- A cookie is a small piece of data a website asks your browser to keep and send back with every request. Websites often use cookies to remember that you are logged in. That is why reading
document.cookie(the browser's way of listing the cookies for the current page) is a classic demonstration of XSS: if an attacker can run code on the page, they can read those cookies. - Directory brute-forcing means trying a long list of common folder and file names against a website automatically, to see which ones exist. Tools that do this include dirbuster and dirsearch. It is like trying every key on a big keyring to see which one opens a door.
- LFI (Local File Inclusion) is a flaw where a website lets you make it read a file from its own disk by manipulating an input. SSRF (Server-Side Request Forgery) is a flaw where you make the server itself send a request somewhere, often to internal systems you could not reach directly. Both are things to test whenever a page accepts a file name or a URL.
- A CVE is a public catalogue entry for a known vulnerability in a piece of software, with an ID number. If a tool you find is running an old version, checking CVEs tells you which known bugs might apply.
- Chrome's XSS auditor was a built-in filter in Google Chrome that tried to detect and block reflected XSS. It was a browser-side safety net, not a fix on the website itself, so a payload blocked in Chrome could still run in another browser such as Firefox.
The starting point
Tokopedia runs a bug bounty programme, which means it pays people who find security problems and report them responsibly. This write-up covers two issues found on one forgotten host: an information disclosure (sensitive information left readable) through an exposed API documentation page, and a reflected XSS in that same page's import feature.
The host is accounts-REDACTED.tokopedia.com. The researcher had come across it while working on a previous write-up about subdomain takeover and came back to it because the name looked interesting. The front page of the subdomain returned only a 410 Gone status code. That tells you the resource was intentionally removed and should have been purged from the server.
What the /docs/ path normally does is render API documentation with Swagger UI. In this case the documentation described an API intended for third party partners of Tokopedia.
What was needed to start
No accounts, roles or credentials were needed. The documentation was open: anyone could modify or update it without logging in or registering. The tools used for discovery were directory brute-force tools, named in the report as dirbuster, dirsearch and similar. The researcher tested in a browser, and later compared behaviour between Chrome and Firefox.
The precondition that made the finding possible was the port split: the same path behaved differently on port 80 and port 443.
Finding it
Because the subdomain name looked interesting, the researcher decided to dig further. The front page returned 410 Gone and nothing else. Directory brute-forcing with dirbuster, dirsearch and similar tools returned 410 Gone for every path, with one exception: accounts-REDACTED.tokopedia.com/docs/ returned a different response, a 200 OK.
Opening that path in a browser returned 410 Gone again.

The researcher was confident this was not a false positive. After double checking, the difference turned out to be the port: port 80 (http) returned 200 OK, while port 443 (https) returned 410 Gone. The browser automatically redirects to https when the protocol is not specified directly, which is why the browser saw the 410.
Opening the path over http revealed that /docs/ on port 80 was API documentation built with Swagger UI.

The documentation contained sensitive API definitions, including an API for retrieving user data and other sensitive PII such as National Identity Number. It was meant for third party partners of Tokopedia, and it even contained the client ID and client secrets for Authorization.

The API itself no longer worked. On previous Tokopedia hunts the researcher had seen the company using GraphQL, which is different from what this documentation described. The changelog showed that the last update by their staff was from around June 2019, so the researcher was about two months late and the web architecture had changed in the meantime. That explains the 410 Gone status code: the resource was supposed to be deleted, but was still there somehow.

Exploitation
Step 1: Look for a known Swagger UI vulnerability
The researcher started hunting for a CVE in that particular version of Swagger UI. One XSS CVE was found, but when tried it did not work.

That was puzzling, because the version was supposed to be vulnerable. After more digging the researcher concluded that the Swagger UI had probably been customised: the partially exposed source code even carried credit to their staff's names. So this Swagger UI was likely different from the official version.
Step 2: Notice that the documentation is writable
The researcher took a break of about one to two weeks, then continued. The key observation was that the documentation was open, meaning anyone could modify or update it without logging in or registering. The researcher accidentally deleted the whole documentation once, and recovered it by downloading the past data from the changelog and importing it again.

Step 3: Find the import URL and test the url parameter
From the import functionality the researcher found this URL:
http://accounts-REDACTED.tokopedia.com/docs/index.php?url=file.yaml
Line by line:
http://means the request goes over plain, unencrypted web traffic, on port 80. This matters, because the same path over https returned 410.accounts-REDACTED.tokopedia.comis the host, the forgotten subdomain./docs/index.phpis the page that runs the documentation tool.index.phptells you the server is running PHP, a common programming language for websites.?url=file.yamlis the part after the question mark: the parameters being sent to the page. Here a single parameter namedurlis given the valuefile.yaml, which is the name of the file to be imported.
The url parameter takes the file to be imported. The researcher tried to find LFI and SSRF through it, and nothing worked. However, the file name was reflected on the HTML page, so the next attempt was an XSS payload.
Step 4: Get the payload reflected and executed
At first no pop up appeared, which looked like another failure. Inspecting the element to check the reflected result showed that the XSS actually fired but was blocked by Chrome's XSS auditor. It worked perfectly on another browser such as Firefox.

The final payload:
Line by line:
http://accounts-REDACTED.tokopedia.com/docs/index.phpis the same import page as before, over plain http.?url=starts the parameter. Everything after the equals sign is the value the page receives.<script>alert(document.cookie)</script>is the actual attack.<script>tells the browser "everything until</script>is code, run it".alert(document.cookie)asks the browser to show a pop-up box containing the cookies for the current page.document.cookieis the browser's way of reading those cookies.
Because the value is reflected into the HTML page, the script ran in the context of the documentation page in Firefox, while Chrome's XSS auditor blocked it.
The researcher also tried the payload against the latest version of Swagger UI and it did not work, and no CVE documenting the vulnerability on older versions could be found. The likely explanation is that the Tokopedia version was already customised, though the researcher also left open the possibility that no CVE had been assigned yet.
Why it worked
Two separate mistakes combine here.
First, a resource that should have been deleted was still served. The host answered 410 Gone on https and on the front page, but the /docs/ path on port 80 still returned 200 OK. The removal was incomplete: the intent to purge was visible in the status codes, but the plain HTTP listener kept serving the old Swagger UI and its partner API documentation, including client ID and client secrets.
Second, the import functionality reflected the url value into the HTML page, and the script tag ran in Firefox. Output encoding means converting characters that have special meaning in HTML (like < and >) into harmless versions before putting them on the page, so they display as text instead of being treated as code. The existing defence that stopped it in one browser was Chrome's XSS auditor, a browser-side filter, not a server-side control; the same payload ran in Firefox. The report does not describe the server-side code, so the exact encoding failure is not shown.
What the impact was
The exposed documentation disclosed sensitive API definitions for retrieving user data and other PII such as National Identity Number, plus the client ID and client secrets used for Authorization. The API itself was no longer working at the time of testing, so the disclosure was of documentation and credentials rather than live data. The reflected XSS ran in the context of the documentation page; the researcher's payload called alert(document.cookie), and the report does not describe what that cookie carried.
Tokopedia's security team verified the report as valid with Medium Severity, responding about 20 minutes after it was sent.
How it was fixed
Tokopedia fixed the bug and asked the researcher to re-test it. What the finding calls for is completing the purge so the /docs/ path is gone on every port and protocol, not only on https, and encoding the reflected url value on output so that markup in it cannot execute.
Things worth trying elsewhere
- Port and protocol splits on retired hosts. Brute-force a host that answers 410 on https, then repeat the same paths over plain http. A positive result is a path that returns 200 on port 80 while returning 410 on 443.
- Forgotten documentation endpoints. Look for
/docs/,/swagger/,/api-docs/and similar paths on partner-facing subdomains. A positive result is a rendered Swagger UI describing partner APIs, especially one containing client IDs or secrets. - Writable documentation. Check whether the documentation can be edited or imported without authentication. A positive result is a successful modification or import with no login.
- Reflected parameters in import or fetch features. In import functionality that takes a URL or file name, test whether the value is reflected into the page. A positive result is the value appearing unencoded in the HTML response.
- Browser-dependent XSS. When a payload does not fire in Chrome, inspect the reflected output and retry in another browser such as Firefox. A positive result is execution in one browser while the other blocks it, which points to a client-side filter rather than server-side encoding.
Timeline
| Date | Event |
|---|---|
| August 29 2019 | Report sent |
| August 29 2019 | Security team verified the report, valid with Medium Severity |
| September 17 2019 | Bug fixed; researcher asked to re-test; bank details requested for the reward |
| November 20 2019 | Reward paid |
Glossary
- API: a fixed way for one program to request data or actions from another, like a service counter with set rules.
- API documentation: the manual describing an API's requests, inputs and outputs.
- Bug bounty programme: a scheme where a company pays people who find and responsibly report security problems.
- Client ID and client secret: a username-and-password pair used by software (rather than a person) to prove its identity to another system.
- Cookie: a small piece of data a website stores in your browser and gets back on later requests, often used to remember logins.
- CVE: a public catalogue entry with an ID number for a known vulnerability in a piece of software.
- Directory brute-forcing: automatically trying a long list of common folder and file names against a site to find ones that exist.
- GraphQL: a way of building APIs where the client asks for exactly the data it wants, different from the style described in this documentation.
- HTTP status code: a number a server returns with each response, such as 200 OK or 410 Gone.
- Information disclosure: a flaw where information that should be private is left readable by others.
- LFI (Local File Inclusion): a flaw where manipulated input makes a server read a file from its own disk.
- OpenAPI (Swagger) Specification: a standard format for writing API documentation that tools can render.
- Output encoding: converting characters with special meaning in HTML into harmless versions so they display as text rather than being run as code.
- PII (Personally Identifiable Information): data that can identify a real person, such as a national identity number.
- Port: a numbered channel on a computer; port 80 is the default for plain http and port 443 for encrypted https.
- Reflected XSS: a flaw where input supplied by a user bounces straight back into the page and is run as code by the browser.
- SSRF (Server-Side Request Forgery): a flaw where manipulated input makes the server itself send a request, often to internal systems.
- Subdomain: a named smaller address inside a larger website's domain, such as
accounts.tokopedia.com. - Swagger UI: an open source tool that displays OpenAPI documentation as a clickable web page.
- Chrome's XSS auditor: a browser-side filter in Google Chrome that tried to detect and block reflected XSS; it was not a server-side fix.