Skip to content

S3: record the SSE headers on write and echo them on GetObject/HeadObject #492

Closed

Description

@scttfrdmn

Split from #475, which asked for server-side encryption across the whole S3 plugin. This
is the shippable unit: item 1 of that issue's own priority order, and the one the
reporter identified as load-bearing. The rest is #493.

What

Record the three SSE request headers on write and echo them on read. No cryptography —
recording and echoing is the whole of it, the same treatment S3SystemMetadata already
gives its four fields.

  • Capture on PutObject: x-amz-server-side-encryption,
    x-amz-server-side-encryption-aws-kms-key-id,
    x-amz-server-side-encryption-bucket-key-enabled.
  • Echo on GetObject and HeadObject: AES256 for SSE-S3; aws:kms plus the key ID
    header for SSE-KMS; the bucket-key header only when it was enabled.
  • The KMS key ID round-trips verbatim.

Why this half, on its own

With SSE unmodelled, an object written with the header reads back byte-identical to one
written without it, so a consumer can only assert on what the request carried. #475
explains why that is weaker than it looks: asserting on the object's bytes passes with no
header sent, and asserting on the SDK input struct only checks the line that filled it in.
Recording and echoing turns every one of those request assertions into a stored-object
assertion
, which is the claim that actually matters — and it does so without needing any
of the resolution rules, defaults, or validation that make up the rest of #475.

That is also why it splits cleanly: nothing here depends on bucket defaults, copy
semantics, or the error cases. Those interact with each other and are worth designing
together; this does not interact with them at all.

On the key ID, deliberately diverging

Real S3 echoes back the resolved key ARN, not the string that was sent — KMS accepts
four forms (key ARN, alias ARN, alias/name, bare UUID). Substrate should echo it
verbatim, because it lets a consumer assert the exact string their config produced,
which is the assertion they are actually trying to make. #475's reporter confirms their
tests assert the sent form.

This is a documented divergence, not an oversight, and it goes in docs/services.md
beside the behaviour: if key resolution is ever modelled, the difference is observable and
this decision has to be revisited.

Acceptance criteria

  • PutObject with x-amz-server-side-encryption: AES256 → GetObject and
    HeadObject echo AES256.
  • aws:kms with a key ID → both echo the algorithm and the key ID, verbatim, for all
    four KMS ID forms.
  • The bucket-key header is echoed only when it was sent enabled — absent, not
    false, otherwise.
  • An object written with no SSE headers echoes none, so "no header sent" stays
    distinguishable from "header sent". (Note that a real bucket never stores an
    unencrypted object — S3 has applied SSE-S3 unconditionally since January 2023 — but
    modelling that default is S3: SSE resolution — CopyObject, multipart, bucket defaults, and the invalid-combination 400s #493's item, and doing it here would remove the
    distinction this criterion exists to preserve.)
  • The values survive a state round-trip, so an object stored before this existed reads
    back with no SSE rather than a fabricated default.
  • docs/services.md documents what is recorded, that no cryptography is performed, and
    the verbatim-key-ID divergence.

SSE-C (x-amz-server-side-encryption-customer-*) is out of scope; #475's reporter does not
need it.

Activity

  1. added this to the v0.87.0 milestone on Aug 2, 2026
  2. added
    type: feature
    area: s3
    on Aug 2, 2026
  3. scttfrdmn commented on Aug 2, 2026

    @scttfrdmn
    OwnerAuthor

    Shipped in ee413b0 (#506), in v0.87.0. Recording and echoing only — no cryptography, which is the whole of what the split intended.

    S3ServerSideEncryption (Algorithm, KMSKeyID, BucketKeyEnabled) is embedded in S3Object beside S3SystemMetadata, and in the multipart-upload record as well even though multipart resolution is #493's. That last part is deliberate: S3SystemMetadata exists precisely so the family is declared once and the two write paths cannot drift, and adding the field twice differently later is the failure that pattern prevents.

    PutObject captures x-amz-server-side-encryption, x-amz-server-side-encryption-aws-kms-key-id and x-amz-server-side-encryption-bucket-key-enabled; GetObject and HeadObject echo them through objectResponseHeaders, which is already the single place both operations build headers and already emits optional headers only when set — so the echo is one edit, not two handlers.

    The KMS key ID round-trips verbatim, and that is a stated divergence rather than a shortcut. Real S3 echoes the resolved key ARN; substrate echoes what was sent. The reason is that the sent string is what a consumer's config produced and what their assertion names — #475's reporter confirmed their tests assert the sent form, and resolving alias/mine to an ARN substrate invented would break an assertion that is correct about the caller's own intent. It is documented beside the field the way s3_copy_metadata.go documents its MetadataDirective asymmetry, and asserted for a bare UUID, an alias/name and a full key ARN. If it ever needs to resolve, #493 is where that decision goes.

    The bucket-key header is echoed only when it was enabled, since an absent header and an explicit false are different observations. An object written with no SSE headers reads back with none — the regression guard on every existing object. And the stored object is asserted directly from state, not only through a header round-trip, so the assertion is about storage rather than echo plumbing.

    Out of scope and named in docs/services.md, all in #493: bucket default encryption, CopyObject inheritance, multipart resolution, and the four invalid-combination 400s. Nothing here depends on any of them, which is what made the split clean.

  4. added a commit that references this issue on Aug 2, 2026
  5. added a commit that references this issue on Oct 5, 2026
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

    area: s3fidelitytype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions