Skip to content

fix(s3): send a CRC32 checksum so Object Lock buckets accept multipart uploads - #550

Open
life5ign wants to merge 1 commit into
databacker:mainfrom
life5ign:fix/s3-object-lock-checksum
Open

life5ign wants to merge 1 commit into
databacker:mainfrom
life5ign:fix/s3-object-lock-checksum

Conversation

@life5ign

Copy link
Copy Markdown

Problem

Uploading a dump larger than the multipart threshold (5 MiB) to an S3 bucket
with Object Lock enabled fails:

InvalidRequest: Content-MD5 OR x-amz-checksum- HTTP header is required for
Put Part requests with Object Lock parameters

S3 requires a Content-MD5 or x-amz-checksum-* header on every write to an
Object Lock bucket, including each UploadPart. manager.Uploader in
aws-sdk-go-v2 only adds a per-part checksum when ChecksumAlgorithm is set on
the PutObjectInput, and pkg/storage/s3 does not set it. Dumps under 5 MiB
go up as a single PutObject and succeed, so the failure only shows once a
database grows past the threshold.

Object Lock (COMPLIANCE or GOVERNANCE mode) is a common way to make backups
immutable, so this affects anyone using it for ransomware protection or
retention requirements.

Change

Set ChecksumAlgorithm: types.ChecksumAlgorithmCrc32 on the upload input in
pkg/storage/s3/s3.go. The uploader then computes a CRC32 for each part and
S3 stores a composite checksum for the object.

Testing

Built from v1.5.0 with this change and ran dump --once against a bucket with
Object Lock COMPLIANCE and SSE-KMS default encryption. A ~14 MB dump uploaded
in 3 parts; s3api get-object-attributes shows a ChecksumCRC32 composite
over 3 parts, and the object restored cleanly. Without the change the same
upload fails with the error above. The patch applies unchanged to main and
is gofmt-clean.

Compatibility

CRC32 checksums are supported by AWS S3 and by current MinIO. Some older
S3-compatible stores may reject x-amz-checksum-* headers; if that is a
concern I'm happy to make the algorithm configurable (for example an
--s3-checksum option defaulting to CRC32, with none to disable) instead
of setting it unconditionally.

…t uploads

S3 requires Content-MD5 or an x-amz-checksum-* header on every write to a
bucket with Object Lock, including each UploadPart. The SDK uploader only
adds a per-part checksum when ChecksumAlgorithm is set, so dumps over the
5 MiB multipart threshold were refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@deitch

deitch commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

This looks good in principle, but as you said, I would be concerned about older stores. I think this makes sense as the default, but it would be good to add an option to opt out of it.

@deitch

deitch commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Also DCO requires signature.

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.

2 participants