Skip to content
Access control Write-up Intermediate

Write-up: AWS Document Signing Security Control Bypass

The application's pre-signed URL endpoint allowed an attacker to obtain valid signatures for the S3 bucket root directory by emptying the S3TmpKey parameter, leading to directory listing and access to all documents. An attacker could then use the listed paths to generate signed URLs for any document, bypassing access controls.

Ozgur Alp Follow

Published on medium.com

Bounty$1,000 View original

{{media:0}}

Ozgur Alp, 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

This write-up covers a vulnerability found on one of the weekly targets of the Synack platform. The target application had a document upload section and a document view section. Both sections used Amazon AWS, specifically S3, as a CDN for storing and retrieving the uploaded documents.

When a user views a document, the application does not serve the file itself. Instead it asks its back end for a signed URL pointing at the S3 object, and the browser then fetches the document directly from AWS. The signing is meant to stop malicious third parties reaching sensitive documents: AWS Signature Version 4 signatures are generated on the back end using private material such as AWS secret keys.

Document upload section From the original on medium.com

Document upload section

Setup

The report does not describe any particular account, role, tool or version. The researcher was working on one of Synack's weekly targets and found a document upload section and a document view section. The only precondition that matters is that the user can upload a document and then view it, because viewing is what triggers the signed URL request.

Finding it

The document upload section looked like a promising entry point, since unrestricted file upload is a classic route to remote code execution. That line of testing is not what the report ends up following. What mattered was the view path: the application was using AWS as the CDN for the uploaded documents, and the view request went to the /s3/preSignedURL endpoint with parameters including a payload that defines the exact file and an operation name.

Viewing the document From the original on medium.com

Viewing the document

AWS signing process From the original on medium.com

AWS signing process

The signing technology is AWS Signature Version 4, used on demand, which is meant to ensure sensitive documents cannot be reached by malicious third parties. The signatures are produced on the back end from private information such as the AWS secret keys, which is exactly why the client should not be able to influence what gets signed beyond the file it is allowed to see.

Exploitation

Step 1: capture the view request and its payload

The /s3/preSignedURL endpoint returned the signed URLs on the AWS storage used for viewing documents. The URL-encoded payload parameter carried the following value:

Text
payload={"linkType":"Attachment","S3TmpKey":"8f397040-8f08-48a6-a431-8db7ffc8be17/2018_SRT_Calendar.pdf","S3TmpVersion":"[redacted]","xhr":{},"link":"","linkVersion":"","fileName":"2018_SRT_Calendar.pdf","progress":"100","fileStatus":"Uploaded","size":"6.7 MB","lastModified":1516121201000}

The important field is S3TmpKey, whose value is the path and file name of the document inside the bucket. The other fields describe the attachment, its version, upload progress, status, size and last modification time. In the response, the url parameter was generated with this syntax:

Text
https://target.attachments.s3.amazonaws.com/<S3TmpKey>?Signatures

So the key from the payload is placed directly into the object path that gets signed.

Step 2: reduce the payload to a single parameter

The researcher's usual approach is to send clean, minimal requests first and then add parameters back one at a time when the response errors, to learn what the back end does with each of them. Here the payload was URL-decoded, every parameter except S3TmpKey was deleted, and the value of S3TmpKey was emptied as well. The payload was then URL-encoded again and sent.

URL decoding the payload parameter, deleting all parameters except S3TmpKey, emptying its value and URL encoding it again From the original on medium.com

URL decoding the payload parameter, deleting all parameters except S3TmpKey, emptying its value and URL encoding it again

Step 3: observe what an empty key gets signed

Sending S3TmpKey empty returned a valid signature for the root directory of the S3 bucket.

Valid signatures for root directory From the original on medium.com

Valid signatures for root directory

This is the core of the bypass: an empty key was signed and resolved to the bucket root. It took whatever key arrived in the payload, signed it, and handed the signature back. An empty key resolves to the bucket root, and the service signed that.

Step 4: use the signed URL to list the bucket

Accessing the returned URL parameter directly from the browser returned a directory listing for all document names and their exact paths.

Directory listing on AWS S3 bucket From the original on medium.com

Directory listing on AWS S3 bucket

Step 5: read other users' documents

With the paths and file names obtained from the listing, assigning the S3TmpKey parameter to those paths and file names made it possible to gather all documents under this S3 bucket, including documents belonging to other users.

Root cause

The /s3/preSignedURL endpoint signed whatever object path the client-supplied S3TmpKey contained, including an empty value that resolved to the bucket root. Because the key was placed straight into the object path of the signed URL, an empty value produced a signature for the bucket root, and the bucket allowed listing. The signing control could be bypassed by sending an empty key. The report does not describe the server-side code, so the exact validation that was missing is inferred from behaviour rather than shown.

Impact

A user of the application could obtain valid signatures for paths in the attachments bucket. Starting from the root listing, they could enumerate every document name and its exact path, then request signatures for those paths and download all documents stored in the bucket, including other users' documents. The client fixed it within a week due to its criticality.

Fix

A fix would need to bind the signed key to the requesting user's own documents, reject keys that do not resolve to a single object the user owns, and stop the bucket from serving directory listings.

Variants to test

  1. Empty or root-like keys: send the key parameter empty, as /, or as a prefix without a file name. A positive result is a signature that resolves to a listing or to objects outside your own uploads.
  2. Path traversal in the key: use ../ sequences or absolute-style paths inside the key value. A positive result is a signed URL for an object outside your own prefix.
  3. Other users' keys: take a key observed in a listing or guessed from a predictable pattern and request a signature for it. A positive result is a downloadable document you do not own.
  4. Parameter stripping: remove every field except the key, as done here, and see whether the back end still signs. A positive result shows the other fields were never part of the authorisation decision.
  5. Bucket listing: request the signed root URL from a browser or client and check for an XML or HTML listing of keys. A positive result exposes document names and paths.
  6. Version and operation fields: change S3TmpVersion or the operation name to values for other objects or actions. A positive result is a signature for an operation or object the user should not be able to request.

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

What happened, in plain words

A security researcher was testing a website that lets people upload documents and then view them again later. The website stored those documents on Amazon's cloud storage service, S3, rather than on its own servers. To let a user view a document, the website's back end created a special web address (a URL) that carried a cryptographic signature, a kind of tamper-proof stamp, and the browser then used that address to fetch the file straight from Amazon.

The idea behind the signature is simple: only the website's back end knows the secret keys needed to produce it, so a stranger should not be able to make up a valid address for a document that is not theirs. The researcher found that sending an empty file path returned a valid signature for the top level of the storage bucket. By sending an empty file path, the researcher got a valid signature for the top level of the storage bucket, the folder that holds everything. Opening that address in a browser showed a list of every document name and its exact location. From there, the researcher could ask for signatures for other people's documents and download them.

The researcher reported it through the Synack platform, received around 1k in payout, and the client fixed it within a week.

Ozgur Alp
Ozgur Alp From the original on medium.com

The setting: a document upload and view feature

The target was one of the weekly targets on Synack, a platform where organisations invite vetted researchers to test their systems and pay for confirmed findings. The application had two relevant parts: a section where you upload a document, and a section where you view a document you (or someone) uploaded.

Document upload section From the original on medium.com

Document upload section

A document upload form is interesting to a tester because, if the site accepts any kind of file and then runs or serves it carelessly, an attacker can sometimes get their own code to execute on the server. That class of bug is called remote code execution, usually shortened to RCE: the attacker manages to make the server run code the attacker wrote. The researcher notes this as a promising entrance point, but the story does not go that way. What mattered was the viewing side.

Where the documents actually live

Both the upload and the view sections used Amazon AWS, and specifically S3, as a CDN for storing and retrieving the uploaded documents.

A few terms from zero:

  • AWS (Amazon Web Services) is Amazon's collection of cloud services. You rent storage, computers and other building blocks instead of owning them.
  • S3 (Simple Storage Service) is the storage part. You create a bucket, which is like a named top-level folder in the cloud, and put objects (files) inside it. Each object has a key, which is its path and file name inside the bucket, for example some-folder/report.pdf.
  • CDN (content delivery network) is a service that holds copies of files close to users so they load quickly. Here the site used S3 as the place the files live and are fetched from.

So when you view a document, the application does not read the file from its own disk and send it to you. It points your browser at the file in Amazon's storage.

The view request

For the view of the document, the request looked like this:

Viewing the document From the original on medium.com

Viewing the document

The application sent a request to the /s3/preSignedURL endpoint with parameters such as a payload that defines the exact file and an operation name.

Two more terms:

  • Endpoint is a specific address on a server that does one job. Think of a large office building: the street address gets you to the building, and the endpoint is the particular desk you walk up to. /s3/preSignedURL is the desk that hands out signed links.
  • Parameter is a named value attached to a request, like the fields on a paper form. The server reads them to decide what to do.

Why a signature at all

