Repository navigation
fix: honor a requested checksum algorithm on SSE-C key rotation - #123
Merged
Merged
Conversation
An in-place SSE-C key rotation takes the fast path at cmd/object-handlers.go:1523 that only rewraps the object key, while every line that turns x-amz-checksum-algorithm into a stored checksum lives in the re-encrypting else branch at 1571-1609, so a requested algorithm was silently dropped and the stale source checksum was kept and reported. Extend the canRotateKeyInPlace guard so a client request carrying the header falls through to the copy that recomputes, stores and reports it. Replica-trusted requests keep the fast path: getOpts leaves their source reader encrypted, so a rewrite would hash ciphertext, and a replica has to keep the checksum its source assigned. Tests: TestAPICopyObjectSSECKeyRotationChecksumAlgorithm (new, red before the guard), TestAPICopyObjectSSECKeyRotationKeepsChecksumAbsence (new, pins the accepted limitation that a headerless rotation preserves the stored checksum state including absence, gaining no default CRC64NVME) and TestAPICopyObjectSSECKeyRotationReplicaKeepsFastPath (new, pins the replica carve-out on a non-empty and on a zero byte source). Compatibility: no API or wire change; a rotation without the header and every replica-trusted rotation are unchanged, while a client rotation carrying the header now rewrites the object data, so the ETag changes, a multipart source collapses to a single part object, the copy replicates as an object rather than as metadata, and the rewritten bytes are compressed if compression is enabled for that object, as AWS CopyObject documents. Upstream MinIO carries the same defect from 2718d9a (minio#21399); this is a deliberate divergence. Fixes #113 Signed-off-by: Feng Ruohang <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contribution Licensing (no CLA, inbound=outbound, DCO required)
This project does not use a CLA; contributions are accepted inbound=outbound.
By submitting this pull request I represent that I have the right to contribute
the changes, which are licensed under this repository's
GNU Affero General Public License v3.0 or later
and remain my copyright. Every commit carries a DCO
Signed-off-bytrailer.Description
An in-place SSE-C key rotation (CopyObject onto itself with a new customer key) takes a metadata-only fast path that only rewraps the object key, while all checksum handling lives in the re-encrypting branch, so a requested
x-amz-checksum-algorithmwas silently dropped: the old checksum was kept, stored and reported. ThecanRotateKeyInPlaceguard now also requires that no checksum algorithm header is present for a client request, so such a rotation falls through to the existing copy that recomputes, stores and reports the requested checksum. Replica-trusted rotations keep the fast path: their source reader is left encrypted by the replication read path, so a rewrite would hash ciphertext, and a replica must keep the checksum its source assigned (a deviation from the plan's one-liner that the adversarial review required, covered by its own regression test).Fixes #113. Fix plan agreed with the Codex reviewer: #113 (comment), with the accepted-limitation amendment #113 (comment) (a headerless rotation preserves the stored checksum state, including absence). Adversarial Codex review of this implementation: round 1 FAIL (one MAJOR: the bare guard regressed replica-trusted rotations to 400
ExcessData; one MINOR: the checksum-absence assertion was vacuous), round 2 PASS with no findings.Motivation and Context
AWS CopyObject documents that a supplied
x-amz-checksum-algorithmreplaces the destination checksum algorithm; a request that is accepted but not honoured gives clients that rotate keys and upgrade checksums a false success. Inherited from upstream2718d9a43(minio#21399), still present on upstream master; deliberate divergence.How to test this PR?
TestAPICopyObjectSSECKeyRotationChecksumAlgorithmfails on main (the CopyObject XML reports no SHA256) and passes with the fix: the response XML, the stored checksum decrypted with the new key and the GET headers carry SHA256 and no CRC32, the new key reads the original bytes and the old key is refused.TestAPICopyObjectSSECKeyRotationKeepsChecksumAbsencepins the accepted limitation on rawObjectInfo.Checksum.TestAPICopyObjectSSECKeyRotationReplicaKeepsFastPathpins the replica carve-out on a non-empty and a zero-byte source (it fails against the bare guard with 400ExcessData). The plan's 13 must-stay-green CopyObject checksum, rotation and metadata-only tests and the 10 replication-trust tests pass.gofmtclean,go vetclean, golangci-lint 0 issues on./cmd/....Compatibility impact
No API or wire change. A rotation without the header and every replica-trusted rotation are unchanged. A client rotation carrying
x-amz-checksum-algorithmnow rewrites the object data, so the ETag changes, a multipart source collapses to a single-part object, the copy replicates as an object rather than as metadata, and the rewritten bytes are compressed if compression is enabled for the object; this is what the same request already does for the null-version and legacy rotation cases and what AWS CopyObject documents. Objects rotated before the fix keep a correct checksum under the old algorithm; re-issuing the copy upgrades it.Types of changes
Checklist:
git commit -s) per the DCO2718d9a43, not a SILO regression)make verifiersequivalent: gofmt clean, go vet clean, golangci-lint 0 issues on./cmd/...pgsty/silo.pgsty.com(compatibility note for the headerless-rotation limitation, to follow)🤖 Generated with Claude Code
https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe