Skip to content
IDOR Write-up Intermediate

How a Simple File Download Bug Turned Into an S3 Signing Oracle

The file download feature accepted a client-supplied S3 object key and authorised it only by checking that the key started with the caller's tenant ID, then used the application's own AWS credentials to create a presigned URL for that key. An attacker could craft a key that passed the prefix check but resolved to another tenant's object, causing the server to sign access to files they did not own.

medium.com

Published on medium.com

Bug Bounty

redhunter01, 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. 8 min read.

Context

A multi-tenant application had a file download feature. When a user asked to download a file, the browser sent the storage key of the object to the server, and the server generated an S3 presigned URL for it. The bucket itself was private, and the application had an authorization check in front of the signing step.

The write-up is about that check: it compared the beginning of the client-supplied key against the caller's client ID, and the researcher found that this prefix comparison was not an ownership check. The result was a signing oracle: an endpoint that would use the application's own AWS credentials to sign a request for an object the caller should not be able to reach.

Setup

The report does not describe the program, the tooling, or any versions. What it does establish is the precondition: two tenants, with the researcher logged in as one of them. The researcher's client ID throughout the write-up is:

Text
client123

The other tenant's prefix used in testing is:

Text
client999

No accounts beyond these are described, and no special roles or tooling are named.

Finding it

The researcher started on the upload side of the file feature, checking the usual properties:

Text
File extensionMIME typeFilenameFile sizeOverwrite behaviorUpload location

Uploads looked secure. Rather than stopping there, the researcher moved to the other operations a file feature exposes:

Text
Upload   ↓View   ↓Download   ↓Delete   ↓Share

On download, the request body contained the real storage key:

Text
{  "fileKey": "client123_abc123.pdf"}

That raised the obvious design question: why is the browser telling the server which S3 file to download? A safer design would send an identifier and let the backend resolve it:

Text
{  "documentId": "12345"}

with the backend doing:

Text
documentId     ↓Find document in database     ↓Check that user owns it     ↓Get real S3 key     ↓Generate download URL

This application instead did:

Text
Browser sends S3 key        ↓Server checks key        ↓Server signs key

The authorization check the server applied looked like this:

Text
if not file_key.startswith(current_user.client_id):    reject()

So with a client ID of client123, this was allowed:

Text
client123_invoice.pdf

and this was blocked:

Text
client999_invoice.pdf

The check answers "does this text begin with client123?" and not "does this file belong to client123?". Those are different questions, and the gap between them is the bug.

Exploitation

Step 1: map the normal responses

Before attempting a bypass, the researcher established what each failure looks like, so that any later deviation could be attributed to a specific layer.

Test 1, no login. The request was sent without authentication and returned:

Text
401 Unauthorized

Authentication was working.

Test 2, another client's prefix. Logged in as client123, the researcher requested:

Text
client999_document.pdf

The server rejected it. The prefix check was real.

Test 3, own prefix with a non-existent file. The researcher requested:

Text
client123_file-does-not-exist.pdf

The prefix was valid, so the application accepted the request, and because the object did not exist the storage layer returned something like:

Text
404 Not Found

That third result is the important one: a 404 means the request got past the application's authorization check and reached the storage lookup. The response map now looked like this:

Text
No login   ↓401
Text
Wrong client prefix   ↓Rejected by application
Text
Correct prefix   ↓Application accepts request   ↓S3/file lookup happens   ↓404 if file doesn't exist

Any key that produced the second path (accepted, then storage lookup) rather than the first (rejected) would demonstrate that the authorization check had been bypassed. The report offers this as a useful hunting technique: understand the normal rejection first, then test the bypass.

Step 2: the prefix check versus the final value

The candidate key the researcher reasoned about was:

Text
client123/../client999/private.pdf

The text begins with client123, so a prefix check says:

Text
Allowed

But if another part of the application later processes the path differently, the value can resolve outside client123:

Text
Server checks:
Text
client123/../client999/private.pdf^^^^^^^^^looks valid
Text
Path is interpreted differently              ↓client999/private.pdf

The lesson is not "try ../ everywhere". The lesson is that the value being checked must be the same final value being accessed. When the server checks one version of the path and later uses another, authorization breaks.

Step 3: the signing step

The application did not stream the file back. It generated an S3 presigned URL: a temporary link that tells AWS to allow whoever holds it to access the object, created with the backend's own AWS permissions. The flow was:

Text
User controls fileKey        ↓Application checks fileKey        ↓Application creates presigned URL        ↓AWS trusts the signature        ↓File becomes downloadable

Because the attacker controls the key that gets signed, the endpoint behaves as a signing oracle. Think of the server as holding a stamp reading

Text
THIS FILE IS ALLOWED TO BE DOWNLOADED

and the question is whether an attacker can make it stamp a file that is not theirs. No AWS credentials are needed, the bucket does not need to be public, and the only requirement is that the application signs the wrong object.

Root cause

The root cause is the combination of three things:

Text
User-controlled S3 key        +weak prefix authorization        +trusted S3 presigner

The server trusted the browser to choose the real storage key, validated it with a string prefix comparison, and then signed whatever value it ended up using with its own credentials. The researcher describes the bug as a mismatch between the value checked and the value finally used:

Text
User input   ↓Application checks it   ↓Application modifies or normalizes it   ↓Application signs the final value

The bug exists when the value checked differs from the value finally used. Calling it "path traversal in fileKey" does not capture the full problem, because the payload is only one way to reach the mismatch.

S3 does not behave like a normal filesystem, so S3 + ../ is not automatic traversal. The vulnerability depends entirely on what the application does with the key.

The existing defences did not stop it. Authentication worked (401 without a session). The prefix check worked for a plainly foreign key. The bucket was private. None of that matters once the application can be induced to sign an object outside the caller's namespace, because AWS sees a request signed with the application's own trusted credentials.

Impact

The report frames the impact as a bug that could let one tenant access another tenant's files. The report frames this as "could let one tenant access another tenant's files".

A private bucket does not prevent this, because the application itself has permission to read the bucket and AWS treats the presigned URL as an authorized request:

Text
Attacker   ↓Chooses file key   ↓Application   ↓Uses trusted AWS credentials   ↓Creates signed URL   ↓Private file

The real security boundary becomes whether the application can be tricked into signing the wrong file. The report does not state which specific objects were successfully retrieved, nor a severity or bounty.

Fix

The report describes the correct design rather than a specific patch that was applied. The bad design:

Text
Browser   ↓fileKey   ↓startswith(clientId)   ↓presign fileKey

The better design:

Text
Browser   ↓documentId   ↓Database lookup   ↓Check document belongs to user/team   ↓Get S3 key from database   ↓presign trusted key

The difference: the user chooses the document, and the server chooses the S3 object. The user should never decide which S3 key gets signed.

A safer backend, as sketched in the report, replaces this:

Text
file_key = request.json["fileKey"]
Text
if not file_key.startswith(current_user.client_id):    raise Unauthorized()return create_presigned_url(file_key)

with a lookup scoped to the caller's team:

Text
document_id = request.json["documentId"]
Text
document = db.documents.find_one(    id=document_id,    team_id=current_user.team_id)if document is None:    raise NotFound()return create_presigned_url(    document.storage_key)

If an old API must keep accepting fileKey, the entire value should be validated with a strict pattern. For a filename of the form client123_abcd1234.pdf, the report gives this conceptually:

Text
^client123_[a-f0-9-]+\.(pdf|png|jpg|jpeg|docx|txt)$

meaning the value must start with the correct client ID, contain the expected random ID, carry an allowed extension, and allow nothing extra. Things like ../, backslashes, extra path segments and unexpected characters must be rejected. This is still weaker than a server-side document ID.

As a second layer, IAM permissions should be scoped per tenant. If the bucket holds:

Text
tenant-a/tenant-b/tenant-c/

the backend serving tenant A should be allowed to read only tenant-a. Then a bug in the application still hits an AWS-level denial for tenant-b. Two doors: application authorization and AWS IAM permission. If the first fails, the second should still help. A single string comparison should never be the only thing protecting an entire bucket.

Variants to test

When testing file downloads, look for parameters such as:

Text
fileKeyobjectKeystorageKeypathfilePathblobNamedocumentPathdownloadKeyresourceKey

If one is present, ask whether that value directly controls which cloud object is accessed. If it does, keep digging. The same pattern appears outside S3: Azure Blob Storage, Google Cloud Storage, CDN signed URLs, temporary download tokens, file export systems, backup downloads and attachment APIs. The question is always whether you can control what resource the trusted server authorizes.

A reusable methodology, with what a positive result looks like at each step:

  1. Download your own file normally. Capture the request and find the parameter that identifies the file, for example { "fileKey": "client123_file.pdf" }. Positive result: you know exactly which value the server signs.
  2. Remove authentication. A 401 tells you what an authentication failure looks like, so you can distinguish it from an authorization failure later.
  3. Change the tenant or client prefix. A rejection tells you what an authorization failure looks like. Positive result: a foreign prefix that is not rejected.
  4. Use your own prefix with a fake filename. A 404 suggests the authorization check passed and the storage lookup ran. Positive result: the 404 path, which is the path a bypass must follow.
  5. Study how the server handles the key. Ask whether it is normalised, decoded, joined with another path, modified, or passed directly to an SDK. You are looking for a difference between the key checked and the key used. Positive result: any transformation between validation and signing.
  6. Test only inside program rules. Use controlled test accounts and files where possible. One clean proof is normally enough.
  7. Stop after proving the bug. Do not download random documents; more access adds risk, not report quality.

A useful mental model for any presigned URL endpoint:

Text
ATTACKER   ↓"Please sign this resource"   ↓SERVER   ↓"Are you allowed?"   ↓AWS CREDENTIALS   ↓SIGNED URL

Ask how good the "Are you allowed?" check is. If the answer is startswith(...), it is worth investigating.

The final rule: the user should choose the document they want, and the server should choose the storage key. If the user can choose what the backend signs, investigate who decides whether that resource really belongs to them.

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

What happened, in plain words

A website stored files for several different companies in the same cloud storage service. Each company is called a tenant: a separate customer whose data should be kept apart from everyone else's. When someone clicked a download button, their browser told the server exactly which file to fetch, and the server created a temporary download link for that file using its own cloud credentials. The cloud storage was private, so nobody could open the files directly. The server also had a check that was supposed to stop one company from downloading another company's files.

That check was the problem. It only looked at the beginning of the file name the browser sent. If the name started with your company's ID, the server said yes. It never asked whether the file actually belonged to you. The researcher who wrote this report found that this beginning-of-the-name check is not the same thing as an ownership check, and that the bug could let one tenant access another tenant's files. Because the server used its own trusted cloud credentials to create that link, the cloud service would treat it as an authorised request. The researcher calls this a signing oracle: a server that will put its official stamp on whatever file you ask it to, as long as you phrase the request the right way.

This article walks through the whole story in the same order as the original write-up, explaining every term from scratch along the way.

The setup

The report does not name the bug bounty program, the tools used, or any software versions. What it does tell us is the starting position: there were at least two tenants, and the researcher was logged in as one of them. Throughout the write-up, the researcher's own client ID (the short identifier for their company account) is:

Text
client123

This is just a label the application uses to know which company you belong to. The other tenant's prefix, used when testing whether the server would let the researcher reach someone else's files, is:

Text
client999

No other accounts, special roles or tools are mentioned. Two tenants and a normal login are all you need to follow along.

Finding it

Starting on the upload side

The researcher began with the part of the file feature where users upload files, not download them. The properties checked were the usual ones:

Text
File extensionMIME typeFilenameFile sizeOverwrite behaviorUpload location

Line by line, in plain words:

  • File extension: the ending of a file name, such as .pdf or .jpg. Applications often check it to decide what kind of file is being uploaded.
  • MIME type: a label the browser attaches to a file saying what type it believes the file is, for example application/pdf. It is a claim, not proof, because the browser or an attacker can set it.
  • Filename: the name of the file itself. Strange characters in a name can sometimes confuse the software that stores it.
  • File size: how large the file is. Applications often limit this to stop people filling up storage.
  • Overwrite behaviour: what happens if you upload a file with the same name as one that already exists. Does it replace the old one, or refuse? Replacing someone else's file would be a problem.
  • Upload location: where on the server or in cloud storage the file ends up. If you can influence this, you might be able to place a file somewhere you should not.

Uploads looked secure. Nothing interesting turned up. Many people testing a site would stop at this point and move on to a different feature. But a file feature has more than one side to it. The report lays out the full set of operations:

Text
Upload   ↓View   ↓Download   ↓Delete   ↓Share

Each arrow means "and then there is also". A file can be uploaded, viewed, downloaded, deleted and shared. Each of those is a separate piece of code with its own checks, and a weakness in any one of them is a weakness in the product. So the researcher moved on to download, and that is where things got interesting.

The browser was choosing the file

When the researcher downloaded a file normally, they looked at the request the browser sent to the server. A request is simply the message your browser sends when you click something: it says what you want and carries any data needed to fulfil it. The request contained something like:

Text
{  "fileKey": "client123_abc123.pdf"}

This is a small piece of data in a format called JSON, which is just a way of writing labelled values. Reading it line by line:

  • The outer curly braces { and } mark the start and end of one object, a bundle of labelled values.
  • "fileKey" is the label, called a key. It is the name of the piece of information being sent.
  • The colon : separates the label from its value.
  • "client123_abc123.pdf" is the value: the actual file name. It starts with the tenant ID client123, then an underscore, then a random-looking part abc123, then the extension .pdf.

So the browser was telling the server the exact name of the file in cloud storage. That raised an obvious design question, which the report states directly: why is the browser telling the server which S3 file to download?

S3 here means Amazon Simple Storage Service, Amazon's cloud file storage. You can think of it as a huge online filing cabinet. Every file in it has a name, called a key, and if you know the key and have permission, you can fetch the file. The application stores its users' files in one of these cabinets, called a bucket.

A safer design would have the browser send an identifier for the document, not the storage name:

Text
{  "documentId": "12345"}

Here the label is documentId and the value is 12345, a simple number. The browser is saying "give me document number 12345", not "give me the file stored under this exact name". The difference matters because the server can look up document 12345 in its own records and see who owns it. The backend would then do this:

Text
documentId     ↓Find document in database     ↓Check that user owns it     ↓Get real S3 key     ↓Generate download URL

Reading the arrows in order: the server receives the document number, looks it up in its database (its own organised store of records), checks that the logged-in user owns that document, retrieves the real storage key from its own records, and only then creates the download link. At no point does the browser get to say which storage file is used. The server decides.

This application did something different:

Text
Browser sends S3 key        ↓Server checks key        ↓Server signs key

The browser sends the storage key, the server checks that key, and then the server signs it. Signing, explained properly below, means using the server's own cloud credentials to vouch for the file. The browser is in charge of which file gets fetched, and the server only applies a check before agreeing.

The check the server applied

The server did have a check. It looked like this:

Text
if not file_key.startswith(current_user.client_id):    reject()

Line by line:

  • if not means "if the following is not true".
  • file_key.startswith(current_user.client_id) asks a yes-or-no question: does the text in file_key begin with the text in current_user.client_id? file_key is the value the browser sent. current_user.client_id is the ID of the company the logged-in user belongs to, which the server knows from the session.
  • The colon : at the end means "then do the following".
  • reject() means refuse the request.

So the whole thing reads: if the file name does not begin with your company's ID, refuse. Otherwise, carry on.

With a client ID of client123, this file was allowed:

Text
client123_invoice.pdf

It begins with client123, so the check passes. And this one was blocked:

Text
client999_invoice.pdf

It begins with client999, which is not client123, so the check fails and the request is refused.

At first glance this looks reasonable. But look at the two questions the check could be answering. It answers "does this text begin with client123?" It does not answer "does this file belong to client123?" Those are different questions, and the gap between them is the bug. A file name can begin with your company's ID and still, after the application processes it further, point at a file that belongs to someone else.

Exploitation

Step 1: map the normal responses

Before trying to get around the check, the researcher worked out what each normal failure looks like. This is a core habit in security testing: if you do not know what a refusal looks like, you cannot tell a successful bypass from an ordinary error. The report calls this understanding the normal rejection first, then testing the bypass.

Test 1, no login. The request was sent without authentication. Authentication means proving who you are, normally by logging in and receiving a session cookie or token. A cookie is a small piece of data your browser stores and sends back with each request so the server recognises you; a token is a similar string, often sent in a header instead. Sending the request without any of that is like walking up to a counter without your membership card. The result was:

Text
401 Unauthorized

A 401 is an HTTP status code. HTTP is the language browsers and servers use to talk, and every response carries a three-digit number saying roughly how it went. 401 means "you are not authenticated": the server does not know who you are. Getting a 401 confirmed that authentication was working. If the request had succeeded without a login, that would have been a much bigger and simpler bug.

Test 2, another client's prefix. Still logged in as client123, the researcher asked for:

Text
client999_document.pdf

This is a file name beginning with the other tenant's ID. The server rejected it. That told the researcher the prefix check was real and was actually running. It was not a check that existed only in the documentation.

Test 3, own prefix with a non-existent file. The researcher then asked for:

Text
client123_file-does-not-exist.pdf

The prefix client123 is valid, so the application accepted the request. But the file does not exist in storage, so the storage layer returned something like:

Text
404 Not Found

A 404 means "I looked, and there is nothing there". That third result is the important one. A 404 means the request got past the application's authorization check and reached the storage lookup. Authorization means deciding whether you are allowed to do something, as opposed to authentication, which is deciding who you are. The server believed the request was allowed, went looking for the file, and found nothing.

The response map now looked like this:

Text
No login   ↓401

No login leads to a 401. Then:

Text
Wrong client prefix   ↓Rejected by application

A wrong prefix leads to a rejection by the application itself, before storage is ever consulted. And:

Text
Correct prefix   ↓Application accepts request   ↓S3/file lookup happens   ↓404 if file doesn't exist

A correct prefix leads to acceptance, then a storage lookup, then a 404 if the file is not there. The researcher now had a map of the backend: which layer produces which response. Any key that produced the second path, accepted and then looked up in storage, rather than the first path, rejected outright, would demonstrate that the authorization check had been bypassed. That is the whole point of mapping the responses first: it turns a vague "I got a different response" into a precise claim about which layer was reached.

Step 2: the prefix check versus the final value

The candidate key the researcher reasoned about was:

Text
client123/../client999/private.pdf

This needs unpacking. The text is a path, a sequence of folder names separated by slashes, like the address of a file. Reading it left to right:

  • client123 is the first folder name, the researcher's own tenant.
  • /.. means "go up one level", back to the parent folder. In many systems, .. is a special name meaning the folder above the current one.
  • /client999 is then a folder name, the other tenant.
  • /private.pdf is the file name at the end.

So the path starts inside client123, steps back out, and then goes into client999. The text begins with client123, so a prefix check says:

Text
Allowed

But if another part of the application later processes the path differently, the value can resolve outside client123. The report shows the check first:

Text
Server checks:

Then the value the server is looking at:

Text
client123/../client999/private.pdf^^^^^^^^^looks valid

The carets ^^^^^^^^^ are just an underline drawn under the beginning of the string, pointing out the part the check examines. The check sees client123 at the start and is satisfied. Then the report shows what happens later:

Text
Path is interpreted differently              ↓client999/private.pdf

If some later part of the application treats .. as "go up a level", the path no longer points inside client123. It points at client999/private.pdf. The value that was checked and the value that was used are not the same value, and that difference is the vulnerability.

The lesson is not "try ../ everywhere". The lesson is that the value being checked must be the same final value being accessed. When the server checks one version of the path and later uses another, authorization breaks. The .. is just one way to make the two versions differ.

Step 3: the signing step

The application did not stream the file back itself. Instead it generated an S3 presigned URL. A presigned URL is a temporary link that tells AWS, Amazon Web Services, to allow whoever holds it to access a particular object. The server creates it using its own AWS permissions, which are the rights the application has been granted in the cloud account. Think of it as a signed permission slip: the server writes "let the bearer have this file", signs it with its own authority, and hands it over. Anyone holding the slip can use it until it expires.

The flow was:

Text
User controls fileKey        ↓Application checks fileKey        ↓Application creates presigned URL        ↓AWS trusts the signature        ↓File becomes downloadable

Reading it in order: the user controls the file key, the application checks that key, the application creates a presigned URL, AWS trusts the signature because it came from the application, and the file becomes downloadable. The weak link is the first arrow. Because the attacker controls the key that gets signed, the endpoint behaves as a signing oracle. An oracle, in this context, is something that will answer a question for you. Here the question is "please sign this file", and the server answers with a valid signature.

Think of the server as holding a stamp reading:

Text
THIS FILE IS ALLOWED TO BE DOWNLOADED

Normally the server should only stamp files that belong to the current user. The question is whether an attacker can make it stamp a file that is not theirs. If they can, the server is a signing oracle. No AWS credentials are needed by the attacker, the bucket does not need to be public, and the only requirement is that the application signs the wrong object.

Root cause

The root cause is the combination of three things:

Text
User-controlled S3 key        +weak prefix authorization        +trusted S3 presigner

Line by line:

  • User-controlled S3 key: the browser, and therefore the user, decides which storage file name is used.
  • Weak prefix authorization: the only check is whether that name begins with the right tenant ID, which is not the same as checking ownership.
  • Trusted S3 presigner: the server then uses its own trusted cloud credentials to sign whatever value it ended up with.

Any one of these alone might be survivable. Together they mean the server will vouch for a file the user should not be able to reach. The researcher describes the bug as a mismatch between the value checked and the value finally used:

Text
User input   ↓Application checks it   ↓Application modifies or normalizes it   ↓Application signs the final value

Reading the arrows: the user supplies input, the application checks it, the application modifies or normalises it, and the application signs the final value. Normalising means tidying a value into a standard form, for example resolving .. segments or decoding encoded characters. The bug exists when the value checked differs from the value finally used. Calling it "path traversal in fileKey" does not capture the full problem, because the payload is only one way to reach the mismatch. Path traversal is the general name for tricks that make a file path escape its intended folder; here it is a symptom, not the cause.

S3 does not behave like a normal filesystem, so S3 + ../ is not automatic traversal. The vulnerability depends entirely on what the application does with the key. If the application passes the key straight through without interpreting .., nothing happens. If it interprets the key somewhere along the way, the checked value and the used value can diverge.

The existing defences did not stop it. Authentication worked, since a request without a session got a 401. The prefix check worked for a plainly foreign key. The bucket was private. None of that matters once the application can be induced to sign an object outside the caller's namespace, because AWS sees a request signed with the application's own trusted credentials. A namespace here is the set of names belonging to one tenant; staying inside your namespace means only touching your own files.

Impact

The report frames the impact as a bug that could let one tenant access another tenant's files. The report frames this as "could let one tenant access another tenant's files".

A private bucket does not prevent this, because the application itself has permission to read the bucket, and AWS treats the presigned URL as an authorised request:

Text
Attacker   ↓Chooses file key   ↓Application   ↓Uses trusted AWS credentials   ↓Creates signed URL   ↓Private file

Reading the arrows: the attacker chooses the file key, the application uses its trusted AWS credentials, creates a signed URL, and the private file is handed over. The bucket can stay perfectly private the whole time. The application itself becomes the problem, because it is the one holding the keys.

The real security boundary becomes whether the application can be tricked into signing the wrong file. The report does not state which specific objects were successfully retrieved, nor a severity or a bounty amount.

Fix

The report describes the correct design rather than a specific patch that was applied. The bad design:

Text
Browser   ↓fileKey   ↓startswith(clientId)   ↓presign fileKey

The browser sends the file key, the server checks it with startswith against the client ID, and then signs that same file key. The better design:

Text
Browser   ↓documentId   ↓Database lookup   ↓Check document belongs to user/team   ↓Get S3 key from database   ↓presign trusted key

The browser sends a document ID, the server looks it up in the database, checks that the document belongs to the user or their team, gets the S3 key from the database, and signs that trusted key. The difference is simple to state: the user chooses the document, and the server chooses the S3 object. The user should never decide which S3 key gets signed.

A safer backend, as sketched in the report, replaces this:

Text
file_key = request.json["fileKey"]

This line takes the value labelled fileKey out of the request and stores it in a variable called file_key. request.json means the request body, read as JSON. Then:

Text
if not file_key.startswith(current_user.client_id):    raise Unauthorized()return create_presigned_url(file_key)

Line by line: if the file key does not start with the current user's client ID, raise an Unauthorized error, which stops the request. Otherwise, return a presigned URL created for that file key. The flaw is that the key being signed is the one the browser supplied.

The replacement starts with:

Text
document_id = request.json["documentId"]

This takes the value labelled documentId from the request and stores it in document_id. Then:

Text
document = db.documents.find_one(    id=document_id,    team_id=current_user.team_id)if document is None:    raise NotFound()return create_presigned_url(    document.storage_key)

Line by line: look up one document in the database where the ID matches the requested document ID and the team ID matches the current user's team. If no such document is found, raise a NotFound error. Otherwise, create a presigned URL for the storage key recorded on that document. The user can only ask for documents their own team owns, and the storage key comes from the server's records, not from the browser.

If an old API must keep accepting fileKey, the entire value should be validated with a strict pattern. For a filename of the form client123_abcd1234.pdf, the report gives this conceptually:

Text
^client123_[a-f0-9-]+\.(pdf|png|jpg|jpeg|docx|txt)$

This is a regular expression, a compact way of describing exactly what a string is allowed to look like. Reading it piece by piece:

  • ^ means the match must start at the very beginning of the string.
  • client123_ is literal text that must appear exactly.
  • [a-f0-9-]+ means one or more characters, each of which must be a letter from a to f, a digit from 0 to 9, or a hyphen. The plus sign means "one or more".
  • \. is a literal dot. The backslash removes the dot's special meaning in this syntax.
  • (pdf|png|jpg|jpeg|docx|txt) means exactly one of those extensions. The vertical bars mean "or".
  • $ means the match must end at the very end of the string.

Together this means the value must start with the correct client ID, contain the expected random ID, carry an allowed extension, and allow nothing extra. Things like ../, backslashes, extra path segments and unexpected characters must be rejected. This is still weaker than a server-side document ID.

As a second layer, IAM permissions should be scoped per tenant. IAM stands for Identity and Access Management, the part of AWS that decides which credentials may do what. If the bucket holds:

Text
tenant-a/tenant-b/tenant-c/

three folders, one per tenant, then the backend serving tenant A should be allowed to read only tenant-a. Then a bug in the application still hits an AWS-level denial for tenant-b. The report describes this as two doors: application authorization and AWS IAM permission. If the first fails, the second should still help. A single string comparison should never be the only thing protecting an entire bucket. This idea of giving each part of a system only the access it needs is called least privilege.

Variants to test

When testing file downloads, look for parameters such as:

Text
fileKeyobjectKeystorageKeypathfilePathblobNamedocumentPathdownloadKeyresourceKey

These are names you might see in a request body or URL. Each one suggests the browser is naming a file or storage location. If one is present, ask whether that value directly controls which cloud object is accessed. If it does, keep digging. The same pattern appears outside S3: Azure Blob Storage, Google Cloud Storage, CDN signed URLs, temporary download tokens, file export systems, backup downloads and attachment APIs. A CDN is a content delivery network, a set of servers that cache and serve content close to users. The question is always whether you can control what resource the trusted server authorises.

A reusable methodology, with what a positive result looks like at each step:

  1. Download your own file normally. Capture the request and find the parameter that identifies the file, for example { "fileKey": "client123_file.pdf" }. Positive result: you know exactly which value the server signs.
  2. Remove authentication. A 401 tells you what an authentication failure looks like, so you can distinguish it from an authorisation failure later.
  3. Change the tenant or client prefix. A rejection tells you what an authorisation failure looks like. Positive result: a foreign prefix that is not rejected.
  4. Use your own prefix with a fake filename. A 404 suggests the authorisation check passed and the storage lookup ran. Positive result: the 404 path, which is the path a bypass must follow.
  5. Study how the server handles the key. Ask whether it is normalised, decoded, joined with another path, modified, or passed directly to an SDK. An SDK is a software development kit, a library of code that makes it easy to talk to a service such as S3. You are looking for a difference between the key checked and the key used. Positive result: any transformation between validation and signing.
  6. Test only inside program rules. Use controlled test accounts and files where possible. One clean proof is normally enough.
  7. Stop after proving the bug. Do not download random documents; more access adds risk, not report quality.

A useful mental model for any presigned URL endpoint:

Text
ATTACKER   ↓"Please sign this resource"   ↓SERVER   ↓"Are you allowed?"   ↓AWS CREDENTIALS   ↓SIGNED URL

The attacker asks the server to sign a resource. The server asks itself whether the attacker is allowed. Then it uses its AWS credentials and returns a signed URL. Ask how good the "Are you allowed?" check is. If the answer is startswith(...), it is worth investigating.

The final rule: the user should choose the document they want, and the server should choose the storage key. If the user can choose what the backend signs, investigate who decides whether that resource really belongs to them.

Glossary

  • API: the set of requests a service accepts, and the format of the answers it gives back. It is how one piece of software asks another to do something.
  • Authentication: proving who you are, usually by logging in. A request without it gets a 401.
  • Authorisation: deciding whether the person who has been identified is allowed to do the thing they are asking for.
  • AWS: Amazon Web Services, Amazon's cloud platform, which includes S3 storage and IAM permissions.
  • Azure Blob Storage: Microsoft's cloud file storage service, a competitor to S3.
  • Bucket: a container in cloud storage that holds files. It can be private or public.
  • CDN: content delivery network, a set of servers that cache and serve content close to users.
  • Client ID: a short identifier the application uses to label which company or tenant an account belongs to.
  • Cookie: a small piece of data your browser stores and sends back with each request so the server recognises you.
  • Credentials: the keys or passwords that prove an application's identity to a cloud service.
  • Defence in depth: layering several independent protections so that if one fails, another still holds.
  • Document ID: an identifier for a document in the application's own database, as opposed to its name in storage.
  • File key: the name of a file inside cloud storage. Knowing it and having permission lets you fetch the file.
  • Google Cloud Storage: Google's cloud file storage service, a competitor to S3.
  • HTTP: the language browsers and servers use to exchange requests and responses.
  • IAM: Identity and Access Management, the part of AWS that decides which credentials may do what.
  • JSON: a simple text format for labelled values, used to send data between browsers and servers.
  • Least privilege: giving each part of a system only the access it actually needs, and no more.
  • MIME type: a label saying what type a file is believed to be, such as application/pdf. It is a claim, not proof.
  • Multi-tenant: a single application serving several separate customers, called tenants, whose data should stay apart.
  • Namespace: the set of names belonging to one tenant. Staying inside your namespace means only touching your own files.
  • Normalisation: tidying a value into a standard form, for example resolving .. segments or decoding encoded characters.
  • Oracle: something that answers a question for you. A signing oracle answers "please sign this file" with a valid signature.
  • Path: a sequence of folder names separated by slashes, like the address of a file.
  • Path traversal: tricks that make a file path escape its intended folder, often using ...
  • Payload: the specific input used to trigger a bug. It is one way to reach the problem, not the problem itself.
  • Presigned URL: a temporary link created with the server's own cloud credentials that lets whoever holds it access a particular file.
  • Regular expression: a compact way of describing exactly what a string is allowed to look like.
  • Request: the message your browser sends when you click something, saying what you want and carrying any data needed.
  • S3: Amazon Simple Storage Service, Amazon's cloud file storage.
  • SDK: software development kit, a library of code that makes it easy to talk to a service such as S3.
  • Session: the server's memory of who you are across several requests, usually tracked with a cookie or token.
  • Signing: using the server's own cloud credentials to vouch for a file, producing a presigned URL.
  • Signing oracle: a server that will sign whatever file you ask it to, as long as you phrase the request the right way.
  • Status code: the three-digit number in every HTTP response saying roughly how it went, such as 401 or 404.
  • Tenant: one separate customer of a multi-tenant application, whose data should stay apart from other customers'.
  • Token: a string, often sent in a header, that proves your identity or grants access, similar in purpose to a cookie.
  • Vulnerability: a weakness in software that lets someone do something they should not be able to do.
  • 401 Unauthorized: the status code meaning "you are not authenticated".
  • 404 Not Found: the status code meaning "I looked, and there is nothing there".

Similar reports

View all

Same bug class and techniques, clearest first.

Insecure direct object reference (IDOR)

The lesson behind this report.

One user can read or change another user's data, usually by changing an identifier the server trusts without checking who is asking. One of the most paid bug classes on web programs.