AWS has a signing technology, used on demand, which ensures that access to sensitive documents is not possible via malicious third parties. These signatures are generated on the back end with private information such as AWS secret keys.

AWS signing process From the original on medium.com

AWS signing process

In everyday terms: imagine a members-only cloakroom. The attendant has a stamp that only they own. When you hand over a ticket for your own coat, the attendant stamps it, and the door staff accept the stamped ticket. A forger cannot make a stamped ticket because they do not have the stamp. The stamp here is the AWS secret key, held only by the back end. The signed URL is the stamped ticket.

The signing scheme is AWS Signature Version 4. The report links to Amazon's documentation on it for anyone who wants the details.

Step 1: capture the view request and its payload

The /s3/preSignedURL endpoint was used to gather the signed URLs on the AWS storage for viewing documents. The URL-encoded payload parameter had this value:

Text
payload={"linkType":"Attachment","S3TmpKey":"8f397040-8f08-48a6-a431-8db7ffc8be17/2018_SRT_Calendar.pdf","S3TmpVersion":"[redacted]","xhr":{},"link":"","linkVersion":"","fileName":"2018_SRT_Calendar.pdf","progress":"100","fileStatus":"Uploaded","size":"6.7 MB","lastModified":1516121201000}

Line by line, in plain words:

  • payload= is the name of the parameter. Everything after the equals sign is its value.
  • The value is a block of data in JSON format, which is just a way of writing labelled values inside curly braces. Each label is a field.
  • "linkType":"Attachment" says what kind of link this is.
  • "S3TmpKey":"8f397040-8f08-48a6-a431-8db7ffc8be17/2018_SRT_Calendar.pdf" is the important one. It is the path and file name of the document inside the bucket: a folder-like part made of a long identifier, then the file name.
  • "S3TmpVersion":"[redacted]" is a version marker for the stored file.
  • "xhr":{} is an empty object, a placeholder with nothing in it.
  • "link":"" and "linkVersion":"" are empty strings, meaning no value was set.
  • "fileName":"2018_SRT_Calendar.pdf" repeats the file name.
  • "progress":"100" says the upload finished.
  • "fileStatus":"Uploaded" says the file is uploaded.
  • "size":"6.7 MB" is the file size.
  • "lastModified":1516121201000 is a timestamp for when the file last changed.

In the response, the url parameter was generated with this syntax:

Text
https://target.attachments.s3.amazonaws.com/<S3TmpKey>?Signatures

Reading that address:

  • https:// is the normal secure web protocol.
  • target.attachments.s3.amazonaws.com is the address of the bucket in Amazon's storage. The word target stands in for the client's name.
  • <S3TmpKey> is a placeholder: whatever key came in the payload is dropped in here as the object path.
  • ?Signatures is a placeholder for the signature values appended to the address, the stamped part that proves the link was issued by the back end.

So the key from the payload is placed directly into the object path that gets signed. That is the detail worth remembering: the client chooses the path, and the server signs it.

Step 2: reduce the payload to a single parameter

The researcher's usual approach is to send clean, minimal requests first and then add parameters back one at a time when the response errors, to learn what the back end does with each of them. This is like testing a form by filling in only one field at a time to see which fields actually matter.

Here the payload was URL-decoded, every parameter except S3TmpKey was deleted, and the value of S3TmpKey was emptied as well. The payload was then URL-encoded again and sent.

URL decoding the payload parameter, deleting all parameters except S3TmpKey, emptying its value and URL encoding it again From the original on medium.com

URL decoding the payload parameter, deleting all parameters except S3TmpKey, emptying its value and URL encoding it again

Two terms used there:

  • URL encoding is a way of writing characters that are not allowed in a web address, or that have special meaning, using percent signs and codes. For example a space becomes %20. Decoding turns it back into readable text; encoding does the reverse.
  • Emptying a value means leaving the field present but with nothing after it, so the server receives a blank where a path used to be.

Why do this? To find out whether the back end actually checks the key, or simply signs whatever it is handed. If the other fields were needed for some authorisation decision, removing them would break the request. If the key is the only thing that matters, the request still works.

Step 3: observe what an empty key gets signed

Sending S3TmpKey empty returned a valid signature for the root directory of the S3 bucket.

Valid signatures for root directory From the original on medium.com

Valid signatures for root directory

This is the core of the bypass: an empty key was signed and resolved to the bucket root. It took whatever key arrived in the payload, signed it, and handed the signature back. An empty key resolves to the bucket root, and the service signed that.

In the cloakroom comparison: you handed over a blank ticket, and the attendant stamped it anyway. A blank ticket, in this system, means the whole cloakroom rather than one coat.

Step 4: use the signed URL to list the bucket

Accessing the returned URL parameter directly from the browser returned a directory listing for all document names and their exact paths.

Directory listing on AWS S3 bucket From the original on medium.com

Directory listing on AWS S3 bucket

A directory listing is what it sounds like: instead of showing one file, the server shows an index of everything in the folder. On a normal website you often see this when a folder has no home page. Here it meant the names and locations of every stored document were visible.

Step 5: read other users' documents

With the paths and file names obtained from the listing, assigning the S3TmpKey parameter to those paths and file names made it possible to gather all documents under this S3 bucket, including documents belonging to other users.

In other words, the listing gave the map, and the signing endpoint gave a stamped ticket for any point on the map. The signature was supposed to be the lock, but it was signing whatever was asked for.

Why it worked

The /s3/preSignedURL endpoint signed whatever object path the client-supplied S3TmpKey contained, including an empty value that resolved to the bucket root. Because the key was placed straight into the object path of the signed URL, an empty value produced a signature for the bucket root, and the bucket allowed listing. The signing control could be bypassed by sending an empty key.

Two words that get confused:

  • Authentication answers "who are you?" The signature proved the request really came from the back end holding the secret key.
  • Authorisation answers "are you allowed to do this?" The signature said nothing about whether this particular user should see this particular document.

The report does not describe the server-side code, so the exact validation that was missing is inferred from behaviour rather than shown.

What it meant

A user of the application could obtain valid signatures for paths in the attachments bucket. Starting from the root listing, they could enumerate every document name and its exact path, then request signatures for those paths and download all documents stored in the bucket, including other users' documents. The report does not state how sensitive those documents were or how many users were affected. The client fixed it within a week due to its criticality.

The fix

A fix would need to bind the signed key to the requesting user's own documents, reject keys that do not resolve to a single object the user owns, and stop the bucket from serving directory listings.

Things worth trying on a similar target

  1. Empty or root-like keys: send the key parameter empty, as /, or as a prefix without a file name. A positive result is a signature that resolves to a listing or to objects outside your own uploads.
  2. Path traversal in the key: use ../ sequences or absolute-style paths inside the key value. A positive result is a signed URL for an object outside your own prefix.
  3. Other users' keys: take a key observed in a listing or guessed from a predictable pattern and request a signature for it. A positive result is a downloadable document you do not own.
  4. Parameter stripping: remove every field except the key, as done here, and see whether the back end still signs. A positive result shows the other fields were never part of the authorisation decision.
  5. Bucket listing: request the signed root URL from a browser or client and check for an XML or HTML listing of keys. A positive result exposes document names and paths.
  6. Version and operation fields: change S3TmpVersion or the operation name to values for other objects or actions. A positive result is a signature for an operation or object the user should not be able to request.

Glossary

  • API: a defined way for one piece of software to ask another to do something, like a service counter with set forms and rules.
  • Authentication: proving who you are.
  • Authorisation: deciding whether you are allowed to do a particular thing.
  • AWS: Amazon Web Services, Amazon's cloud platform of rented computing and storage.
  • Back end: the part of a website that runs on the server, out of sight of the browser.
  • Bucket: a named top-level container in S3 that holds objects (files).
  • CDN: content delivery network, a service that stores and serves files close to users for speed.
  • Directory listing: a page that shows the names of everything in a folder instead of a single file.
  • Endpoint: a specific address on a server that performs one job.
  • JSON: a text format for labelled values inside curly braces, used to send structured data.
  • Key (S3): the path and file name of an object inside a bucket.
  • Object: a stored file in S3.
  • Parameter: a named value sent with a request, like a field on a form.
  • Payload: the main body of data sent in a request; here, the JSON block describing the document.
  • RCE (remote code execution): a bug where an attacker gets the server to run code the attacker wrote.
  • Root directory: the top level of a storage bucket, containing everything else.
  • S3: Amazon's Simple Storage Service, cloud file storage.
  • Signature (AWS Signature Version 4): a cryptographic stamp made with a secret key, proving a request or link was produced by the holder of that key.
  • Signed URL: a web address carrying such a signature, so the storage service accepts it.
  • Synack: a platform where organisations invite researchers to test their systems and pay for confirmed findings.
  • URL: a web address.
  • URL encoding: writing characters in a web address as percent codes so they are transmitted safely.
  • URL decoding: turning those percent codes back into readable characters.

More by Ozgur Alp

View all

6 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.