Repository navigation
fix: exclude SSE-C objects from compression - #126
Merged
Merged
Conversation
With compression allow_encryption=on an SSE-C object is stored as encrypt(s2(plaintext)), while replication reads it raw (NoDecryption at cmd/erasure-object.go:257) and putReplicationOpts drops the internal compression and actual-size headers (cmd/bucket-replication.go:786). The replica keeps the source seal with no compression marker, so a GET with the correct customer key returns HTTP 200 and the raw S2 stream instead of the object, and the source records the transfer as COMPLETED. Widen the one condition in excludeForCompression (cmd/object-api-utils.go:613) so SSE-C is never compressed, whatever allow_encryption says. This covers all four producers at once, PutObject, NewMultipartUpload, CopyObject and PutObjectExtract, plus any future caller of isCompressible. crypto.SSEC.IsRequested ignores copy-source headers, so a copy is judged on its destination key only, and a raw SSE-C replica write is unaffected because it carries no public SSE-C headers. allow_encryption keeps its meaning for SSE-S3 and SSE-KMS, where the server owns the key and decompresses before replicating. Tests: TestAPISSECCompressionReplicaStaysReadable (single PUT and multipart), TestAPISSECCompressionProducerMatrix, TestAPISSECCompressionSkippedOnCopyObject, TestAPISSECCompressionSkippedOnSnowballExtract and the control TestSSECBatchReplicationCannotRead in cmd/compression-ssec_test.go. Two existing expectations pinned the removed shape and are updated: TestAPICopyObjectSSECKeyRotationNullVersionCompressesRewrite is renamed TestAPICopyObjectSSECKeyRotationNullVersionSkipsCompression and now expects an uncompressed rewrite, keeping its body, checksum, version and ETag assertions; the SSE-C compressed-encrypted variant of TestAPICopyObjectServerSideChecksumEncryption becomes compressible-extension and expects an uncompressed destination, its SSE-S3 sibling keeping the compressed coverage. Compatibility: a deliberate behaviour change. Deployments with allow_encryption=on no longer store new or rewritten SSE-C data compressed, so those writes cost more space; objects already stored compressed keep working on the source and are the concern of #109, which rejects them at replication time. Multipart uploads initiated before this change keep compressing their parts from the metadata saved at initiation. Upstream 468a9fa refused this combination at PUT time and a2cab02 removed the guard; upstream master is still unguarded, so this is a deliberate divergence. Fixes #118 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe Signed-off-by: Feng Ruohang <[email protected]>
7 tasks
Closed
4 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
With
compression allow_encryption=on, an object that is both SSE-C and compression-eligible was stored asencrypt(s2(plaintext)). Replication ships an SSE-C object as raw ciphertext and drops the compression metadata, so even a destination that applies no transforms stored a replica that decrypts, with the correct customer key, to a raw S2 stream while the source reportedCOMPLETED. The one-line fix widens the condition inexcludeForCompressionso new SSE-C data is never compressed, whateverallow_encryptionsays; SSE-S3 and SSE-KMS keep following the setting because the server owns those keys and decompresses before replicating. Upstream468a9fae8originally refused this combination at PUT time anda2cab0255removed the guard; upstream master remains unguarded.Fixes #118. The issue body is the plan agreed with the Codex reviewer (2 rounds). Adversarial Codex review of this implementation: round 1 FAIL (a second existing test variant pinned compressed SSE-C storage; the CI script needed a storage-representation assertion; three misleading comments), round 2 FAIL (the new shell assertion accepted a failed HEAD; one comment), round 3 PASS with no findings.
Motivation and Context
allow_encryptionis off by default and documented as unsafe, but it is global: enabling it for SSE-S3/SSE-KMS silently made every SSE-C object unreplicable. Preventing the shape is smaller and safer than carrying compression state over the wire (which needs a peer capability check) and than rejecting the upload (which turns an accepted write into an application failure). #109 (PR #122) is the backstop for objects already stored compressed; neither change repairs replicas already written.How to test this PR?
New
cmd/compression-ssec_test.go: the replica-corruption reproduction (single PUT and multipart; on main the correct-key GET returns 256 bytes that s2-decode to the 335872-byte plaintext, after the fix the object is stored encrypted and uncompressed and reads back intact), the CopyObject and snowball-extract producers, theallow_encryptionmatrix (plaintext, SSE-S3, SSE-KMS stay compressed underon; SSE-C never), and the batch-replication control. Two existing expectations change deliberately:TestAPICopyObjectSSECKeyRotationNullVersionCompressesRewriteis renamed...SkipsCompressionand expects an uncompressed rewrite, and the SSE-C compressed-encrypted variant ofTestAPICopyObjectServerSideChecksumEncryptionnow expects an uncompressed destination (renamedcompressible-extension; its SSE-S3 sibling keeps the compressed coverage). Red on main for the four regression entry points on ErasureSD and Erasure, green with the fix; the compression, checksum and object-handlers compression sweeps stay green.gofmtclean,go vetclean, golangci-lint 0 issues;bash -n,shellcheckandshfmt -dclean on the shell script.Not executed here:
docs/site-replication/run-ssec-object-replication-with-compression.sh(run bymake test-site-replication-silo, two live clusters) is restored toallow_encryption=onwith a compressible 100 MB multipart payload, asserts viamc --debug statthat the source object carries noX-Minio-Compressedheader (the server emits it for compressed objects,cmd/api-headers.go:254), and checks the replica's ETag and size. It needs a run of that make target before release.Compatibility impact
Deliberate behaviour change for deployments with
allow_encryption=on: new or rewritten SSE-C data is stored uncompressed (metadata-only operations keep an already compressed object's representation; multipart uploads initiated before the change keep compressing their parts). Plaintext, SSE-S3 and SSE-KMS objects are unchanged; withallow_encryption=offnothing changes. A raw SSE-C replica write is unaffected because it carries no public SSE-C headers. Recorded divergence from upstream master. Documented indocs/compression/README.md.Types of changes
allow_encryption=on; agreed in the issue)Checklist:
git commit -s) per the DCO468a9fae8guarded,a2cab0255removed the guard)make verifiersequivalent: gofmt clean, go vet clean, golangci-lint 0 issues on./cmd/...docs/compression/README.md)pgsty/silo.pgsty.com(compression page should carry the same sentence with the release)🤖 Generated with Claude Code
https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe