Misconfigured S3 Bucket Access Controls to Critical Vulnerability
An S3 bucket used for static resources was misconfigured to allow unauthenticated users to upload and delete files. An attacker could delete legitimate resources and replace them with malicious content, affecting any application that references those files.
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
Amazon S3 (Simple Storage Service) is one of the most widely used storage services, and companies commonly use buckets to hold assets such as user profile pictures and static resources. When a bucket is misconfigured or unclaimed, an attacker may be able to carry out actions such as an S3 bucket takeover or an S3 content takeover.
This write-up covers a recent encounter in which a misconfigured S3 bucket allowed any of the CRUD operations, which the author classifies as a critical vulnerability. The application under test had a large scope, and the finding relates to one of the subsidiaries of the program, referred to here as subtarget.com.

Setup
The work needs two things: a way to enumerate subdomains and resolve them, and the AWS CLI configured with credentials so that bucket permissions can be tested with default commands.
- Install the AWS CLI.
- Provide an AWS access key and secret to configure the AWS CLI.
The enumeration used subfinder and httpx, as shown in the next section.
Finding it
Enumeration started with subdomain enumeration and resolving unique subdomains:
subfinder -d subtarget.com -silent | httpx -follow-redirects -status-code -vhost -threads 300 -silent | sort -u | grep "[200]" | cut -d [ -f1 > resolved.txt
From that list, a subdomain named https://qa-assets-us.subtarget.com was found. Navigating to it showed that the bucket was open and returned a ListBucketResult.
An open bucket used for static resources is not, on its own, worth reporting, because such buckets are sometimes open intentionally. The next step was to look at the listing entry that provides the name of the S3 bucket:
<Name>some-name-here</Name>
With the bucket name in hand, the next process is to test the access controls of the bucket. Normally a bucket should not give an unauthorised user the following permissions:
- Create something on the bucket
- Modify something on the bucket
- Delete something on the bucket
- Read some sensitive data on the bucket (on a case-by-case basis)
The recommended way to test these access controls is with the AWS CLI and its default commands.
Exploitation
Step 1: Test upload (create)
Use the following command to check whether there is access to upload something to the bucket:
aws s3 cp yourtestfile.txt s3://bucketname
On success, the output looks like this:
upload: ./yourtestfile.txt to s3://bucketname/yourtestfile.txt
In this case the file was successfully uploaded to the bucket.
Step 2: Test delete
To increase the impact, the next check was whether the uploaded file could be deleted:
aws s3 rm s3://bucketname/yourtestfile.txt
The file was successfully removed.
Step 3: Assess the combined impact
With both create and delete confirmed, the impact increases: the original resource can be deleted and a new, attacker-defined resource with the same name can be uploaded. Wherever the application references that resource, it will now show the attacker-defined resource.
Root cause
The bucket's access controls allowed an unauthorised user to create and delete objects. The report does not describe the bucket policy or ACL configuration that produced this state, so the exact misconfiguration is not stated. The open listing alone was treated as possibly intentional; it was the write and delete permissions that turned the finding into a vulnerability.
Impact
An unauthorised user could create objects in the bucket and delete existing ones. Because the bucket serves static resources referenced by the application, an attacker could delete an original resource and upload a replacement with the same name, so that wherever the application references that resource it serves the attacker-defined content instead. The report does not state which resources were affected or how widely they were referenced.
Fix
Variants to test
- Enumerate subdomains and look for hosts that return a
ListBucketResult, then extract the bucket name from the<Name>element. A positive result is a listing that exposes the bucket name. - Run
aws s3 cpagainst the bucket with a test file. A positive result is theupload: ... to s3://...confirmation. - Run
aws s3 rmagainst the file just uploaded. A positive result is the object being removed. - Check the remaining CRUD actions: modify an existing object and read sensitive data, on a case-by-case basis. A positive result is any of these succeeding without authorisation.
Timeline
- Reported
- Blocker for the company on impact
- Triaged and accepted as P1
What happened, in plain words
A company kept some of its files in an online storage service called Amazon S3. You can think of S3 as a very large shared locker room: each company rents one or more lockers, called buckets, and puts files inside them. Those files might be profile pictures, images used on a website, or other things the website needs to show to visitors.
Normally a locker should be set up so that strangers can look through the glass (read the files the website needs to show) but cannot open the door and put things in or take things out. In this case the door was left unlocked. A security researcher found one of this company's buckets, and discovered he could upload his own file into it and then delete it again. That sounds small, but it means anyone could delete a real file the website uses and replace it with a file of their own choosing, under the same name. Wherever the website points at that file, it would then show the attacker's file instead of the company's.
The researcher wrote the finding up as a critical vulnerability. The timeline in the write-up lists it as a blocker for the company on impact, then triaged and accepted as P1.

The picture above is the author's profile picture from the site where the write-up was published.
The background: what S3 and buckets are
Amazon S3 stands for Simple Storage Service. It is one of the most popular ways for companies to store files in the cloud. Instead of keeping images on their own servers, companies put them in S3 and let Amazon look after them. A bucket is the container: every file (S3 calls each file an object) lives inside a bucket, and every bucket has a name that is unique across all of Amazon S3.
Because buckets are so common, mistakes in how they are configured are common too. Two classic mistakes are:
- S3 bucket takeover: the bucket name a company refers to in its website or app no longer exists, so an attacker can register a bucket with that same name and serve their own content.
- S3 content takeover: the bucket exists but its permissions are too loose, so an attacker can change what is inside it.
This write-up is about the second kind. The researcher found a bucket whose permissions let him do any of the CRUD operations. CRUD is a general computing acronym for the four basic things you can do with stored data:
- Create: add something new.
- Read: look at something.
- Update: change something that already exists.
- Delete: remove something.
A well-behaved public bucket usually allows only Read, and only for files that are meant to be public. Allowing Create, Update or Delete to strangers is the problem.
The application being tested belonged to a large programme with a wide scope. Scope here means the list of systems a researcher is allowed to test. The finding was in one of the programme's subsidiaries, which the write-up calls subtarget.com (a stand-in name, not the real domain).
Getting set up
Two things were needed before testing could start.
- A way to find the company's web addresses. A large company has many subdomains, which are the prefixes in front of a domain name, like
shop.example.comorqa.example.com. Finding them by hand is impossible, so the researcher used two command-line tools, subfinder and httpx. A command line is a text window where you type instructions instead of clicking buttons. - The AWS CLI. AWS is Amazon Web Services, Amazon's cloud platform, and the AWS CLI is Amazon's own command-line tool for working with it. To use it you need an access key and a secret, which are a pair of long strings that identify you to Amazon, a bit like a username and password for a program rather than a person. With the CLI installed and configured, the researcher could ask S3 directly whether his account was allowed to do things to the bucket.
Finding the bucket
The first step was to list the company's subdomains and keep only the ones that actually answered. This is the command that was run:
subfinder -d subtarget.com -silent | httpx -follow-redirects -status-code -vhost -threads 300 -silent | sort -u | grep "[200]" | cut -d [ -f1 > resolved.txt
Line by line, in plain words:
subfinder -d subtarget.com -silentasks subfinder to find subdomains ofsubtarget.com. The-silentflag means "only print the results, not extra chatter".- The vertical bar
|is a pipe: it takes whatever the first command printed and hands it to the next command as input. Think of it as passing a bucket of results down an assembly line. httpx -follow-redirects -status-code -vhost -threads 300 -silenttakes each subdomain and actually visits it.-follow-redirectsmeans if a page redirects somewhere else, follow it.-status-codemeans also print the HTTP status code, the three-digit number a web server sends back (200 means "here is the page", 404 means "not found").-vhostmakes it also try the address as a virtual host, which is how many web servers decide which site to show.-threads 300means do 300 of these checks at the same time, to go faster.-silentagain means quiet output.sort -usorts the lines and removes duplicates, so each address appears once.grep "[200]"keeps only the lines that contain[200], that is, the addresses that answered successfully.cut -d [ -f1splits each line at the opening square bracket and keeps the part before it, which is the address itself without the status code attached.> resolved.txtwrites the final list into a file calledresolved.txt.
From that list, one address stood out: https://qa-assets-us.subtarget.com. Visiting it in a browser showed that the bucket was open: the page returned something called a ListBucketResult.
A ListBucketResult is what S3 sends back when someone asks a bucket "what is in you?" and the bucket is willing to answer. It is a list of every file in the bucket. Seeing it means the bucket allows anyone to browse its contents.
On its own, that is not worth reporting. Plenty of companies deliberately make asset buckets listable, because the files inside are public anyway (images on a website, for example). The write-up notes that such buckets are sometimes open intentionally. So the researcher kept going.
Getting the bucket's name
To test permissions with the AWS CLI, you need the bucket's exact name. The listing conveniently provides it. Inside the listing there is an entry like this:
<Name>some-name-here</Name>
This is a small piece of XML, a text format for structured data where things are wrapped in angle-bracket tags. <Name> opens a tag and </Name> closes it, and whatever sits between them is the value. Here the value is the bucket's name. The bucket name is shown here as some-name-here.
What a bucket should and should not allow
With the name in hand, the next job was to test the bucket's access controls. Access controls are the rules that decide who may do what. On a shared drive at work, for example, you might be allowed to view a folder but not delete anything in it; those are access controls.
A bucket should not let a stranger (an unauthorised user) do any of the following:
- Create something in the bucket.
- Modify something in the bucket.
- Delete something in the bucket.
- Read sensitive data in the bucket, judged case by case, because some files are meant to be public and some are not.
The recommended way to check all this is with the AWS CLI and its default commands.
Testing what the bucket allows
Step 1: Can I upload a file?
The first test is whether a stranger can add a file. This is the command:
aws s3 cp yourtestfile.txt s3://bucketname
In plain words:
awsstarts the AWS command-line tool.s3says which Amazon service to talk to, here S3.cpmeans copy, the same idea as copying a file on your computer.yourtestfile.txtis the test file being uploaded.s3://bucketnameis the destination, written in S3's address style:s3://followed by the bucket name. It is like a web address, but for a bucket instead of a page.
If the upload is allowed, the tool prints a confirmation like this:
upload: ./yourtestfile.txt to s3://bucketname/yourtestfile.txt
That line says the local file ./yourtestfile.txt (the ./ means "in the current folder") was copied to the bucket under the same name. In this case the upload succeeded, which already means the bucket lets strangers write to it.
Step 2: Can I delete a file?
Writing a file is bad enough, but the researcher wanted to know how far the permissions went, because more permissions mean more impact. So he tried to remove the file he had just uploaded:
aws s3 rm s3://bucketname/yourtestfile.txt
In plain words:
aws s3again means "talk to S3".rmmeans remove, the same as deleting a file.s3://bucketname/yourtestfile.txtis the exact file to delete: the bucket name, a slash, then the file name.
The file was successfully removed. Deleting his own test file proves the bucket also allows strangers to delete things, and that is the dangerous part.
Step 3: Why the two together matter
Create plus delete is far worse than either alone. If you can delete a real file and then upload your own file with exactly the same name, then every place the website points at that file will now show your file instead. The write-up puts it this way: the original resource can be deleted and a new, attacker-defined resource with the same name can be uploaded, and wherever the application references that resource, it will now show the attacker-defined resource.
Why it happened
The bucket's access controls let an unauthorised user create and delete objects. The write-up does not describe the exact bucket policy or ACL settings that produced this state. An ACL (access control list) is a list attached to a resource saying who may do what with it. What is clear is that the open listing alone was treated as possibly intentional, and it was the write and delete permissions that turned the finding into a real vulnerability.
What the impact was
A stranger could add files to the bucket and remove existing ones. Because the bucket serves files that the application refers to, an attacker could swap a real file for one of their own under the same name, and the application would serve the attacker's version. The write-up does not say which files were affected or how many places referred to them.
How it should be fixed
The obvious remedy is to tighten the bucket's access controls so that strangers cannot create, modify or delete objects, while leaving any deliberate public read access for static files in place.
How to look for the same thing yourself
- Find the company's subdomains and look for addresses that return a
ListBucketResult. Then pull the bucket name out of the<Name>element. A hit is a listing that reveals the bucket name. - Run
aws s3 cpagainst the bucket with a harmless test file. A hit is theupload: ... to s3://...confirmation. - Run
aws s3 rmon the file you just uploaded. A hit is the file being removed. - Check the remaining CRUD actions: change an existing object, and read sensitive data, judged case by case. A hit is any of these succeeding without permission.
Timeline
- Reported.
- Blocker for the company on impact.
- Triaged and accepted as P1.
Glossary
- Access controls: the rules that decide who is allowed to do what with a resource, such as who may read, change or delete a file.
- ACL (access control list): a list attached to a resource that names who may perform which actions on it.
- Amazon S3 (Simple Storage Service): Amazon's cloud service for storing files.
- AWS (Amazon Web Services): Amazon's cloud platform, of which S3 is one part.
- AWS CLI: Amazon's command-line tool for working with AWS services, including S3.
- Access key and secret: a pair of long strings that identify a program to AWS, roughly like a username and password for software.
- Bucket: the container in S3 that holds files; every bucket name is unique across all of S3.
- CRUD: the four basic operations on stored data: Create, Read, Update, Delete.
- Command line: a text window where you type instructions instead of clicking buttons.
- Enumeration: systematically listing things, such as all the subdomains of a domain.
- HTTP status code: the three-digit number a web server returns with a response, such as 200 for success or 404 for not found.
- httpx: a command-line tool that visits a list of addresses and reports details such as status codes.
- ListBucketResult: the response S3 sends when a bucket allows anyone to list its contents.
- Object: S3's word for a single stored file.
- P1: the highest priority level in a bug bounty programme, meaning the issue is serious and should be handled urgently.
- Pipe (
|): a way to pass the output of one command straight into the next command. - Scope: the list of systems a researcher is permitted to test.
- S3 bucket takeover: registering a bucket under a name a company still refers to but no longer owns, so the company's app loads the attacker's content.
- S3 content takeover: abusing loose permissions on an existing bucket to change what it serves.
- Subdomain: a prefix in front of a domain name, such as
shopinshop.example.com. - subfinder: a command-line tool that finds subdomains of a domain.
- Threads: separate tasks a program runs at the same time; more threads means faster checking.
- Virtual host (vhost): a way for one web server to host several sites and choose which one to show based on the address requested.
- XML: a text format for structured data in which values are wrapped in angle-bracket tags such as
<Name>and</Name>.