S3 API implementation reference

This page describes how the S3 wire is built: the HTTP listener, SigV4 and the other ways a request is let in, the operation table, request and response handling, bucket features, storage and restart behaviour, errors, limits and tests. For the port, the proof scores, how to connect and how to re-run the differential suite, see the operator page S3. Authentication policy across all wires is in Security.

Code lives in src/protocol/s3/: mod.rs (listener, HTTP front end, operation parser, dispatch, object and bucket handlers, persistence, error mapping), auth.rs (credential registry, header and presigned SigV4 checks), features.rs (versioning, bucket policy, CORS, browser POST uploads), operations.rs (the S3Operation enum, request and response types) and storage.rs (the in-memory object store and lazy body loading). The shared SigV4 verifier is src/auth/aws_keys.rs. Crates that matter: hyper, hyper-util and http-body-util (HTTP/1.1), md5 (imported as md5_s3, ETags), hmac and sha2 (SigV4), base64 (body storage), chrono (dates, presign expiry) and serde_json (metadata, policies). (source: Cargo.toml; src/protocol/s3/mod.rs, imports)

Listener and HTTP handling

  • The default port is 9100 (s3_port). The server builds the handler with S3Handler::with_synergy_storage, or with_tls when a TLS config exists, always with S3Config::default(); there is no operator setting for the S3 config. (source: src/config.rs; src/server/mod.rs; src/protocol/s3/mod.rs, with_synergy_storage, with_tls, S3Config::default)
  • HTTP is served by hyper's http1::Builder::serve_connection, so keep-alive, pipelining and chunked transfer encoding are handled by hyper. (source: S3Handler::start)
  • With TLS configured, each socket goes through TlsListener::accept_auto, which looks at the first byte, so plain HTTP and TLS are both served on port 9100. (source: S3Handler::start; src/protocol/tls.rs, accept_auto) Not verified: no test covers S3 over TLS.
  • The whole request body is collected (req.collect()) before the operation is parsed or the signature checked, with no size cap at that point. The 5 GB object limit is checked afterwards. An unauthenticated client can therefore make the server buffer a large body. (source: handle_http_request; put_object, max_object_size) The security guide says the same.
  • Addressing is path-style only: the first path segment is the bucket and the rest, percent-decoded, is the key. The virtual_hosted_style: true field in S3Config is never read. (source: parse_s3_operation, S3Config)
  • An OPTIONS request is answered from the bucket's CORS rules without authentication, as browsers never sign a preflight. Every other response gets the matching CORS headers added. (source: handle_http_request; features.rs, cors_preflight, cors_actual_headers)
  • Each connection is recorded for audit as wire s3. (source: S3Handler::start, audit::in_connection)
  • Not cluster-aware: there is no replicated-write path or read-only check. (source: src/protocol/s3/, whole module) Not verified in cluster mode.

Authentication

dispatch decides how a request is let in, in this order. (source: src/protocol/s3/mod.rs, dispatch)

Request carries Check
Authorization header validate_signature: parse with the shared SigV4 parser, look up the access key, rebuild the canonical request from the real method, raw path and raw query, and verify with aws_keys::verify_sigv4 (15-minute clock skew, payload hash when x-amz-content-sha256 is a hex digest).
X-Amz-Signature= in the query, no header validate_presigned_request: algorithm AWS4-HMAC-SHA256, X-Amz-Expires from 0 to 604,800 seconds, not past X-Amz-Date plus X-Amz-Expires, signature over the query without X-Amz-Signature and payload UNSIGNED-PAYLOAD.
multipart/form-data POST to a bucket Let through to the handler, which verifies the form's POST policy and signature (verify_post_policy).
Nothing, but the bucket policy grants the action to "Principal": "*" Allowed for s3:GetObject (GET and HEAD object), s3:PutObject, s3:DeleteObject, s3:GetObjectTagging and s3:ListBucket (both list versions). A Deny statement wins; an Allow counts only if it has no Condition, NotAction, NotResource or NotPrincipal.
Nothing else Allowed only with SYNERGYDB_DEV_INSECURE_AUTH; otherwise 403 AccessDenied with the reason.

(source: dispatch; auth.rs, validate_signature, validate_presigned_request; features.rs, policy_allows_anonymous, policy_grants_anonymous, verify_post_policy; src/auth/aws_keys.rs, verify_sigv4)

