mirror of
https://github.com/pgsty/minio.git
synced 2026-08-09 07:43:29 +03:00
fix: accept full object multipart completion without part checksums
CompleteMultipartUpload compared the per-part checksum taken from the request body against the stored part checksum unconditionally, so a client that sent only PartNumber and ETag for each part failed with InvalidPart. AWS S3 requires part level checksums in the completion body only for composite checksum types. For full object types the client sends the object level checksum in the request headers instead and does not retain per-part values - that is the point of FULL_OBJECT. Reproduced with boto3 1.43.58: it puts x-amz-checksum-crc32 on each UploadPart and the full object checksum on the completion headers, but emits only ETag and PartNumber in the completion body. A caller could only get such an upload through by collecting the per-part checksums from the UploadPart responses and echoing them back, which is exactly the bookkeeping FULL_OBJECT exists to avoid and which no off-the-shelf SDK call does. minio-go does echo them, which is why mc never hit this. Treat the part checksum as optional when the upload declared a full object checksum type and the client sent no part checksum at all. A part carrying any checksum is still validated against the stored one - including one sent under the wrong algorithm, which cannot match and is rejected - composite uploads keep requiring a checksum for every part, and the merged object checksum is still computed from the server stored, upload time validated part checksums, never from client supplied values, so integrity is unchanged. Covered by API level tests over CRC32, CRC32C and CRC64NVME on both the single drive and erasure backends, with guards for a wrong object checksum, a wrong part checksum, a part checksum under another algorithm, a mix of present and omitted part checksums, an absent object checksum, and composite uploads still requiring every part checksum. Fixes #31 Reported-by: Christophe Bornet <cbornet@users.noreply.github.com> Co-authored-by: ChatGPT <noreply@openai.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1290,10 +1290,26 @@ func (er erasureObjects) CompleteMultipartUpload(ctx context.Context, bucket str
|
||||
hash.ChecksumSHA256.String(): part.ChecksumSHA256,
|
||||
hash.ChecksumCRC64NVME.String(): part.ChecksumCRC64NVME,
|
||||
}
|
||||
if wantCS[checksumType.String()] != crc {
|
||||
gotCS := wantCS[checksumType.String()]
|
||||
var suppliedAnyCS bool
|
||||
for _, v := range wantCS {
|
||||
if v != "" {
|
||||
suppliedAnyCS = true
|
||||
break
|
||||
}
|
||||
}
|
||||
// Part checksums are optional in the CompleteMultipartUpload body when
|
||||
// the upload was created with a full object checksum type: clients send
|
||||
// the object level checksum instead and do not retain part checksums.
|
||||
// A part that carries any checksum at all is still validated against
|
||||
// what we stored - including one sent under the wrong algorithm, which
|
||||
// cannot match and is rejected. The object level checksum, if supplied,
|
||||
// is verified against the merged part checksums below.
|
||||
allowMissingPartCS := checksumType.FullObjectRequested() && !suppliedAnyCS
|
||||
if !allowMissingPartCS && gotCS != crc {
|
||||
return oi, InvalidPart{
|
||||
PartNumber: part.PartNumber,
|
||||
ExpETag: wantCS[checksumType.String()],
|
||||
ExpETag: gotCS,
|
||||
GotETag: crc,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user