Skip to content

fix: exclude SSE-C objects from compression - #126

Merged
Vonng merged 1 commit into
mainfrom
fix/issue-118-no-compressed-ssec
Sep 6, 2026
Merged

Vonng merged 1 commit into
mainfrom
fix/issue-118-no-compressed-ssec

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

With compression allow_encryption=on, an object that is both SSE-C and compression-eligible was stored as encrypt(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 reported COMPLETED. The one-line fix widens the condition in excludeForCompression so new SSE-C data is never compressed, whatever allow_encryption says; SSE-S3 and SSE-KMS keep following the setting because the server owns those keys and decompresses before replicating. Upstream 468a9fae8 originally refused this combination at PUT time and a2cab0255 removed 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_encryption is 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?

GOWORK=off go test -tags kqueue,dev ./cmd -count=1 -v -run '^(TestAPICompressedSSEC.*|TestAPICopyObjectSSECKeyRotationNullVersionSkipsCompression|TestAPICopyObjectMetadataOnlyNullVersionCompressesRewrite|TestAPICopyObjectSSECKeyRotationKeepsCompressionState|TestAPICopyObjectServerSideChecksumEncryption)$'

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, the allow_encryption matrix (plaintext, SSE-S3, SSE-KMS stay compressed under on; SSE-C never), and the batch-replication control. Two existing expectations change deliberately: TestAPICopyObjectSSECKeyRotationNullVersionCompressesRewrite is renamed ...SkipsCompression and expects an uncompressed rewrite, and the SSE-C compressed-encrypted variant of TestAPICopyObjectServerSideChecksumEncryption now expects an uncompressed destination (renamed compressible-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. gofmt clean, go vet clean, golangci-lint 0 issues; bash -n, shellcheck and shfmt -d clean on the shell script.

Not executed here: docs/site-replication/run-ssec-object-replication-with-compression.sh (run by make test-site-replication-silo, two live clusters) is restored to allow_encryption=on with a compressible 100 MB multipart payload, asserts via mc --debug stat that the source object carries no X-Minio-Compressed header (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; with allow_encryption=off nothing changes. A raw SSE-C replica write is unaffected because it carries no public SSE-C headers. Recorded divergence from upstream master. Documented in docs/compression/README.md.

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 (SSE-C objects are no longer compressed under allow_encryption=on; agreed in the issue)

Checklist:

  • All commits are signed off (git commit -s) per the DCO
  • Fixes a regression (regression against upstream's original intent: 468a9fae8 guarded, a2cab0255 removed the guard)
  • 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 (docs/compression/README.md)
  • Public documentation update opened in pgsty/silo.pgsty.com (compression page should carry the same sentence with the release)

🤖 Generated with Claude Code

https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe

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]>
@Vonng
Vonng merged commit 7657574 into main Sep 6, 2026
8 checks passed
@Vonng
Vonng deleted the fix/issue-118-no-compressed-ssec 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] A compressed SSE-C object replicates to a replica that decrypts to an S2 stream

1 participant