Skip to content
Subdomain takeover Write-up Intermediate

How Inspect Element lead to Stored XSS on Bukalapak’s website

A subfolder on a Bukalapak subdomain pointed to an unclaimed Amazon S3 bucket, which the researcher claimed. By taking over the bucket, the researcher could host malicious content on the trusted subdomain, enabling stored XSS, clickjacking, and phishing.

wis4nggeni Follow

Published on medium.com

{{media:0}}

wis4nggeni, 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. 5 min read.

Context

Bukalapak is one of the largest online marketplaces in Indonesia, and at the time of this research it ran a public bug bounty programme with a Wall of Fame for researchers. The researcher, wis4nggeni, was browsing the site as a normal shopper when he noticed the programme and decided to look for bugs.

His attention went to a newly released feature hosted on a specific subdomain, REDACTED.bukalapak.com. The reasoning was simple: a new feature is more likely to have missed something. The subdomain itself was live and served a working feature of the Bukalapak website; the problem was not the subdomain but a path underneath it.

Setup

No special accounts, roles or tooling are described. The work started from an ordinary browsing session, the browser's developer tools (Inspect Element and the console), and a new tab to open a URL found in the console. The only external resource mentioned is Patrik Hudak's blog on subdomain takeover, used for background reading on guessing the S3 region.

Finding it

Before the discovery, the researcher spent time on the same subdomain without success. The only issues he found were minor or very low severity, such as clickjacking with no sensitive action and a rate-limiting issue.

The turning point came while he was inspecting an element on one of the pages to check whether an XSS payload had fired. It had not, but the browser console showed something else: the page was trying to fetch an image from another subdomain, the request failed, and a 404 response was printed in the console. The URL looked like this:

Image for post
Broken link From the original on medium.com

The screenshot shows the broken image request in the browser console.

Opening that link in a new tab returned an Amazon S3 NoSuchBucket error page, which also printed the bucket name. The error page showed that no bucket with that name existed, and it printed the bucket name.

The S3 error page, with the bucket name visible.

What made this case interesting is that the subdomain-takeover scanners the researcher had used previously could not detect it. To understand why, he stripped the URL back to find the address that actually pointed at the unclaimed bucket:

At that level, REDACTED.bukalapak.com was up and healthy and hosted another Bukalapak feature that worked normally. Only the /img/ path was mapped to the dangling S3 bucket. That is why he called it a subfolder takeover rather than a subdomain takeover: the methodology is the same, but the claimable unit is a path under a live host.

Exploitation

Step 1: Create the bucket with the leaked name

He created an Amazon S3 bucket using the name printed on the NoSuchBucket error page. For the region, Patrik Hudak's writing explains how to guess it; since Bukalapak is an Indonesian product, the researcher simply chose the nearest region, Asia Pacific, and that turned out to be correct. With the bucket created, the subfolder pointed at storage he controlled.

Step 2: Assess what the takeover enables

With control of the subfolder, he identified three consequences:

  1. Stored XSS. The site's cookies were set for a wildcard subdomain, so the same cookies were used everywhere. Content served from the taken-over subfolder runs on the same subdomain, so script there can reach those cookies and stealing session cookies is possible.
  2. Clickjacking. Because the subfolder sits on one of their subdomains, pages whose X-Frame-Options is set to the same origin subdomain can be framed. Such pages most of the time contain sensitive actions.
  3. Phishing. He could host phishing content on the trusted subdomain, which combined with the XSS and clickjacking would be a powerful attack vector.
Image for post
The Popup everyone loves. From the original on medium.com

The popup image from the report.

Step 3: Stop and report

He did not exploit further, because he was concerned that doing so would go against the programme's rules. He reported the issue and left the severity decision to the team.

Root cause

The mistake is a dangling reference: the /img/ path on a live subdomain pointed at an unclaimed S3 bucket, while the rest of the subdomain served a working feature. Because the hostname itself resolved and responded normally, hostname-based takeover scanners did not flag it. The bucket name was disclosed by S3's own NoSuchBucket error page, which made claiming it trivial.

The impact is amplified by two factors: cookies set to a wildcard subdomain, so the same cookies are used everywhere, and pages whose X-Frame-Options is set to the same origin subdomain, which can then be framed. The report does not describe any change to these settings.

Impact

Under the conditions above, an attacker who claims the bucket can serve arbitrary content from a trusted Bukalapak subfolder. That enables stored XSS against users of the wildcard-scoped cookies, clickjacking of same-origin-subdomain pages that perform sensitive actions, and phishing from a trusted domain. The researcher notes that combining these would be a very powerful attack vector. He did not carry the exploitation beyond confirming control of the bucket.

Fix

The report does not state what remediation was applied. The general fix for this class of issue is to remove or repoint the dangling reference so the path no longer resolves to an unclaimed bucket, and to keep an inventory of bucket-backed paths so that deleted buckets do not leave claimable names behind.

Timeline

Date Event
August 13 2019 Report sent.
August 13 2019 (less than half an hour later) Cyber incident responder replied, asking for a specific file to be uploaded to confirm the findings.
August 14 2019 Report validated and categorised as a misconfiguration with High severity. The team asked for his details for the Wall of Fame and bounty payment.
August 26 2019 Name added to the Wall of Fame.
September 24 2019 Bounty paid with a thank you note.
December 23 2019 Disclosure request approved and write-up published.

Variants to test

  1. Watch the browser console on every page. Look for failed requests to other subdomains, especially image, static and asset paths. A positive result is a 404 or an S3 NoSuchBucket page when the URL is opened directly.
  2. Strip URLs back to the path level. If the full URL fails but the parent path serves a working feature, you may have a subfolder takeover rather than a subdomain takeover. A positive result is a live host whose specific path resolves to an unclaimed cloud bucket.
  3. Open failing asset URLs in a new tab. A cloud provider error page that prints the bucket or container name confirms the resource is unclaimed and gives you the name to claim.
  4. Check cookie scope and framing headers on the parent subdomain. Wildcard-scoped cookies and X-Frame-Options set to the same origin subdomain raise the impact of any content you can serve there.
  5. Do not rely only on takeover scanners. This case was missed by the tools the researcher had used, so manual inspection of console errors and asset paths is worth doing alongside automated checks.

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

What happened, in plain words

Bukalapak is one of the biggest online marketplaces in Indonesia, a website where people buy and sell things, a bit like a large online shopping centre. At the time of this research it ran a public bug bounty programme: a scheme where a company invites independent researchers to look for security mistakes in its systems and pays for the useful ones. The programme also had a Wall of Fame, a page listing the names of researchers who reported valid issues. The researcher, wis4nggeni, was browsing the site as an ordinary shopper when he noticed the programme and decided to try his luck.

He focused on a newly released feature hosted on a specific subdomain, REDACTED.bukalapak.com. A subdomain is a part of a website address that sits in front of the main domain, so shop.example.com is a subdomain of example.com. Companies often put different features on different subdomains. His reasoning was simple: a brand new feature is more likely to have missed something, because it has not been tested and reviewed as much as the older parts of the site.

The subdomain itself was live and served a working feature of the Bukalapak website. The problem was not the subdomain as a whole, but one path underneath it. A path is the part of a web address after the domain name, the bit that tells the server which page or file you want, like the folder structure on a computer.

In the end, he found that a folder on a live Bukalapak subdomain was pointing at a storage space in the cloud that nobody had claimed. Because the name of that storage space was printed on an error page, he could create it himself and put his own content there, served from a trusted Bukalapak address. That is the whole story: a broken image link, a curious look in the browser console, and a takeover of a subfolder.

Setup

No special accounts, roles or tooling are described. The work started from an ordinary browsing session, the browser's developer tools (Inspect Element and the console), and a new tab to open a URL found in the console.

Inspect Element is a built-in feature of every modern browser. Right-clicking on a page and choosing it opens a panel that shows the page's underlying code, the HTML that describes the structure of what you see. The console is another tab of the same panel: it is a running log where the browser reports messages, including errors, such as a request for a file that could not be loaded.

The only external resource mentioned is Patrik Hudak's blog on subdomain takeover, used for background reading on guessing the S3 region. A blog is just a website with articles; reading one is no different from reading any other page.

Finding it

Before the discovery, the researcher spent time on the same subdomain without success. The only issues he found were minor or very low severity, such as clickjacking with no sensitive action and a rate-limiting issue.

Clickjacking is a trick where an attacker loads a real page inside an invisible frame on top of a page they control, so that when you think you are clicking a harmless button you are actually clicking a button on the hidden page. It only matters if the hidden page does something sensitive, like transferring money or changing a password. Rate limiting is a control that stops someone from sending too many requests too quickly, for example to guess passwords; a weakness there is usually low impact on its own.

The turning point came while he was inspecting an element on one of the pages to check whether an XSS payload had fired. XSS, short for cross-site scripting, is a class of bug where an attacker manages to get their own code (usually JavaScript, the language browsers run) to execute inside someone else's page. A payload is simply the piece of input an attacker sends to try to trigger the bug. It had not fired, but the browser console showed something else: the page was trying to fetch an image from another subdomain, the request failed, and a 404 response was printed in the console. A 404 is the standard answer a web server gives when the thing you asked for does not exist.

The URL looked like this:

Line by line, in plain words:

  • https:// is the protocol, the set of rules the browser uses to talk to the server. The s stands for secure: the traffic is encrypted, so nobody in between can read or change it.
  • REDACTED.bukalapak.com is the host, the name of the server being contacted. The first part is a subdomain of bukalapak.com.
  • /img/ is the path, a folder on that server.
  • some-random-text.jpg is the file name being requested, an image in this case.
Image for post
Broken link From the original on medium.com

The screenshot shows the broken image request in the browser console.

Opening that link in a new tab returned an Amazon S3 NoSuchBucket error page, which also printed the bucket name. Amazon S3 is a cloud storage service: you rent space on Amazon's servers and store files there, and those files can be served over the web. The space you rent is called a bucket, and every bucket has a name that must be unique across the whole service, a bit like a username that nobody else in the world can have. The NoSuchBucket error means no bucket with that name exists, and the page printed the name. It is like finding a mailbox with a name plate on it and no lock: whoever puts their name on the plate gets the mail.

The S3 error page, with the bucket name visible.

What made this case interesting is that the subdomain-takeover scanners the researcher had used previously could not detect it. A scanner is an automated tool that checks many addresses quickly against a list of known patterns. Subdomain takeover is the general name for this kind of bug: a company points one of its names at an external service, later stops using that service, but forgets to remove the pointer, so a stranger can claim the service and answer under the company's name. To understand why the scanners missed it, he stripped the URL back to find the address that actually pointed at the unclaimed bucket:

Line by line, in plain words:

  • https:// is again the encrypted protocol.
  • REDACTED.bukalapak.com is the same host as before.
  • /img/ is the folder, with no file name after it. This is the address of the folder itself rather than of one image inside it.

At that level, REDACTED.bukalapak.com was up and healthy and hosted another Bukalapak feature that worked normally. Only the /img/ path was mapped to the dangling S3 bucket. Dangling here means the pointer exists but the thing it points at does not, like a signpost to a shop that has closed down. That is why he called it a subfolder takeover rather than a subdomain takeover: the methodology is the same, but the claimable unit is a path under a live host. The scanners were looking at whole hostnames, and this hostname answered perfectly well, so they saw nothing wrong.

Exploitation

Step 1: Create the bucket with the leaked name

He created an Amazon S3 bucket using the name printed on the NoSuchBucket error page. For the region, Patrik Hudak's writing explains how to guess it; since Bukalapak is an Indonesian product, the researcher simply chose the nearest region, Asia Pacific, and that turned out to be correct. A region is the physical location of the data centre where the storage lives, so picking the right one matters. With the bucket created, the subfolder pointed at storage he controlled.

Step 2: Assess what the takeover enables

With control of the subfolder, he identified three consequences:

  1. Stored XSS. The site's cookies were set for a wildcard subdomain, so the same cookies were used everywhere. A cookie is a small piece of data a website asks your browser to keep and send back with every request to that site; it is how a site remembers that you are logged in. A wildcard subdomain setting means the cookie is valid for the main domain and all of its subdomains, not just one. Content served from the taken-over subfolder runs on the same subdomain, so script there can reach those cookies and stealing session cookies is possible. A session cookie is the one that proves who you are; if someone else gets it, they can act as you without knowing your password.
  2. Clickjacking. Because the subfolder sits on one of their subdomains, pages whose X-Frame-Options is set to the same origin subdomain can be framed. X-Frame-Options is a response header, a small piece of information a server attaches to its answer, that tells the browser whether the page may be shown inside a frame on another site. Setting it to the same origin subdomain means pages from that subdomain are allowed to frame them. Such pages most of the time contain sensitive actions.
  3. Phishing. He could host phishing content on the trusted subdomain, which combined with the XSS and clickjacking would be a powerful attack vector. Phishing is a fake page that looks like the real one and asks you to type your password or card details. An attack vector is simply the route an attacker uses to reach a victim.
Image for post
The Popup everyone loves. From the original on medium.com

The popup image from the report.

Step 3: Stop and report

He did not exploit further, because he was concerned that doing so would go against the programme's rules. He reported the issue and left the severity decision to the team. This is standard practice in bug bounties: prove that the problem is real, then stop and let the company fix it.

Root cause

The mistake is a dangling reference: the /img/ path on a live subdomain pointed at an unclaimed S3 bucket, while the rest of the subdomain served a working feature. Because the hostname itself resolved and responded normally, hostname-based takeover scanners did not flag it. The bucket name was disclosed by S3's own NoSuchBucket error page, which made claiming it trivial.

The impact is amplified by two factors: cookies set to a wildcard subdomain, so the same cookies are used everywhere, and pages whose X-Frame-Options is set to the same origin subdomain, which can then be framed. The report does not describe any change to these settings.

Impact

Under the conditions above, an attacker who claims the bucket can serve arbitrary content from a trusted Bukalapak subfolder. That enables stored XSS against users of the wildcard-scoped cookies, clickjacking of same-origin-subdomain pages that perform sensitive actions, and phishing from a trusted domain. The researcher notes that combining these would be a very powerful attack vector. He did not carry the exploitation beyond confirming control of the bucket.

Fix

The report does not state what remediation was applied. The general fix for this class of issue is to remove or repoint the dangling reference so the path no longer resolves to an unclaimed bucket, and to keep an inventory of bucket-backed paths so that deleted buckets do not leave claimable names behind.

Timeline

Date Event
August 13 2019 Report sent.
August 13 2019 (less than half an hour later) Cyber incident responder replied, asking for a specific file to be uploaded to confirm the findings.
August 14 2019 Report validated and categorised as a misconfiguration with High severity. The team asked for his details for the Wall of Fame and bounty payment.
August 26 2019 Name added to the Wall of Fame.
September 24 2019 Bounty paid with a thank you note.
December 23 2019 Disclosure request approved and write-up published.

Variants to test

  1. Watch the browser console on every page. Look for failed requests to other subdomains, especially image, static and asset paths. A positive result is a 404 or an S3 NoSuchBucket page when the URL is opened directly.
  2. Strip URLs back to the path level. If the full URL fails but the parent path serves a working feature, you may have a subfolder takeover rather than a subdomain takeover. A positive result is a live host whose specific path resolves to an unclaimed cloud bucket.
  3. Open failing asset URLs in a new tab. A cloud provider error page that prints the bucket or container name confirms the resource is unclaimed and gives you the name to claim.
  4. Check cookie scope and framing headers on the parent subdomain. Wildcard-scoped cookies and X-Frame-Options set to the same origin subdomain raise the impact of any content you can serve there.
  5. Do not rely only on takeover scanners. This case was missed by the tools the researcher had used, so manual inspection of console errors and asset paths is worth doing alongside automated checks.

Glossary

  • Bug bounty programme: a scheme where a company invites independent researchers to look for security mistakes and pays for the useful ones.
  • Wall of Fame: a public page listing the names of researchers who reported valid issues.
  • Subdomain: a part of a website address in front of the main domain, such as shop in shop.example.com.
  • Path: the part of a web address after the domain name that identifies a page or file, like a folder on a computer.
  • Inspect Element: a browser tool that shows the underlying code of a page.
  • Console: a panel in the browser's developer tools that logs messages and errors, including failed requests.
  • Clickjacking: a trick where a real page is hidden inside a frame so that clicks land on something the victim did not intend.
  • Rate limiting: a control that stops someone from sending too many requests too quickly.
  • XSS (cross-site scripting): a bug where an attacker gets their own code to run inside someone else's page.
  • Payload: the piece of input an attacker sends to try to trigger a bug.
  • 404: the standard answer a web server gives when the requested thing does not exist.
  • Protocol: the set of rules used to communicate, such as HTTPS.
  • HTTPS: the encrypted version of the web protocol, so traffic cannot be read or changed in transit.
  • Host: the name of the server being contacted, such as REDACTED.bukalapak.com.
  • Amazon S3: a cloud storage service where you rent space and store files that can be served over the web.
  • Bucket: a named storage space in S3; names must be unique across the whole service.
  • NoSuchBucket: the S3 error meaning no bucket with that name exists, which also prints the name.
  • Scanner: an automated tool that checks many addresses quickly against known patterns.
  • Subdomain takeover: a bug where a company's name points at an external service that is no longer used, letting a stranger claim it.
  • Subfolder takeover: the same idea, but the claimable unit is a path under a live host rather than a whole hostname.
  • Dangling reference: a pointer that exists but points at something that no longer exists.
  • Region: the physical location of the data centre where cloud storage lives.
  • Cookie: a small piece of data a site asks the browser to keep and send back, used to remember who you are.
  • Wildcard subdomain: a cookie or setting that applies to the main domain and all of its subdomains.
  • Session cookie: the cookie that proves who you are; stealing it lets someone act as you.
  • X-Frame-Options: a response header that tells the browser whether a page may be shown inside a frame on another site.
  • Response header: a small piece of information a server attaches to its answer.
  • Phishing: a fake page that looks real and asks for passwords or card details.
  • Attack vector: the route an attacker uses to reach a victim.
  • Severity: how serious an issue is judged to be.
  • Misconfiguration: a security mistake caused by a setting rather than by a flaw in the code itself.
  • Remediation: the fix applied to close an issue.

More by wis4nggeni

View all

3 more disclosed reports, best first.

More from Bukalapak

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Subdomain takeover

The lesson behind this report.

A company's DNS still points at a cloud service it no longer uses, so anyone can claim it and serve content on the company's domain.