Repository navigation
Closed
Labels
Description
Summary
The object route ignores the query string and S3's operation headers. As a result, PutObjectTagging and PutObjectAcl replace the object's bytes with the request's XML body, and DeleteObjectTagging deletes the object. CopyObject answers 200 but writes an empty object. Standard clients make these calls routinely. aws s3 mv is CopyObject followed by DeleteObject, so a move leaves an empty destination and deletes the source.
Classification
- Type: Bug
- Severity: High
- Verification: Verified (Runtime)
- Location:
crates/protocol-s3/src/server.rs:45-64(router),crates/protocol-s3/src/handlers.rs:63-85(put_object),:139-149(delete_object),:185-234(list_objects)
Reproduction / Context
Start the server with spacectl serve-s3 --port 8080, then:
| Request | Response | Effect |
|---|---|---|
PUT /b1/hello.txt?tagging with a <Tagging> body |
200 |
hello.txt now contains the <Tagging> XML |
PUT /b1/hello.txt?acl with <AccessControlPolicy/> |
200, new ETag |
object replaced by <AccessControlPolicy/> |
DELETE /b1/hello.txt?tagging |
204 |
object deleted; the next GET is NoSuchKey |
PUT /b1/dst.txt with x-amz-copy-source: /b1/src.txt |
200 |
dst.txt is 0 bytes |
GET /b1/hello.txt?tagging |
200 |
returns the object body |
GET /b1?location |
200 |
returns a ListBucketResult |
boto3 1.43.94 (path-style) shows the same results:
put_object_tagging()succeeds, andget_object()then returnsb'<Tagging xmlns="http://s3.amazonaws.com/doc/2006-03-01/">...'.copy_object()succeeds, and the copy reads back asb''.
Methods with no route get an empty-bodied response instead of an S3 <Error>, so SDKs report a bare ClientError (405) Method Not Allowed with no code:
405forPOST /b1?deleteandPOST /b1/k?uploads.404forGET /andPUT /b1/.
Proposed Fix / Recommendation
- Add a guard (middleware or extractor) on both the bucket and object routes. It should reject any request whose query names an S3 subresource the server doesn't implement with
501,<Code>NotImplemented</Code>. Examples:acl,tagging,uploads,uploadId,partNumber,versionId,location,versioning,policy,cors,lifecycle,delete,restore,select,attributes. Build it as an allow-list of the parameters each handler understands, so subresources added later fail closed. - Reject
x-amz-copy-sourceon PUT withNotImplementeduntil CopyObject exists. A server-side read-and-rewrite would implement it cheaply, since the copy dedups to the same segments. - Add a fallback handler that returns S3 XML (
MethodNotAllowed/NotImplemented) for unmatched routes and methods. - Add a regression test for each row of the table above.
Activity
Document which S3 operations return NotImplemented