Skip to content

[Gap] S3 GET and PUT ignore conditional headers (If-None-Match, If-Match, If-Modified-Since) #171

Closed

Description

@saworbit

Summary

Conditional request headers are ignored. A GET with a matching If-None-Match returns the full body with 200 instead of 304. S3 supports conditional PUTs, If-None-Match: * for create-only and If-Match: <etag> for compare-and-swap; here both overwrite unconditionally. Clients that rely on them for caching or locking get silent lost updates.

Classification

  • Type: Edge-Case Gap
  • Severity: Low
  • Verification: Verified (Runtime) for GET; Static Audit for PUT and HEAD
  • Location: crates/protocol-s3/src/handlers.rs:63-136

Reproduction / Context

  1. etag = s3.head_object(Bucket="demo", Key="stream.bin")["ETag"]
  2. s3.get_object(Bucket="demo", Key="stream.bin", IfNoneMatch=etag) returns HTTP 200 with the body. Expected: 304 Not Modified.
  3. put_object and head_object take no HeaderMap, so they never read If-* headers either.

Proposed Fix / Recommendation

The ETag is already a stable capsule ID, so these checks are cheap:

  • GET and HEAD: If-Match → 412, If-None-Match → 304, and If-Modified-Since / If-Unmodified-Since compared against created_at.
  • PUT: evaluate If-None-Match: * and If-Match in S3View::put_object, under the pipeline lock and next to the existing live_capsule lookup, so the check and the bind are atomic. Return 412 PreconditionFailed on a mismatch.

Activity

  1. added
    enhancement
    on Nov 13, 2026
  2. saworbit commented on Nov 13, 2026

    @saworbit
    OwnerAuthor

    Fixed in cdb3249 (#181). GET and HEAD give 412 or 304 per RFC 9110. PUT honours If-None-Match: *, If-Match and If-Unmodified-Since, checked again under the pipeline lock at the commit. A test races two create-only PUTs and only one wins. CHANGELOG updated. This closes when #181 merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementprotocol-s3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions