Skip to content

Metadata-only CopyObject of a null version rewrites the data and leaves the metadata inconsistent #83

Closed

Description

@Vonng

Problem

The fix for #67 keeps the source compression metadata whenever CopyObjectHandler considers a copy metadata-only. That assumes the object layer will then leave the stored bytes alone. It does not.

erasureServerPools.CopyObject and erasureSets.CopyObject skip a data rewrite in exactly three cases and otherwise fall back to PutObject:

  1. dstOpts.VersionID != "" && srcOpts.VersionID == dstOpts.VersionID — in-place update of the addressed version
  2. !dstOpts.Versioned && srcOpts.VersionID == "" — in-place update of an unversioned object
  3. dstOpts.Versioned && srcOpts.VersionID != dstOpts.VersionID && !srcInfo.Legacy — a new version referencing the existing data

The reachable gap is a copy whose source is a null version on a bucket that gained versioning after the object was written. srcInfo.VersionID is empty, so the source-version substitution added for case 3 leaves it empty, no branch matches, the data is rewritten, and the preserved metadata still describes bytes that no longer exist.

Failure modes

All reproduced on main (ce456dba0), identical on ErasureSD and Erasure.

1. Compression disabled at copy time — loud corruption. Write a compressible object with compression on, enable bucket versioning, disable compression, then copy the key onto itself with x-amz-metadata-directive: REPLACE. Plaintext is stored while compression/actual-size are kept. GET fails with s2: corrupt input.

2. Compression enabled at copy time — silent data loss. The same sequence with compression turned on instead. PutObject consumes the S2 reader, so compressed bytes are stored, while the absent source markers are preserved. A 1572864-byte object becomes a 106-byte object, reported as size=106; GET returns 200 with 106 bytes and no error is raised.

3. SSE-C key rotation — unreadable object. The same trigger with an SSE-C rotation. The rotation branch only rewraps the object key and never re-encrypts, so the fallback writes the plaintext held by the source reader under metadata claiming SSE-C. GET fails with sio: unsupported version. This mode is inherited from upstream: reverting the source-version substitution introduced by the #67 fix makes ordinary versioned SSE-C rotations fail the same way, so that fix narrowed the defect rather than creating it.

Root cause

srcInfo.metadataOnly carries two meanings:

  • (a) request semantics — "this is a same-object metadata update", used by the ErrInvalidCopyDest validation
  • (b) storage semantics — "the object layer will not store new bytes"

The fix for #67 used (a) where (b) was required.

Scope

Only CopyObjectHandler is affected. The three other object-layer CopyObject callers that set metadataOnly — PostRestoreObjectHandler, erasureObjects.updateRestoreMetadata and batchKeyRotate — address the same version on both sides and never set Versioned, so they always reach case 1 or 2.

Failure modes 1 and 2 are not in any release: the #67 fix landed after RELEASE.2026-08-06T00-00-00Z, so they affect main only. Failure mode 3 predates the fork.

Proposed direction

  • State the object layer's rewrite decision once as a predicate the handler can evaluate, and use it at the two places that read metadataOnly for storage semantics: the compression metadata block and the SSE-C key-rotation shortcut. Fold in the later metadataOnly clearings for legacy sources and for server-side checksum recomputation, both of which force a rewrite.
  • When the rotation shortcut is skipped, the copy falls through to the ordinary re-encrypting path. That path authenticates the source key through the source decryptor, which is not built for zero-byte objects, so the key needs an explicit check to keep the change authentication-neutral. The underlying gap is Zero-byte SSE-C objects never authenticate the customer key #82.
  • Leave srcInfo.metadataOnly itself unchanged. Clearing it would produce the same stored bytes but would also flip the replication type from metadata to object replication and change object-sweeper behaviour, neither of which is needed here.
  • Cross-reference the predicate from both object-layer decision sites so the two cannot drift apart silently.

Acceptance criteria

  • A metadata-only copy of a null version records compression metadata describing the bytes actually stored, in both compression directions.
  • SSE-C key rotation on a null version yields an object readable with the new key, with its logical checksum intact.
  • A rotation the object layer must rewrite still rejects an incorrect source key with 403 AccessDenied and creates no new version.
  • Ordinary metadata-only copies, versioned self-referential copies, and full rewrites are unchanged.
  • No on-disk format change.

Relationship to other work

  • Follow-up to Metadata-only CopyObject can stamp compression metadata without rewriting data #67. Failure modes 1 and 2 are a regression of that fix.
  • Failure mode 3 is inherited from upstream.
  • Zero-byte SSE-C objects never authenticate the customer key #82 tracks the zero-byte SSE-C key authentication gap, which the explicit check above deliberately does not close.
  • A more thorough alternative — letting the object layer reference a null version so case 3 applies, which would also avoid rewriting the object body on every metadata-only copy of a pre-versioning object — was evaluated and deferred: it changes the persisted shape (the new version shares the null version's dataDir) and needs validation across replication, healing and usage accounting.

Activity

  1. added
    bug
    on Aug 29, 2026
  2. Vonng commented on Aug 29, 2026

    @Vonng
    MemberAuthor

    PR submitted

    The release candidate is PR #86, stacked on foundation PR #85 because the destination-key checksum fix must precede this CopyObject repair.

    The branch contains the two reviewed fixes plus reverse-direction compression, encrypted rewrite, predicate, and wrong/equal-key tests. Focused normal/race and the combined full CI-tagged suite pass locally. No old issue-64 federation twin was reintroduced.

  3. Vonng commented on Aug 29, 2026

    @Vonng
    MemberAuthor

    Resolved by #86. Metadata-only null-version CopyObject now keeps metadata/compression state consistent and correctly re-encrypts SSE-C data, including reverse-direction coverage. Final main 1be684b passed Go CI, VulnCheck, the full local race suite, and Test Release run 33254848256.

  4. moved this from Backlog to Done in Siloon Aug 29, 2026
  5. self-assigned this
    on Sep 15, 2026
  6. added theissue type on Sep 15, 2026
  7. added this to the 20260903 milestone on Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions