Skip to content

[Bug] - x-amz-content-sha256 is ignored in public buckets PutObject #1423

@niksis02

Description

@niksis02

Describe the bug
When creating an object with PutObject in public buckets by providing invalid/incorrect x-amz-content-sha256 versitygw ignores it.

To Reproduce

// create a bucket
aws s3api create-bucket --bucket test

// make the bucket public
aws s3api put-bucket-policy --bucket test --policy file://policy.json

// Attempt to put an object with invalid x-amz-content-sha256
curl -v -i -X PUT "http://localhost:7070/test/hello" -H "x-amz-content-sha256: invalid_sha256" -H "Content-Length: 100" --data-binary @data.bin

Where policy.json is:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Statement1",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:*",
            "Resource": "arn:aws:s3:::test"
        },
        {
            "Sid": "Statement2",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:*",
            "Resource": "arn:aws:s3:::test/*"
        }
    ]
}

And data.bin is a rangom 100 length file.

Expected behavior
The gateway should return an error like:

<?xml version="1.0"?>
<Error>
  <Code>XAmzContentSHA256Mismatch</Code>
  <Message>The provided 'x-amz-content-sha256' header does not match what was computed.</Message>
  <ClientComputedContentSHA256>invalid_sha256</ClientComputedContentSHA256>
  <S3ComputedContentSHA256>aa58b21b01d6b8a99c1a5856962dbac36c758a79dc0a77c2e013ce2c39ecdc8a</S3ComputedContentSHA256>
  <RequestId>AHGMD5Z600MWF7PS</RequestId>
  <HostId>N7coEYwRhqN0U1R9LQskxDGfN9ip1uicH22LkiFVPYNomg9XbCf3SrRPVeZmq0L8OVn1H9lP3l4=</HostId>
</Error>

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions