Skip to content

fix: honor a requested checksum algorithm on SSE-C key rotation - #123

Merged
Vonng merged 1 commit into
mainfrom
fix/issue-113-rotation-checksum-algorithm
Sep 6, 2026
Merged

Vonng merged 1 commit into
mainfrom
fix/issue-113-rotation-checksum-algorithm

Conversation

@Vonng

@Vonng Vonng commented Sep 5, 2026

Copy link
Copy Markdown
Member

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-by trailer.

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-algorithm was silently dropped: the old checksum was kept, stored and reported. The canRotateKeyInPlace guard 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-algorithm replaces 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 upstream 2718d9a43 (minio#21399), still present on upstream master; deliberate divergence.

How to test this PR?

GOWORK=off go test -tags kqueue,dev ./cmd -count=1 -v -run '^(TestAPICopyObjectSSECKeyRotationChecksumAlgorithm|TestAPICopyObjectSSECKeyRotationKeepsChecksumAbsence|TestAPICopyObjectSSECKeyRotationReplicaKeepsFastPath)$'

TestAPICopyObjectSSECKeyRotationChecksumAlgorithm fails 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. TestAPICopyObjectSSECKeyRotationKeepsChecksumAbsence pins the accepted limitation on raw ObjectInfo.Checksum. TestAPICopyObjectSSECKeyRotationReplicaKeepsFastPath pins the replica carve-out on a non-empty and a zero-byte source (it fails against the bare guard with 400 ExcessData). The plan's 13 must-stay-green CopyObject checksum, rotation and metadata-only tests and the 10 replication-trust tests pass. gofmt clean, go vet clean, 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-algorithm 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 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Optimization (provides speedup with no functional changes)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • All commits are signed off (git commit -s) per the DCO
  • Fixes a regression (inherited from upstream 2718d9a43, not a SILO regression)
  • Unit tests added/updated
  • make verifiers equivalent: gofmt clean, go vet clean, golangci-lint 0 issues on ./cmd/...
  • Relevant package tests pass
  • Compatibility and rollback impact documented
  • Internal documentation updated (guard comment records the accepted limitation)
  • Public documentation update opened in pgsty/silo.pgsty.com (compatibility note for the headerless-rotation limitation, to follow)

🤖 Generated with Claude Code

https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe

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
@Vonng
Vonng merged commit 8b736de into main Sep 6, 2026
8 checks passed
@Vonng
Vonng deleted the fix/issue-113-rotation-checksum-algorithm branch September 9, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant