Skip to content

[P2] In-place SSE-C key rotation ignores a requested checksum algorithm #113

Closed

Description

@Vonng

Problem and reproduction

  1. PUT an SSE-C object with a CRC32 checksum.
  2. Copy that object onto the same bucket/key, specifying the old SSE-C source key, a different destination SSE-C key, and x-amz-checksum-algorithm: SHA256.
  3. Read the result with the new key and inspect its checksum.

CopyObject returns 200 and the new key reads the original bytes correctly, but SHA256 is absent and the old CRC32 is retained. On 0903, the CopyObject XML itself also reports the old CRC32. The requested algorithm is neither honored nor rejected.

The same signed-handler test reproduces this on ErasureSD and Erasure in both releases. Ordinary content reads remain correct; this is an explicit checksum contract failure.

Cause and minimal repair

The in-place key-rotation branch bypasses checksum computation, which is only in its else branch. The omission dates to 2718d9a430fb2c9db1c41536ccd28717b0c1435d (2025-06-25). The newer canRotateKeyInPlace restriction did not introduce it.

When an explicit checksum algorithm is requested, use the existing read/rechecksum/re-encrypt path instead of the in-place rotation shortcut. Retain the fast path when no algorithm change is requested.

Acceptance

  • Old CRC32 + new SSE-C key + requested SHA256 returns and stores SHA256.
  • The new key reads identical bytes and the old key no longer works.
  • Existing rotation without an explicit algorithm keeps its checksum and remains correct.

The CopyObject API supports selecting a destination checksum algorithm. #99 concerns a separate legacy federation path; this issue is the ordinary local same-object key-rotation path.

Versions and verification

Reproduced in the 2026-09-05 functional review on the published SILO release RELEASE.2026-09-03T13-18-01Z (9b11dc9469e650815b775cb47b039610644f5da4), with RELEASE.2026-08-06T00-00-00Z (3be10fcc1a44f6620ded0bd303461f9d688cca23) as the baseline. The reviewed code remains unchanged on current main f0bd164b92d799c026fb1a31ad8e0df8ecb39388. Product fixes have not been applied.

Activity

  1. added
    bug
    on Sep 5, 2026
  2. Vonng commented on Sep 5, 2026

    @Vonng
    MemberAuthor

    Fix plan prepared 2026-09-05 by Claude (Fable 5.1) and reviewed in 1 round(s) of dialogue with the Codex reviewer (gpt-6-astra) that filed this issue. Local paths under /Users/vonng/pgsty/silo-codex-triage-20260905/silo-113 (plan, prototype diff, tests, Codex transcripts) and /private/tmp/silo-mcli-review-20260905.MfP8W9 (review evidence) live on the maintainer's machine, not in the repository.

    Fix plan — #113 (Claude ⨯ Codex consensus, 2026-09-05)

    1. Verdict

    Confirmed. I read cmd/object-handlers.go on main f0bd164b9: the in-place SSE-C rotation
    branch is entered at line 1523 and closes at line 1543, while every line that turns
    x-amz-checksum-algorithm into a stored checksum lives in the else branch that opens at line
    1544, specifically lines 1571-1609. A rotation therefore never sets
    dstOpts.WantServerSideChecksumType and never attaches a hasher, so it preserves the existing
    stored checksum, exposed as ObjectInfo.Checksum (cmd/object-api-datatypes.go:217, read by
    decryptChecksums at cmd/encryption-v1.go:1195), while rewrapping the object key in encryption
    metadata.
    git diff 9b11dc946..f0bd164b9 -- cmd/object-handlers.go is empty, so the reviewed release code is
    on main verbatim and Codex's line citations still hold. I ran the Codex repro at main in my own
    worktree: FAIL on both ErasureSD and Erasure, GET returns no SHA256 and the stale CRC32, stored
    checksum map[CRC32:... x-amz-checksum-type:FULL_OBJECT]
    (silo-113-red.log). One correction to the issue text: the sentence "neither honored
    nor rejected" holds for a valid algorithm only. An unrecognized value is already rejected with 400
    by copyDstOpts at cmd/object-api-options.go:449, which calls hash.GetContentChecksum, so by the
    time control reaches line 1523 the algorithm header is either absent or a valid supported type.

    2. Root cause

    cmd/object-handlers.go:1523 on f0bd164b9. The guard
    cpSrcDstSame && (sseCopyC && sseC) && !chStorageClass && canRotateKeyInPlace takes an early branch
    that only rewraps the object key through rotateKey and sets srcInfo.metadataOnly = true. All
    checksum handling sits in the else at 1571-1609, so a requested algorithm is dropped on the floor.
    The object key itself is unchanged by an SSE-C rotation (cmd/encryption-v1.go:350, the sealed key
    is resealed with the same objectKey), which is why the stale CRC32 still decrypts and is reported
    back verbatim. Codex's attribution is right: upstream 2718d9a430fb2c9db1c41536ccd28717b0c1435d
    (2025-06-25, "CopyObject must preserve checksums and encrypt them if required (minio#21399)") added the
    checksum block inside the else; ffb70eb373 only added canRotateKeyInPlace and did not
    introduce this.

    3. Minimal fix

    • Change: cmd/object-handlers.go, CopyObjectHandler, extend canRotateKeyInPlace (line 1515)
      with && !hash.NewChecksumHeader(r.Header).IsSet(). One product line plus a five line comment.
      hash is already imported. The header is parsed a second time at line 1573; that is deliberate,
      both calls are pure header parses and hoisting the variable would widen its scope across 60 lines
      for no gain. Size S.
    • Behaviour after the fix: when the client supplies a valid x-amz-checksum-algorithm, the copy
      falls into the existing re-encrypting branch. The source is read and decrypted through gr, the
      requested hasher is attached at lines 1573-1577, a fresh object key encrypts the data, the new
      checksum is stored under that key, and the CopyObject XML plus the response headers report it through the
      existing objInfo.decryptChecksums(0, dstHeaders) at line 1880. This matches the AWS CopyObject
      contract: "If the CopyObject request does not include this x-amz-checksum-algorithm header, the
      checksum algorithm will be copied from the source object to the destination object. You can
      optionally specify a different checksum algorithm to use with the x-amz-checksum-algorithm
      header." With no header the fast path is untouched and the source checksum is preserved, which is
      the documented default. x-amz-checksum-type is a CopyObject response element in AWS, not a
      request header, and the destination of a copy is always a single part object, so the recomputed
      checksum is a full object checksum. That is what the else branch already produces for every
      other copy, including multipart composite sources, which
      TestAPICopyObjectServerSideChecksumSourceVariants/multipart-composite-source pins today.
    • Explicitly out of scope:
      • Keeping the fast path when the requested algorithm equals the stored one. It buys only
        performance, it needs the stored checksum decrypted and compared including the
        COMPOSITE/FULL_OBJECT flag, and getting that comparison wrong would silently leave a composite
        checksum where the client asked for a recompute. No evidence shows this case is hot: nothing in
        the server sends x-amz-checksum-algorithm on an outbound CopyObject, and the header is an
        explicit opt-in to recomputation.
      • Rejecting unsupported algorithm values. Already handled at cmd/object-api-options.go:449.
      • The adjacent gap that a rotation of a checksum-less object does not gain the automatic
        CRC64NVME that the else branch adds at lines 1604-1607. Closing it would divert every
        rotation to a full rewrite and destroy the fast path that
        TestAPICopyObjectSSECKeyRotationKeepsCompressionState pins. [P2] In-place SSE-C key rotation ignores a requested checksum algorithm #113 is about an explicitly
        requested algorithm, and this fix leaves that case exactly as it is today.
      • Federated CopyObject silently ignores a requested checksum algorithm #99, the legacy federation CopyObject path at cmd/object-handlers.go:1818. Different branch,
        different mechanism, untouched here.
      • Adding an in-place checksum recompute that keeps the bytes. That would need the handler to drain
        the reader itself and feed dstOpts.WantChecksum on a metadataOnly write, contradicting the
        existing invariant at line 1766 that a server side checksum type forces a data rewrite.

    4. Tests

    • Regression test: TestAPICopyObjectSSECKeyRotationChecksumAlgorithm in
      cmd/object-copy-checksum_test.go, written and verified, 95 lines, in silo-113-test.diff. It
      reuses the local helpers putCopyChecksumSource, copyChecksumRequest, assertCopyChecksumResponse,
      assertCopyChecksum and mustChecksum, and runs under ExecObjectLayerAPITest so ErasureSD and
      Erasure are both covered. It PUTs an SSE-C object with CRC32, rotates the key in place while
      requesting SHA256, then asserts: CopyObject 200; the response XML carries the recomputed
      ChecksumSHA256 with ChecksumType FULL_OBJECT; the stored checksum decrypted with the new key is
      SHA256 and no longer carries CRC32; a GET with the new key returns the original bytes with
      x-amz-checksum-sha256 and no x-amz-checksum-crc32; a GET with the rotated-out key returns 403.
      It supersedes the Codex repro, which need not be upstreamed.
    • Existing tests that must stay green:
      TestAPICopyObjectSSECKeyRotationKeepsCompressionState is the fast path guard, a rotation with no
      algorithm header, and it also asserts the metadata only write does not stamp compression metadata.
      Plus TestAPICopyObjectServerSideChecksum, ...Encryption, ...SourceVariants,
      TestAPICopyObjectSSECKeyRotationNullVersion, ...NullVersionCompressesRewrite,
      ...NullVersionWrongKey, TestAPICopyObjectMetadataOnlyCompression, ...NullVersion,
      ...NullVersionCompressesRewrite, TestCopyRewritesObjectData, TestAPICopyObjectHandler,
      TestAPIRejectsUnsupportedChecksumHeaders. All 14 pass with the prototype applied.
    • No live or integration check is required. This is a single node handler decision with no wire,
      cluster or replication protocol surface.

    5. Compatibility, risk, rollout

    No API or wire change: the request and response shapes are unchanged, and a request without
    x-amz-checksum-algorithm behaves exactly as before. The one visible consequence is that a rotation
    carrying the header now rewrites the object data instead of only its metadata, so the ETag changes,
    a multipart source collapses to a single part object, and the change replicates as
    replication.ObjectReplicationType rather than MetadataReplicationType. If compression is
    enabled for that object, the rewritten bytes are compressed, exactly as
    TestAPICopyObjectSSECKeyRotationNullVersionCompressesRewrite already pins for the null version
    rewrite. All of this already happens today for the null version and legacy rotation cases that canRotateKeyInPlace diverts, and
    TestAPICopyObjectSSECKeyRotationNullVersion already pins the ETag change, so this is an existing
    behaviour reused rather than a new one. AWS documents the same collapse: "If the source object is an
    object that was uploaded by using a multipart upload, the object copy will be a single part object."
    No data already written is affected and no resync is needed: objects rotated before the fix keep a
    correct checksum, just under the old algorithm, and a client can re-issue the copy to upgrade it.
    No config or docs change.

    6. Cost

    Effort S. Product: 1 line changed plus 5 comment lines in cmd/object-handlers.go. Test: 95
    lines for one new test in cmd/object-copy-checksum_test.go, already written and green. No
    dependency or ordering with other issues: it does not touch #99's federation branch, #114 and #115's GetObjectAttributes
    handler, or the replication copy path in the P1 SSE-C replication finding. Server side only, no mc
    or SDK work.

    7. Consensus with Codex

    Rounds used: 1/3, CONSENSUS: YES in round 1 (silo-113-r1.md). Agreed on all five dimensions.
    Codex explicitly endorsed dropping the same-algorithm optimization and adding no integration gate,
    and confirmed that the writer replaces the stored checksum and encrypts it with the destination key
    at cmd/erasure-object.go:1504, so the fix repairs persistence as well as the response. It ran no
    tests and requested none, accepting my reported results.

    Amendments accepted: one, non-blocking and factual. Codex objected that §1 placed the retained
    checksum bytes in srcInfo.UserDefined. It is right: they live in ObjectInfo.Checksum
    (cmd/object-api-datatypes.go:217), read by decryptChecksums at cmd/encryption-v1.go:1195. I
    verified both citations and rewrote §1. Diagnosis and patch unaffected.

    Rejected suggestions: none. Open disagreements: none.

    Appendix A — prototype diff

    --- a/cmd/object-handlers.go
    +++ b/cmd/object-handlers.go
    @@ -1512,8 +1512,14 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
     	// data instead, the rotation has to go through the regular re-encrypting
     	// copy, or the destination ends up holding plaintext under metadata that
     	// claims the object is encrypted.
    +	//
    +	// An explicitly requested destination checksum algorithm has to be computed
    +	// over the object data, which an in-place rotation never reads. Leave the
    +	// fast path so the regular re-encrypting copy computes, stores and reports
    +	// the requested algorithm.
     	canRotateKeyInPlace := !srcInfo.Legacy &&
    -		!copyRewritesObjectData(srcInfo.metadataOnly, copySrcOpts, dstOpts)
    +		!copyRewritesObjectData(srcInfo.metadataOnly, copySrcOpts, dstOpts) &&
    +		!hash.NewChecksumHeader(r.Header).IsSet()
     
     	// If src == dst and either
     	// - the object is encrypted using SSE-C and two different SSE-C keys are present

    Before: TestReview20260905SSECRotationChecksumAlgorithm FAIL on ErasureSD and Erasure at main
    f0bd164b9 (silo-113-red.log).
    After: that test plus 13 existing CopyObject checksum, rotation and metadata-only tests PASS,
    ok github.com/minio/minio/cmd 5.082s (silo-113-green.log). The new
    TestAPICopyObjectSSECKeyRotationChecksumAlgorithm also PASSES alongside the fast path guard
    TestAPICopyObjectSSECKeyRotationKeepsCompressionState (silo-113-newtest.log). Product diff:
    silo-113.diff. Regression test diff: silo-113-test.diff.

  3. Vonng commented on Sep 5, 2026

    @Vonng
    MemberAuthor

    Amendment to the fix plan above (2026-09-05), agreed with the Codex reviewer in one round.

    Accepted compatibility limitation, to be recorded with this fix. The plan's §3 lists as out of scope that an in-place SSE-C key rotation of a checksum-less object does not gain the automatic CRC64NVME that every other CopyObject shape adds (cmd/object-handlers.go:1604-1607 on main f0bd164b9; the rotation fast path at :1523 returns before that block). Follow-up verification with signed-handler probes on ErasureSD and Erasure confirmed the behaviour and its context: rotation onto itself with a new key leaves no checksum; a copy to a different key, plaintext or SSE-C, gains CRC64NVME; a rotation of a CRC32-bearing source preserves CRC32; a headerless PutObject attaches no default either, so checksum-less objects are not limited to legacy uploads; and a plaintext metadata-directive: REPLACE onto itself already rewrites the data to attach the automatic checksum, so the rotation path is the only metadata-only copy that escapes the rewrite. Upstream MinIO is identical (from 2718d9a43, minio#21399).

    Both reviewers agreed this is a real but P3 deviation from the documented AWS CopyObject default, not worth its own issue, and that the right disposition is to keep the fast path and specify the behaviour, because closing the gap costs a full re-encrypting rewrite with a fresh data directory per affected rotation (cmd/object-handlers.go:1631, cmd/erasure-server-pool.go:1401, cmd/erasure-object.go:1362) for objects whose data never changed. Deliverables folded into this issue:

    • Guard comment at canRotateKeyInPlace: "Without a requested destination checksum algorithm, an in-place SSE-C rotation preserves the stored checksum state, including absence; it does not add the default CRC64NVME."
    • Regression assertion: checksum absent before and after a headerless rotation, absent from the CopyObject XML checksum fields, successful readback with the new key; keep the existing CRC32-preservation coverage (cmd/object-copy-metadata_test.go:153,176) and TestAPICopyObjectSSECKeyRotationKeepsCompressionState green on both backends. No product change beyond the one-line guard already in this plan.
    • A short public compatibility note on silo.pgsty.com (separate deliverable in the docs repository).

    Revisit only if SILO implements the AWS default checksum on the upload path, after which checksum-less objects become legacy-only and the cost argument changes. Local artifacts: /Users/vonng/pgsty/silo-codex-triage-20260905/followups/fu-rotation-crc64/.

  4. Vonng commented on Sep 5, 2026

    @Vonng
    MemberAuthor

    Fix record (2026-09-05)

    Status: implemented, reviewed, awaiting merge. Pull request: #123 (branch fix/issue-113-rotation-checksum-algorithm, commit fcc4d7789, based on main f0bd164b9).

    Root cause, as fixed. The in-place SSE-C rotation branch (cmd/object-handlers.go:1523) returns before the checksum block in the re-encrypting else branch (:1571-1609), so a requested x-amz-checksum-algorithm was never hashed, stored or reported. Inherited from upstream 2718d9a43.

    Change (1 product line plus comment). canRotateKeyInPlace additionally requires replicaTrusted || !hash.NewChecksumHeader(r.Header).IsSet(). A client rotation carrying the header now takes the existing re-encrypting copy, which computes, stores and reports the requested algorithm. One deviation from the plan's bare !IsSet(), required by the adversarial review: replica-trusted rotations keep the fast path, because the replication read path leaves their source reader encrypted (a rewrite would hash ciphertext and answered 400 ExcessData) and a replica must keep the checksum its source assigned. The guard comment carries the accepted-limitation sentence from the amendment.

    Tests. TestAPICopyObjectSSECKeyRotationChecksumAlgorithm (red on main, green with the fix), TestAPICopyObjectSSECKeyRotationKeepsChecksumAbsence (the amendment's assertion, on raw ObjectInfo.Checksum), TestAPICopyObjectSSECKeyRotationReplicaKeepsFastPath (pins the carve-out; red against the bare guard). All 13 must-stay-green CopyObject tests and the 10 replication-trust tests pass; gofmt, go vet and golangci-lint clean.

    Adversarial Codex review (gpt-6-astra). Round 1: FAIL, one MAJOR (the bare guard regressed replica-trusted rotations) and one MINOR (the absence assertion was vacuous because decryptChecksums also returns nil on a failed unseal); both fixed. Round 2: PASS, no findings; Codex accepted the replica carve-out over its own suggested remedy of forcing a decrypting source read.

    Surfaced, not fixed here (pre-existing, identical on main). A replica-trusted SSE-C to SSE-C CopyObject to a different object name returns 400 ExcessData (the rewrite hashes ciphertext), and its zero-byte variant accepts a wrong source key with 200. This matches the earlier recorded upstream leftover that zero-byte SSE-C reads do not authenticate the key. Worth its own issue.

    Still to do outside this change. The public compatibility note on silo.pgsty.com (headerless rotation preserves checksum state, including absence).

  5. moved this from Backlog to In progress in Siloon Sep 5, 2026
  6. moved this from In progress to Done in Siloon Sep 6, 2026
  7. Vonng commented on Sep 6, 2026

    @Vonng
    MemberAuthor

    Merged — record complete (2026-09-06)

    Merged via #123 (merge commit 8b736dee3) into main. Supersedes the "awaiting merge" status above: main is green — silo e7d0e62f1, Go CI (Test cmd/, Test internal/, Race + S3 Select, Format/Build/Vet, Lint/Generated Files, Cross Compile) and VulnCheck all pass.

    Issue closed; fix record complete.

  8. added a commit that references this issue on Sep 6, 2026
    fcc4d77
  9. self-assigned this
    on Sep 15, 2026
  10. added theissue type on Sep 15, 2026
  11. added this to the 20260916 milestone on Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions