Skip to content
Info disclosure Write-up Intermediate

Exploiting S3 bucket with path folder to Access PII info of A BANK

An S3 bucket had proper access control at the bucket level but a folder within it lacked proper access control, allowing the researcher to list and access files containing bank information and PII. The researcher discovered the folder name through directory brute-forcing and then used AWS CLI to list its contents.

Santosh Kumar Sha Follow

Published on notifybugme.medium.com

My name is Santosh Kumar Sha, I’m a security researcher from India(Assam). In this article, I will be describing How I Exploiting S3 bucket with path folder to Access PII info of A BANK using aws cli .

Santosh Kumar Sha(@killmongar1996), on notifybugme.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. 6 min read.

Context

This is a write-up of a finding against a bank that the author refers to only as XXXX Bank, with the target domain replaced by example.com because the work was done under a private bug bounty programme. The bank had no public programme at the time; it was preparing to launch a private one, which made reporting awkward at first, but the bank responded quickly and fixed the issue.

The feature at the centre of the report is a transaction endpoint, XXXXXX.aspx, used for transaction data and also by other functions such as product tax invoice and sell tax invoice. Behind it, transaction PDFs were stored in an Amazon S3 bucket in us-east-1, and the bucket also held folders of customer data.

Setup

The tools listed in the report are:

  1. Subfinder (https://github.com/projectdiscovery/subfinder)
  2. httpx (https://github.com/projectdiscovery/httpx)
  3. gau, by Corben (https://github.com/lc/gau)
  4. waybackurls, by tomnomnom (https://github.com/tomnomnom/waybackurls)

Burp Suite was used for browsing the main application, for the OPTIONS method check, and later for directory brute-forcing with Intruder. The AWS CLI was used against the bucket. No versions are given.

The pattern the author had seen before is a bucket with a proper access control policy whose folders are not protected in the same way. The author had exploited that pattern before, which is why he tried it here.

Finding it

Reconnaissance started on the main domain, example.com. Subdomains and archived URLs were collected with subfinder, gau and waybackurls:

Bash
subfinder -d example.com silent
Bash
gau -subs example.com
Bash
waybackurls example.com

To avoid missing subdomains, subfinder output was piped into waybackurls so that URLs for every subdomain, where they exist, were also collected. The combined collection was then filtered to URLs containing a parameter, and the results were merged and de-duplicated:

Bash
gau -subs example.com | grep "=" >> vul1.txt
Bash
waybackurls example.com |grep "=" >> vul2.txt
Bash
subfinder -d example.com -silent | gau -subs | grep "=" >> vul3.txt
Bash
cat vul1.txt vul2.txt vul3.txt | sort -u >> unique_sub.txt

While testing the main domain in Burp, the author noticed an endpoint, XXXXXX.aspx, that handled transaction data and was also used by functions such as product tax invoice and sell tax invoice. That suggested one or more functions were reaching the same endpoint for tax invoice data. Fuzzing the endpoint directly produced nothing, so he went back to the archived URLs and extracted endpoint paths from unique_sub.txt with a bash pipeline:

Bash
cat unique_sub.txt | sed 's/^.*.com//' | sed 's/?.*//' >> endpoint_path.txt

The first sed strips everything up to and including .com, the second strips the query string, leaving paths such as /XXXXX/transaction. The endpoint was then appended to every path:

Bash
cat endpoint_path.txt | sed 's/$/\/XXXXXX.jsp/'

Note that this line appends XXXXXX.jsp while the endpoint discussed elsewhere is XXXXXX.aspx; the report shows both spellings. The paths were then requested through httpx, with Burp as the proxy so the traffic could be reviewed:

Bash
xargs -a endpoint_path.txt -I@ bash -c 'for url in $(cat endpoint_path.txt | sed "s/$/\/XXXXXX.aspx/"); do echo "http://$url/@";done' | httpx -silent -status-code -http-proxy http://[redacted]:8080

In the Burp history this surfaced the endpoint of interest:

Text
https://transaction.example.com/transaction/XXXXXX.aspx

It returned 403. Reusing the cookie and session ID from the main domain did not help, and the various 403 bypass techniques the author tried all failed.

Exploitation

Step 1: discover the allowed method

The author went back to the old school method and asked the endpoint which HTTP methods it accepted:

He then sent the allowed methods one by one. With POST, the endpoint downloaded the file from the S3 bucket that stored the transaction PDF, and the bucket URL appeared in the response:

Text
https://XXXXX.s3.us-east-1.amazonaws.com/11XXXXXXXXXX012.pdf

Step 2: try the bucket directly

Listing the bucket with the AWS CLI failed because the bucket itself had a proper access control policy:

Bash
aws s3 ls s3://XXXXX — region us-east-1

Step 3: look for a folder name

The author's earlier experience was with buckets that were protected at bucket level but not at folder level. The problem here was that the downloaded PDF URL contained no folder. He searched the page source and JavaScript files by hand and found a bucket URL that did include a folder:

He tried the CLI against that folder:

Bash
aws s3 ls s3://XXXXX /document — region us-east-1

This also failed.

Step 4: brute-force folder names

Rather than stop, he built a custom wordlist of terms commonly used in banking services and ran directory brute-forcing against the bucket with Burp Intruder, filtering results by response length. The brute-force returned valid folders:

Text
/kyc_details/
/banking_info/
/transaction/

One of these folders lacked a proper access control policy.

Step 5: list the unprotected folder

Bash
aws s3 ls s3://XXXXX/banking_info/ — region us-east-1

The output was a shock: it listed the bank information and PII of users.

The screenshot shows the author's reaction to the listing output.

From the original on notifybugme.medium.com

The second screenshot shows the contents returned by the folder listing, which exposed user bank information and PII.

Root cause

The bucket had a correct access control policy at bucket level, which is why aws s3 ls s3://XXXXX failed. The protection was not applied to the folders inside it, so a folder such as banking_info/ could be listed once its name was known. The folder name was found by brute-forcing with a custom wordlist of terms commonly used in banking services. The 403 on the .aspx endpoint was a separate obstacle; sending POST made the endpoint download the transaction PDF from the S3 bucket.

Impact

Anyone who found the folder name could list it, and the listing showed the bank information and PII of users. The author describes the issue as critical and says the bank fixed it immediately. The report does not enumerate which data fields were exposed, how many users were affected, or whether the objects themselves could be downloaded as well as listed.

Fix

The report says the bank fixed the issue quickly but does not describe the change. The fix that addresses the root cause is to apply access control at object and prefix level, not only at bucket level, so that every folder inherits the same restriction, and to verify it by attempting an unauthenticated listing of each prefix.

Variants to test

  1. List a bucket anonymously with aws s3 ls s3://bucket and, if that is denied, try known or guessed prefixes such as aws s3 ls s3://bucket/prefix/. A positive result is a listing of objects where the bucket root was denied.
  2. Harvest bucket and folder names from JavaScript files and page source, as was done here with the document/ URL. A positive result is a bucket URL containing a path segment that the application itself uses.
  3. Brute-force folder names with a wordlist tailored to the target's industry, filtering by response length. A positive result is a set of prefixes that return listings or objects rather than access denied.
  4. When an endpoint returns 403, send OPTIONS and then each allowed method. A positive result is a method that returns data or a download link the GET did not.
  5. Follow download links returned by the application back to their storage URL and test the storage host directly, both at bucket root and at the folder shown in the link.

The final image is the author's buy-me-a-coffee link.

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 was testing a bank's website. The bank had not yet opened a public bug bounty programme, so the researcher could not simply sign up and start testing; the bank was in the process of launching a private one. He found a page on the bank's site that handed out transaction PDF files. The page itself refused to show him anything (it returned an error), but when he asked it a slightly different way, it gave him a download link. That link pointed to a storage service run by Amazon, called S3, where the bank kept its files.

At first the storage area was locked down properly: he could not browse it. But he noticed that the bank's own web pages and scripts mentioned a folder inside that storage area. He brute-forced folder names using words a bank would use, and one of the folders found was not locked down properly. Listing it showed him the bank details and personal information of the bank's users.

This article walks through the same steps for someone who has never done security testing before. Every tool and command is explained from scratch.

The people and the target

The researcher is Santosh Kumar Sha, from Assam in India. The bank is never named: he calls it XXXX Bank, and he replaces the real domain with example.com throughout, because the work was done under a private bug bounty programme and the bank's identity is confidential.

A bug bounty programme is an arrangement where a company invites outside researchers to look for security problems in its systems and pays or thanks them for reporting what they find. A private programme means only invited people may take part, rather than anyone on the internet.

Because there was no public programme yet, reporting the problem was awkward at first. The bank, however, responded quickly, handled the report properly, and fixed the issue straight away. The researcher says the bank treated it as a critical issue, thanked him for his effort, and gave him the first private invitation to its new bug bounty programme.

The feature that mattered

The centre of the story is a web page whose name ends in .aspx. The report hides its real name and writes it as XXXXXX.aspx. This page dealt with transaction data, and the same page was also used by other parts of the site, such as product tax invoices and sell tax invoices.

An endpoint is simply a specific address on a website that does a specific job, like a particular counter in a large office. You send a request to that address and it does something for you: shows a page, saves a form, or hands back a file.

Behind this endpoint, the bank stored transaction PDFs in an Amazon S3 bucket. S3 is Amazon's online file storage service: think of it as a very large filing cabinet on the internet. A bucket is the top-level container, like a drawer in that cabinet, and folders (also called prefixes) inside it group the files, like folders inside the drawer. The bucket in this story was in the us-east-1 region, which is the name of the data centre area where Amazon keeps it.

The tools used

The report lists four tools for gathering information, plus two more used later:

  1. Subfinder (https://github.com/projectdiscovery/subfinder)
  2. httpx (https://github.com/projectdiscovery/httpx)
  3. gau, by Corben (https://github.com/lc/gau)
  4. waybackurls, by tomnomnom (https://github.com/tomnomnom/waybackurls)

Subfinder finds subdomains. A subdomain is a smaller address under a main one: if example.com is the main building, shop.example.com and mail.example.com are separate offices inside it. Each one may run different software and have different weaknesses, so finding them all matters.

gau and waybackurls collect old addresses that have been saved by internet archives. Services like the Wayback Machine keep copies of web pages from years ago, including links that no longer appear on the live site. Those forgotten links often point at pages that are still running but no longer advertised, which makes them interesting to a tester.

httpx is a tool that sends a request to a long list of addresses and reports what came back, such as the status code. A status code is the short number a web server returns with every reply: 200 means fine, 403 means forbidden, 404 means not found.

Burp Suite is a program that sits between your browser and the website and records every request and response, so you can read them, change them and resend them. Its Intruder feature sends the same request many times with different values filled in, which is how lists of names get tested quickly.

The AWS CLI is Amazon's command-line tool for talking to S3 and other Amazon services from a terminal instead of a browser. aws s3 ls means "list what is in this bucket or folder".

No versions of any tool are given in the report.

The idea behind the final step

The researcher had seen this pattern before: an S3 bucket whose top-level lock is set correctly, but whose folders inside do not inherit that lock. Imagine a building with a locked front door but several internal rooms whose doors were never fitted with locks. If you cannot get past the front door, you might still walk straight into a room if you know its name and can reach it another way. That prior experience is why he tried the same trick here.

Step 1: gathering addresses

He started on the main domain, example.com, and collected subdomains and archived URLs:

Bash
subfinder -d example.com silent

This asks Subfinder to find subdomains of example.com. The -d flag supplies the domain, and silent keeps the output to just the results, without banners or extra messages.

Bash
gau -subs example.com

This asks gau to fetch known URLs for example.com and all of its subdomains (-subs).

Bash
waybackurls example.com

This asks waybackurls to fetch archived URLs for the same domain.

He worried that some subdomains might still be missed, so he chained the tools: Subfinder's output was piped into waybackurls, so that archived URLs for every subdomain, where any exist, were collected too. A pipe, the | symbol, means "take the output of the command on the left and feed it as input to the command on the right", like passing a document from one desk to the next.

He then kept only URLs that contain a parameter, merged the results, and removed duplicates:

Bash
gau -subs example.com | grep "=" >> vul1.txt

grep "=" filters the lines and keeps only those containing an equals sign. An equals sign usually means the URL carries a parameter, which is a named value passed to a page, as in page?name=value. Parameters are where a lot of interesting behaviour lives, so he kept only those URLs. >> appends the output to a file instead of printing it on screen.

Bash
waybackurls example.com |grep "=" >> vul2.txt

The same filter, applied to waybackurls output, saved into a second file.

Bash
subfinder -d example.com -silent | gau -subs | grep "=" >> vul3.txt

Here Subfinder's subdomains are piped into gau, which fetches URLs for each of them, and the equals-sign filter is applied again. The result goes into a third file.

Bash
cat vul1.txt vul2.txt vul3.txt | sort -u >> unique_sub.txt

cat prints the contents of the three files one after another. sort -u sorts the lines and removes duplicates (-u means unique). The combined, de-duplicated list is saved as unique_sub.txt. The point of all this is to build one clean list of every address worth looking at, without testing the same thing twice.

Step 2: spotting the endpoint

While browsing the main application in Burp, he noticed the endpoint XXXXXX.aspx. It handled transaction data, and he saw that other functions, such as product tax invoice and sell tax invoice, also used it. That suggested one or more features were reaching the same endpoint to get tax invoice data, which made it worth a closer look.

He tried fuzzing the endpoint directly. Fuzzing means sending many slightly different inputs to see how the system reacts, hoping one of them produces an unexpected result. This produced nothing useful, so he went back to the archived URLs.

Step 3: turning full URLs into paths

He used a bash pipeline to pull just the path part out of every URL in unique_sub.txt:

Bash
cat unique_sub.txt | sed 's/^.*.com//' | sed 's/?.*//' >> endpoint_path.txt

sed is a tool for find-and-replace on text. The first sed command, s/^.*.com//, removes everything from the start of the line up to and including .com, leaving only what comes after the domain. The second, s/?.*//, removes the question mark and everything after it, which is the query string. What remains is the path, such as /XXXXX/transaction. The cleaned paths are saved to endpoint_path.txt.

He then appended the endpoint name to every path:

Bash
cat endpoint_path.txt | sed 's/$/\/XXXXXX.jsp/'

s/$/.../ means "at the end of each line ($), add this text". Note that this line adds XXXXXX.jsp while the endpoint discussed everywhere else is XXXXXX.aspx; the report shows both spellings, and it is not clear which was actually used.

Step 4: requesting every combination

He then requested every path-plus-endpoint combination through httpx, with Burp set as the proxy so he could review all the traffic afterwards:

Bash
xargs -a endpoint_path.txt -I@ bash -c 'for url in $(cat endpoint_path.txt | sed "s/$/\/XXXXXX.aspx/"); do echo "http://$url/@";done' | httpx -silent -status-code -http-proxy http://[redacted]:8080

This is a dense line, so here it is piece by piece:

  • xargs -a endpoint_path.txt reads the file and runs the following command for each entry.
  • -I@ sets @ as the placeholder for the current entry.
  • bash -c '...' runs a small shell script for each entry.
  • Inside that script, cat endpoint_path.txt | sed "s/$/\/XXXXXX.aspx/" takes every path and adds /XXXXXX.aspx to its end.
  • for url in ...; do echo "http://$url/@"; done prints an http:// address for each of those combinations.
  • | httpx -silent -status-code sends each address through httpx, quietly, and prints the status code for each.
  • -http-proxy http://[redacted]:8080 routes all of it through Burp, which listens on that local address, so every request and response is recorded.

A proxy here is a middleman program on your own computer that all traffic passes through, which is exactly what Burp does.

Step 5: the endpoint that stood out

In the Burp history, one result stood out:

Text
https://transaction.example.com/transaction/XXXXXX.aspx

This is a subdomain called transaction, with a path containing transaction and the endpoint name. It returned 403, meaning forbidden: the server understood the request but refused to serve it.

He tried reusing the cookie and session ID from the main domain, but that did not help. A cookie is a small piece of data a website stores in your browser so it can recognise you on the next request; a session ID is the value inside it that identifies your logged-in session, like a wristband at an event. If the endpoint accepted the main site's wristband, it would have let him in. It did not. He tried various other techniques for getting past a 403, and all of them failed.

Step 6: the old school method

Since every bypass technique failed, he went back to basics and asked the endpoint which request methods it accepted:

An HTTP method is the verb at the start of a request that says what you want to do. GET means "give me this page". POST means "here is some data, act on it". OPTIONS means "tell me which methods you allow here". The first line above is the request line: method, path, and the HTTP version. The second line, Host, tells the server which site name the request is for, since one server can host many sites.

He then sent each of the allowed methods one at a time. With POST, the endpoint downloaded the file from the S3 bucket that stored the transaction PDF, and the bucket URL appeared in the response:

Text
https://XXXXX.s3.us-east-1.amazonaws.com/11XXXXXXXXXX012.pdf

This is the address of a single PDF file inside the bucket. The bucket's name is hidden as XXXXX, and the file name is partly hidden too. The important detail is that the address contains no folder: the file sits directly at the top of the bucket.

Step 7: trying the bucket directly

He tried to list the bucket with the AWS CLI:

Bash
aws s3 ls s3://XXXXX — region us-east-1

aws s3 ls lists the contents of what follows. s3://XXXXX is the bucket. The — region us-east-1 part is written with a long dash in the report rather than the usual double hyphen, so as shown it would not run as a normal command; the intent is to specify the region.

This failed, because the bucket itself had a proper access control policy. An access control policy is the set of rules saying who may read, list or change what. At the top level, the rules were correct, so listing was refused.

Step 8: looking for a folder name

The researcher's earlier experience was with buckets protected at bucket level but not at folder level. The obstacle here was that the PDF address contained no folder at all, so there was no folder name to try. He searched the page source and JavaScript files by hand. Page source is the underlying text a browser receives and turns into the page you see; JavaScript files are the programs the page runs in your browser, and they often contain addresses the page uses behind the scenes.

He found a bucket address that did include a folder:

Here document is a folder inside the bucket, and uploadXXXX.png is a file inside that folder. He tried the CLI against that folder:

Bash
aws s3 ls s3://XXXXX /document — region us-east-1

This also failed. Note the space between the bucket name and /document in the report; the usual form would join them as s3://XXXXX/document.

Step 9: guessing folder names

At this point he was losing hope and thought about stopping, but decided on one last attempt: guessing folder names on the bucket itself. He built a custom wordlist of terms commonly used in banking services. A wordlist is simply a text file of candidate names to try, one per line. A custom wordlist means it was written for this target rather than taken off the shelf, which makes each guess far more likely to hit.

Any directory brute-forcing tool would work; he used Burp Intruder. Directory brute-forcing means trying a long list of names against a server to see which ones exist. He filtered the results by response length, because a folder that exists usually returns a different amount of content than one that does not. The output surprised him: it returned valid folders:

Text
/kyc_details/
/banking_info/
/transaction/

kyc_details refers to Know Your Customer checks, the identity checks banks perform. banking_info suggests bank account details. transaction matches the transaction theme of the whole story. One of these folders lacked a proper access control policy.

Step 10: listing the unprotected folder

Bash
aws s3 ls s3://XXXXX/banking_info/ — region us-east-1

This asks the AWS CLI to list the contents of the banking_info folder inside the bucket. The output was a shock: it listed the bank information and personal data of users.

The screenshot shows the researcher's reaction to the listing output.

From the original on notifybugme.medium.com

The second screenshot shows what the folder listing returned: user bank information and PII. PII stands for personally identifiable information, meaning data that can identify a specific person, such as a name, address or account number.

Why it worked

The bucket had a correct access control policy at bucket level, which is why aws s3 ls s3://XXXXX was refused. That protection was not applied to the folders inside it, so a folder such as banking_info/ could be listed once its name was known. The name was found by brute-forcing with a custom wordlist of terms commonly used in banking services.

The 403 on the .aspx endpoint was a separate obstacle. Sending POST made the endpoint download the transaction PDF from the S3 bucket, and the bucket address appeared in the response.

Impact

Anyone who found the folder name could list it, and the listing showed the bank information and PII of users. The researcher describes the issue as critical and says the bank fixed it immediately. The report does not say which data fields were exposed, how many users were affected, or whether the files themselves could be downloaded as well as listed.

The fix

The report says the bank fixed the issue quickly but does not describe what was changed. The fix that addresses the root cause is to apply access control at object and folder level, not only at bucket level, so that every folder inherits the same restriction, and then to verify it by attempting an unauthenticated listing of each folder.

Variants to test

  1. List a bucket anonymously with aws s3 ls s3://bucket and, if that is denied, try known or guessed folders such as aws s3 ls s3://bucket/prefix/. A positive result is a listing of objects where the bucket root was denied.
  2. Harvest bucket and folder names from JavaScript files and page source, as was done here with the document/ address. A positive result is a bucket address containing a path segment that the application itself uses.
  3. Brute-force folder names with a wordlist tailored to the target's industry, filtering by response length. A positive result is a set of folders that return listings or files rather than access denied.
  4. When an endpoint returns 403, send OPTIONS and then each allowed method. A positive result is a method that returns data or a download link that GET did not.
  5. Follow download links returned by the application back to their storage address and test the storage host directly, both at bucket root and at the folder shown in the link.

Takeaway

The researcher notes that many people have probably seen this process before, but this is how he approached exploiting an S3 bucket through a folder to reach a bank's PII. His real lesson is to be creative and not to give up until you achieve something or learn something new from it. That is why he shared the experience, and to highlight other ways such a weakness can be exploited.

The final image is the researcher's buy-me-a-coffee link.

Glossary

  • Access control policy: the rules that decide who may read, list or change something.
  • AWS CLI: Amazon's command-line tool for working with Amazon services such as S3.
  • Bucket: the top-level container in Amazon S3 that holds files and folders.
  • Bug bounty programme: an arrangement where a company invites outside researchers to find and report security problems.
  • Burp Suite: a program that sits between your browser and a website, recording and letting you change requests and responses.
  • Cookie: a small piece of data a website stores in your browser so it can recognise you later.
  • Directory brute-forcing: trying a long list of names against a server to discover which ones exist.
  • Endpoint: a specific address on a website that performs a specific job.
  • Folder (prefix): a grouping inside an S3 bucket, like a folder in a filing cabinet.
  • Fuzzing: sending many slightly different inputs to see how a system reacts.
  • gau: a tool that collects known URLs for a domain from internet archives.
  • HTTP method: the verb at the start of a request, such as GET, POST or OPTIONS, saying what you want to do.
  • httpx: a tool that sends requests to many addresses and reports what came back.
  • Intruder: Burp Suite's feature for sending the same request many times with different values.
  • JavaScript: programs that run in your browser and often contain addresses a page uses behind the scenes.
  • KYC: Know Your Customer, the identity checks banks perform on customers.
  • Page source: the underlying text a browser receives and turns into the page you see.
  • Parameter: a named value passed to a page in a URL, as in page?name=value.
  • PII: personally identifiable information, data that can identify a specific person.
  • Pipe: the | symbol, which feeds the output of one command into another.
  • POST: an HTTP method meaning "here is some data, act on it".
  • Private programme: a bug bounty programme open only to invited researchers.
  • Proxy: a middleman program that traffic passes through, such as Burp Suite.
  • Region: the data centre area where Amazon stores a bucket, such as us-east-1.
  • S3: Amazon's online file storage service.
  • sed: a command-line tool for find-and-replace on text.
  • Session ID: the value in a cookie that identifies your logged-in session.
  • Status code: the number a web server returns with every reply, such as 200, 403 or 404.
  • Subdomain: a smaller address under a main domain, such as shop.example.com.
  • Subfinder: a tool that finds subdomains of a domain.
  • Waybackurls: a tool that collects archived URLs for a domain.
  • Wordlist: a text file of candidate names to try, one per line.

More by Santosh Kumar Sha

View all

16 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.