Credentials. The registry holds the one key pair from SYNERGYDB_ACCESS_KEY_ID and SYNERGYDB_SECRET_KEY, or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. With an empty registry every signed request fails closed, unless the dev flag is set, in which case any access key is accepted without checking the signature. SynergyDB catalog roles are not used on this wire. (source: mod.rs, register_provisioned_credentials; auth.rs, validate_signature; src/auth/aws_keys.rs, provisioned_credential) Tested by test_empty_registry_fails_closed_without_dev_flag and test_credentials_management in auth.rs and test_unsigned_request_rejected_by_default in mod.rs.

Authorization. A request with a valid signature can do everything. S3Credentials has a CredentialPermissions field (including read_only) that is never checked, and signed requests are not evaluated against bucket policies; bucket policies only widen access for anonymous requests. Object and bucket ACLs are stored and returned but not enforced. (source: auth.rs, CredentialPermissions; dispatch; features.rs, policy_allows_anonymous)

The region and service in the credential scope are not compared with S3Config::region; validate_signature takes the region argument as _region and ignores it. (source: auth.rs, validate_signature)

Operations

parse_s3_operation maps method, bucket, key and query keys to an S3Operation, and dispatch runs it. The first matching row wins, in this order. (source: src/protocol/s3/mod.rs, parse_s3_operation, dispatch; operations.rs, S3Operation)

Method Target Query or header Operation
GET /   ListBuckets
GET, PUT, DELETE object tagging GetObjectTagging, PutObjectTagging, DeleteObjectTagging
GET bucket uploads ListMultipartUploads
GET object uploadId ListParts
GET, PUT object acl GetObjectAcl, PutObjectAcl (stores the canned x-amz-acl value)
GET, PUT bucket acl GetBucketAcl (fixed owner grant), PutBucketAcl (checks the bucket exists, stores nothing)
GET bucket location GetBucketLocation (us-east-1 as an empty constraint)
GET, PUT bucket versioning GetBucketVersioning, PutBucketVersioning
GET bucket versions ListObjectVersions
GET, PUT, DELETE bucket policy GetBucketPolicy, PutBucketPolicy, DeleteBucketPolicy
GET, PUT, DELETE bucket cors GetBucketCors, PutBucketCors, DeleteBucketCors
PUT bucket any other CreateBucket
DELETE bucket none DeleteBucket
HEAD bucket   HeadBucket
GET bucket any other List objects: V2 when list-type=2, else V1 (marker). Reads prefix, delimiter, continuation-token (V2), start-after (V2), max-keys, encoding-type=url.
PUT object x-amz-copy-source header CopyObject (?versionId= in the source; x-amz-metadata-directive COPY or REPLACE)
PUT object partNumber and uploadId UploadPart
PUT object otherwise PutObject
GET object   GetObject
DELETE object uploadId AbortMultipartUpload
DELETE object otherwise DeleteObject (versionId honoured)
HEAD object   HeadObject
POST bucket delete DeleteObjects (Quiet honoured)
POST bucket multipart/form-data body PostObject (browser upload)
POST object uploads CreateMultipartUpload
POST object uploadId CompleteMultipartUpload

Anything else is an internal error that the front end turns into 400 InvalidRequest. S3Operation::GeneratePresignedUrl exists but no HTTP request parses to it. (source: parse_s3_operation, handle_http_request)

Because unknown bucket sub-resources fall through, PUT /bucket?lifecycle (or ?tagging, ?encryption, ?notification) is handled as CreateBucket, which answers 200 for an existing bucket, so the client is told the setting was stored when nothing was; GET /bucket?lifecycle is answered as a listing. Neither is an error. Likewise a PUT with both x-amz-copy-source and partNumber (UploadPartCopy) is handled as CopyObject on the target key. (source: parse_s3_operation, create_bucket) Not verified: no test sends these requests.

Request and response details

  • Reads. GetObject and HeadObject honour versionId, partNumber, a single Range, and If-Match, If-Unmodified-Since, If-None-Match and If-Modified-Since in RFC 7232 order (412 or 304). response-content-type, response-content-disposition, response-content-encoding and response-content-language override the stored headers. (source: read_object)
  • Writes. Content-Type, Content-Encoding, Cache-Control, Content-Disposition, x-amz-meta-* and x-amz-tagging are kept with the object. Content-MD5 is not checked. (source: put_object, metadata_from_headers) Not verified against a client that sends Content-MD5.
  • Streaming uploads. No code decodes aws-chunked bodies (x-amz-content-sha256: STREAMING-AWS4-HMAC-SHA256-PAYLOAD); such a body would be stored with its chunk framing. (source: src/protocol/s3/, src/auth/aws_keys.rs, no handling of either name) Not verified: whether the clients in the proof suite send it.
  • ETags. MD5 of the body, quoted; a multipart object's ETag is the MD5 of the part MD5s followed by -<part count>. (source: storage.rs, md5_s3::compute, complete_multipart_upload)
  • Dates. Last-Modified is an RFC 7231 IMF-fixdate; XML timestamps are ISO 8601 with milliseconds and Z. (source: http_date, iso8601_ms) Tested by test_date_formats_match_aws and test_last_modified_wire_formats.
  • Listings. max-keys is capped at 1000. ListMultipartUploads and ListParts always answer MaxUploads or MaxParts 1000 with IsTruncated false and do not page. (source: list_objects, list_multipart_uploads, list_parts) Tested by test_prefix_listing_acl_and_single_content_type.
  • Errors carry <RequestId>request-id</RequestId>, a constant, not a per-request id. (source: error_response)

Bucket features

Feature Behaviour Source
Versioning Enabled and Suspended. Every write in an enabled bucket makes a version; a delete without versionId adds a delete marker (x-amz-delete-marker: true); a suspended bucket replaces the null version. Responses carry x-amz-version-id. features.rs, VersioningStatus; storage.rs
Bucket policy Stored as JSON; used only to admit anonymous requests, as in Authentication. features.rs, policy_grants_anonymous
CORS Rules stored per bucket; preflights and response headers built from them. features.rs, cors_preflight, cors_actual_headers
Browser POST upload multipart/form-data with a SigV4 POST policy (expiration and conditions checked), key with ${filename}, success_action_status, x-amz-meta-*. Without a signature it is allowed only if the policy grants anonymous s3:PutObject. features.rs, post_object, verify_post_policy

Tested by globs, public_read_policy and multipart_form in features.rs and the S3 differential suite.

Storage and restart

The object store is in memory (storage.rs) and each change is also written as SQL rows through the query engine. (source: src/protocol/s3/mod.rs, with_synergy_storage)

Table Columns Written by
_s3_buckets bucket_name (key), metadata (versioning, policy, CORS) Bucket create, delete and feature changes
_s3_objects bucket_name, object_key (key), object_data (base64 TEXT), metadata persist_object: one upsert per write
_s3_versions bucket_name, object_key, version_id (key), seq, object_data, metadata Versioned writes and delete markers
_s3_uploads upload_id (key), bucket_name, object_key, metadata, initiated CreateMultipartUpload
_s3_parts upload_id, part_number (key), part_data UploadPart

(source: with_synergy_storage, the CREATE TABLE statements; persist_object, persist_upload)

  • After a successful upsert the in-memory body is dropped (offload_object) and only a BodyRef stays; a read loads the body with one primary-key SELECT and a base64 decode (body_loader). If the upsert fails, a warning is logged and the client still gets a success reply, with the body kept only in memory. (source: persist_object, body_loader; storage.rs, offload_object, BodyRef)
  • At startup the five tables are read with visit_table_rows, which streams rows; object, version and part bodies are not kept, only BodyRefs. Rows saved before ETags were stored are hashed once at load. (source: with_synergy_storage, visit_table_rows) Tested by test_restart_reloads_bodies_without_holding_the_table and test_offloaded_bodies_in_versioned_buckets in mod.rs and the persistence_tests module of tests/protocol_s3.rs.
  • Bodies are stored base64 in a TEXT column, so the on-disk size is about four thirds of the object size, and every object read decodes its whole body even for a Range request. (source: persist_object, body_loader, read_object)
  • Multipart uploads in progress survive a restart. (source: persist_upload)

Not verified: whether the upsert is synced to disk before the reply; the proof suite's restart phase (14 checks) restarts the server cleanly.

Error replies

