Skip to content

Refuse S3 operations the server doesn't implement - #175

Merged
saworbit merged 3 commits into
mainfrom
protocol-s3/reject-unimplemented
Nov 13, 2026
Merged

saworbit merged 3 commits into
mainfrom
protocol-s3/reject-unimplemented

Conversation

@saworbit

Copy link
Copy Markdown
Owner

Description

S3 picks the operation from the query and headers as well as the method, but the handlers only looked at the method. So:

  • PutObjectTagging and PutObjectAcl replaced the object with the request's XML;
  • DeleteObjectTagging deleted the object;
  • CopyObject answered 200 and stored an empty object (and aws s3 mv is CopyObject then DeleteObject);
  • GET ?tagging and GET ?location returned the object or a listing;
  • unrouted operations got an empty 404 or 405 that SDKs couldn't read.

What changes:

  • Query allow-lists: each handler checks its query against the parameters it reads, plus presigned-URL authentication (SigV4 and SigV2) and the SDKs' x-id tag, which has to name that handler's operation. Anything else gets 501 <Code>NotImplemented</Code>, so subresources S3 adds later fail closed.
  • PUT headers: x-amz-copy-source is refused. So is an aws-chunked body, which would have been stored with its chunk framing.
  • Bucket configuration (PUT /{bucket}?versioning and the like) is refused and no longer creates the bucket.
  • Fallbacks: unrouted paths and methods (ListBuckets, DeleteBucket, DeleteObjects, multipart uploads) get a NotImplemented S3 error instead of an empty response.
  • GetBucketLocation is answered, not refused. GET /{bucket}?location returns an empty LocationConstraint (us-east-1). Clients that call it, such as the MinIO SDK, used to get a listing they read as "no constraint", so refusing it would have broken them. This departs from the issue's suggestion.
  • fetch-owner on ListObjectsV2 is accepted and ignored; there are no owners.
  • response-content-type and the other response-* overrides on GET are refused, as the issue proposed. A presigned link that sets them now gets 501 until they're implemented.

Tested with boto3 1.43.94 against a running serve-s3:

  • These still work: put_object, upload_fileobj, get_object, head_object, head_bucket, list_objects, the list_objects_v2 paginator (with FetchOwner too), get_bucket_location, download_file, a presigned GET and delete_object.
  • These now raise NotImplemented and leave the data untouched: put_object_tagging, copy_object, delete_objects, delete_bucket, list_buckets and create_multipart_upload.

Fixes #156

Type

  • Bug fix
  • New feature
  • Breaking change
  • Refactor / cleanup
  • Docs / comments only

Checklist

Quality gates

  • cargo fmt --all
  • cargo clippy --workspace --all-targets -- -D warnings
  • Tests pass (cargo test --workspace): 377 passed, 0 failed (2 of them new; unimplemented_operations_are_refused_not_misrun fails on main)
  • Docs compile: RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps

Documentation

  • I updated relevant docs (the S3 quick start already lists what isn't supported)
  • CHANGELOG.md updated

Security

  • No hardcoded secrets, tokens, or keys introduced
  • External inputs are validated (query parameters and copy and chunked-encoding headers on every S3 route)
  • No new unsafe blocks

Dependency changes (skip if none)

None.

Independent of #174. Both add a CHANGELOG line under Fixed, a couple of lines apart, so they should merge in either order.

S3 picks the operation from the query and headers as well as the
method, but the handlers only looked at the method. PutObjectTagging
and PutObjectAcl replaced the object with the request's XML,
DeleteObjectTagging deleted it, CopyObject answered 200 and stored an
empty object, and GET ?tagging or ?location returned the object or a
listing. Unrouted operations got an empty 404 or 405.

- Each handler checks its query against the parameters it reads, plus
  presigned-URL authentication (SigV4 and SigV2) and the SDKs' x-id
  tag, which must name the handler's operation. Anything else is
  501 NotImplemented, so subresources added later fail closed.
- PUT refuses x-amz-copy-source, and an aws-chunked body, which would
  have been stored with its chunk framing.
- PUT /{bucket}?versioning and the like no longer create the bucket.
- The router's fallbacks answer unrouted paths and methods (ListBuckets,
  DeleteBucket, DeleteObjects, multipart uploads) with a NotImplemented
  S3 error.
- GET /{bucket}?location answers GetBucketLocation with the default
  region. Clients that call it got a listing they read as "no
  constraint", so refusing it would have broken them.
- ListObjectsV2 accepts fetch-owner and ignores it; there are no owners.
- Tests: every row of the issue's table, plus bucket configuration and
  unrouted operations, is refused and leaves the store unchanged;
  presigned URLs, x-id, fetch-owner and ?location keep working.
- CHANGELOG entry.

Fixes #156
@saworbit saworbit added bug Something isn't working protocol-s3 labels Nov 13, 2026
The README and the S3 quick start list GetBucketLocation and presigned URLs among what works, and name the operations that now get 501 NotImplemented (#156): multipart upload, CopyObject, tagging, ACLs, bucket configuration, ListBuckets, DeleteBucket, DeleteObjects, response-* overrides and aws-chunked bodies.
@saworbit
saworbit merged commit b9416dd into main Nov 13, 2026
3 checks passed
@saworbit
saworbit deleted the protocol-s3/reject-unimplemented branch November 13, 2026 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working protocol-s3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] S3 requests for unimplemented operations run as plain PUT/DELETE and overwrite or delete objects

1 participant