Repository navigation
S3: check the Content-MD5 of put_object and upload_part - #10508
Open
jayhemnani9910 wants to merge 1 commit into
Open
jayhemnani9910 wants to merge 1 commit into
jayhemnani9910 wants to merge 1 commit into
Conversation
A Content-MD5 that did not match the body was accepted and the object stored. S3 rejects it with BadDigest, and a value that is not a base64 MD5 digest with InvalidDigest.
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.
A
Content-MD5that doesn't match the body is accepted and the object is stored:Code that relies on Content-MD5 to catch a corrupted upload can't test that path against moto.
put_objectandupload_partnow decode the header and compare it with the MD5 of the body: a value that isn't base64 for 16 bytes raisesInvalidDigest, a mismatch raisesBadDigest, both 400. Requests without the header are unchanged, so boto3's default CRC32 checksums andupload_fileobjare not affected.test_put_object_and_upload_part_check_content_md5intests/test_s3/test_s3.pyfails without the change.pytest tests/test_s3passes (564 passed), ruff 0.14.10 clean. Againstmoto_serverfrom this branch: the two calls above return BadDigest and InvalidDigest, the correct MD5 still stores the object, andupload_fileobjof 9 MiB and a plainput_objectstill work.