Errors are XML: <Error><Code>…</Code><Message>…</Message><RequestId>request-id</RequestId></Error> with Content-Type: application/xml. Handlers that build an S3ERR|status|code|message error get exactly that status and code (for example KeyTooLongError, EntityTooSmall, InvalidBucketName, PreconditionFailed). Other errors are mapped by map_error_to_s3: (source: src/protocol/s3/mod.rs, map_error_to_s3, error_response, s3e)

Code Status When
NoSuchBucket 404 Missing bucket.
NoSuchKey 404 Missing object or version.
NoSuchUpload 404 Unknown upload id.
BucketAlreadyOwnedByYou 409 Storage reports BucketAlreadyExists. CreateBucket itself answers 200 for a bucket that already exists (us-east-1 behaviour), so this is rarely seen.
BucketNotEmpty 409 DeleteBucket with objects.
EntityTooLarge 400 Object or part over 5 GB.
InvalidPartOrder, InvalidPart 400 Bad CompleteMultipartUpload list.
MalformedXML 400 Unparseable XML body.
SignatureDoesNotMatch 403 Signature mismatch.
InvalidAccessKeyId 403 Unknown access key.
AccessDenied 403 Any other authentication failure (message gives the reason), permission errors.
InvalidRequest 400 Operation not recognised.
InternalError 500 Anything else.

Tested by test_s3_error_to_xml in operations.rs and the error_handling module of tests/protocol_s3.rs.

Limits and configuration

Item Value Source
Port 9100 src/config.rs, s3_port
Region reported us-east-1; re-creating an owned bucket succeeds S3Config::default, create_bucket
Object size 5 GB max_object_size
Part size 5 MB minimum (except the last part, checked at complete), 5 GB maximum min_part_size, max_part_size
Parts per upload 10,000 max_parts
Key length 1024 bytes (KeyTooLongError) check_key
Bucket names 3 to 63 characters of lower-case letters, digits, dots and hyphens; starts and ends alphanumeric; no ..; not an IPv4 address (InvalidBucketName) valid_bucket_name
Keys per listing page 1000 list_objects
Presigned URL lifetime Up to 604,800 seconds (7 days) validate_presigned_request
Request body before auth Not capped handle_http_request

Test coverage

Suite Count What it covers
src/protocol/s3/mod.rs unit tests 11 Operation parsing, unsigned requests refused, date formats, listing and content type, restart with offloaded bodies (plain and versioned).
auth.rs / features.rs / operations.rs / storage.rs 7 / 3 / 4 / 5 SigV4 key derivation and header parsing, presigned URL generation, fail-closed registry; policy globs, public-read policy, multipart forms; response and error types; store operations.
tests/protocol_s3.rs 53 Modules bucket_operations, object_crud, object_listing, object_copy, auth_types, data_integrity, persistence_tests, error_handling. They call S3Storage and S3Auth directly; none sends HTTP.

(source: the files named)

Proof pack (docs/proof/2026-11-30/proof-pack-a3232c9/logs/s3-s3-diff.txt): "S3: 151/151 match (single 132/132, cross 5/5, durable 14/14)" against LocalStack. The log has 9 note lines where LocalStack's answer differed and the check was compared against AWS's documented answer instead: tampered and expired presigned GETs, a wrong secret, a public-read policy, and presigned POST cases (field outside policy, tampered signature, expired policy). This suite runs under the harness's wirediff profile, with real authentication. (source: the log named; prove/wires.py)

Not verified: TLS, cluster mode, aws-chunked uploads, Content-MD5, large-object memory use, the sub-resource fall-through cases above.

Not implemented

  • Virtual-hosted-style addressing. (source: parse_s3_operation)
  • Per-key permissions, IAM policies for signed requests, enforcement of ACLs. (source: dispatch, CredentialPermissions)
  • More than one access key. (source: register_provisioned_credentials)
  • Lifecycle, bucket tagging, encryption, replication, notifications, object lock, website hosting, inventory, analytics, UploadPartCopy, SelectObjectContent, GetObjectAttributes, checksums (x-amz-checksum-*). None has a parse arm. (source: parse_s3_operation)
  • Paging of ListMultipartUploads and ListParts. (source: list_multipart_uploads, list_parts)
  • A request size limit before authentication. (source: handle_http_request)