Repository navigation
fix: record plaintext part sizes for replicated SSE-C multipart parts - #124
Merged
Merged
Conversation
Trusted SSE-C replication uploads parts as raw ciphertext with the ciphertext length as Content-Length, and erasureObjects.PutObjectPart only derived the plaintext length when the caller passed a negative size, so each replicated part persisted the ciphertext length as ActualSize (the field defined as the uploaded size without encryption bytes). On the replica, partNumberToRangeSpec turned those lengths into a plaintext range, so GET/HEAD ?partNumber=N returned the wrong bytes and shifted Content-Range (2560, 2560 and 5120 bytes for 5 MiB, 5 MiB and 1 MiB parts), and a later decommission or rebalance re-uploaded the parts with the stale value and recomputed the object-level actual-size from their sum, after which a whole-object GET advertised a Content-Length larger than the body it wrote. Derive the plaintext length of an encrypted, uncompressed part from the bytes actually written (sio.DecryptedSize) in PutObjectPart, the single place a part is persisted, rejecting a length that cannot be a valid stream before the part is committed; and derive part lengths from part.Size in partNumberToRangeSpec for encrypted, uncompressed objects, returning an error instead of a nil range, so replicas already on disk read correctly without a resync. Compressed parts keep ActualSize. Tests: TestAPISSECReplicaPartNumberReads (three-part SSE-C replica, ?partNumber=N bytes, Content-Length and Content-Range equal the source) and TestSSECReplicaPartActualSizeDataMovement (replay through the data movement path leaves part and object sizes at plaintext values) fail on main and pass with the fix on ErasureSD and Erasure; TestAPIGetObjectWithPartNumberHandler, TestAPISSECMultipartReplicationTrust and TestAPIListObjectPartsHandler stay green. Compatibility: no wire or API change; objects an unfixed server already moved carry a poisoned object-level actual-size and need a rewrite or resync. Fixes #119 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
2 tasks done
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
Trusted SSE-C replication uploads multipart parts as raw ciphertext with the ciphertext length as
Content-Length, anderasureObjects.PutObjectPartonly derived the plaintext length when the caller passed a negative size, so every replicated SSE-C part persisted the ciphertext length asActualSize. On the replica,partNumberToRangeSpecturned those lengths into a plaintext range, soGET/HEAD ?partNumber=Nreturned the wrong bytes with a shiftedContent-Range, and a later decommission or rebalance re-uploaded the parts with the stale value and recomputed the object-levelactual-sizefrom their sum, after which a whole-objectGETadvertised aContent-Lengthlarger than the body it wrote.The fix derives the plaintext length of an encrypted, uncompressed part from the bytes actually written in
PutObjectPart(the single point where a part is persisted, covering replication, decommission and rebalance), rejects a length that cannot be a valid encrypted stream before the part is committed, and derives part lengths frompart.SizeinpartNumberToRangeSpecfor encrypted, uncompressed objects so replicas already on disk read correctly without a resync. Compressed parts keepActualSize.Fixes #119. The issue body is the plan agreed with the Codex reviewer (2 rounds). Adversarial Codex review of this implementation: round 1 FAIL (three required test-coverage findings: protocol assertions only logged, no independent guard for the read-side repair, malformed-length paths untested), round 2 PASS with two optional suggestions (a compressed fixture that detects removal of the compression exclusion, a comment wording), both applied.
Motivation and Context
ObjectPart.Sizeand the part-number read contract are defined in terms of the uploaded plaintext; a replica must serve the same bytes for?partNumber=Nas its source. Inherited from upstream, which carries byte-identical code inpartNumberToRangeSpecand in the replication send.How to test this PR?
TestAPISSECReplicaPartNumberReads: a three-part SSE-C object (5 MiB, 5 MiB, 1 MiB) is replayed through the trusted replication write path; the replica's partActualSizevalues, andGET/HEAD ?partNumber=Nstatus,Content-Length,Content-Rangeand bytes are asserted against independent prefix sums and the source for every part. Fails on main (parts record 5245440/5245440/1049088, ranges shifted by 2560/2560/5120 bytes), passes with the fix.TestSSECReplicaPartActualSizeDataMovement: replays such a replica through the data-movement path (DataMovement: true, noReplicationRequest) and asserts part and object-level sizes stay at plaintext values and the whole-objectGETadvertises exactly the bytes it writes. Fails on main (objectactual-size11539968 for an 11534336-byte body).TestPartNumberToRangeSpecEncryptedParts: unit guard for the read-side repair with a stale-metadata fixture that bypasses the writer (parts recording the ciphertext length), the correct-metadata, plaintext and compressed cases, a malformed 31-byte part reported aserrObjectTamperedbypartNumberToRangeSpec,NewGetObjectReaderandsetObjectHeaders, and a zero-length trailing part accepted. With the read-side derivation disabled the stale case fails.TestAPISSECReplicaMalformedPartIsRejected: a trusted SSE-C replica part of 31 bytes is rejected withXMinioObjectTamperedand nothing is committed; the real ciphertext still uploads on the same upload.Must-stay-green, all passing:
TestAPIGetObjectWithPartNumberHandler(includingenc-mp-*),TestAPISSECMultipartReplicationTrust,TestAPIListObjectPartsHandler,TestAPIGetObjectAttributesAuthenticatesSSECKey,TestAPIGetObjectAttributesSSECReplicationAuthz,TestObjectAPIPutObjectPart,TestAPICompleteMultipartFullObjectVariants,TestAPIReplicationTrustProtectsSSECReads.go vetclean,gofmt -l cmdempty, golangci-lint 0 issues on./cmd/....Compatibility impact
No wire or API change. Healthy local uploads are unaffected: for an encrypted part the derived length equals the caller's value. Replicas already on disk with stale part sizes read correctly from the next request. Objects that an unfixed server already moved (decommission/rebalance) carry a poisoned object-level
actual-sizeand still need a rewrite or resync; the fix stops the amplification but does not undo it. A malformed replicated part now fails the write withXMinioObjectTamperedinstead of being stored; its HTTP status follows #110.Types of changes
Checklist:
git commit -s) per the DCOmake verifiersequivalent: gofmt clean, go vet clean, golangci-lint 0 issues on./cmd/...pgsty/silo.pgsty.com(release fix note)🤖 Generated with Claude Code
https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe