Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@klauspost
Copy link
Contributor

@klauspost klauspost commented Apr 1, 2025

Description

Accept anonymous requests with trailing headers.

Fixes #21005

With modified minio-go (will send PR):

<DEBUG> PUT /tbb/mc.exe HTTP/1.1
Host: 127.0.0.1:9001
User-Agent: MinIO (windows; amd64) minio-go/v7.0.90 mc/DEVELOPMENT.GOGET
Content-Length: 44301288
Accept-Encoding: zstd,gzip
Content-Encoding: aws-chunked
Content-Type: application/x-msdownload
X-Amz-Content-Sha256: STREAMING-UNSIGNED-PAYLOAD-TRAILER
X-Amz-Date: 20250401T150402Z
X-Amz-Decoded-Content-Length: 44295168
X-Amz-Trailer: x-amz-checksum-crc32

mc: <DEBUG> HTTP/1.1 200 OK
Content-Length: 0
Accept-Ranges: bytes
Date: Tue, 01 Apr 2025 15:04:02 GMT
Etag: "46273a30f232dc015ead1c0da8925c98"
Server: MinIO
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Origin
Vary: Accept-Encoding
X-Amz-Checksum-Crc32: wElc/A==
X-Amz-Id-2: 7987905dee74cdeb212432486a178e511309594cee7cb75f892cd53e35f09ea4
X-Amz-Request-Id: 18323A0F322B41C8
X-Content-Type-Options: nosniff
X-Ratelimit-Limit: 2478
X-Ratelimit-Remaining: 2478
X-Xss-Protection: 1; mode=block

Tested on multipart uploads as well - and of course checked that is still rejected on regular buckets.

How to test this PR?

Will send minio-go fix that will do this encoding.

Types of changes

  • New feature (non-breaking change which adds functionality)

Do not fail on anonymous requests with trailing headers.

Fixes minio#21005

With modified minio-go (will send PR):

```
<DEBUG> PUT /tbb/mc.exe HTTP/1.1
Host: 127.0.0.1:9001
User-Agent: MinIO (windows; amd64) minio-go/v7.0.90 mc/DEVELOPMENT.GOGET
Content-Length: 44301288
Accept-Encoding: zstd,gzip
Content-Encoding: aws-chunked
Content-Type: application/x-msdownload
X-Amz-Content-Sha256: STREAMING-UNSIGNED-PAYLOAD-TRAILER
X-Amz-Date: 20250401T150402Z
X-Amz-Decoded-Content-Length: 44295168
X-Amz-Trailer: x-amz-checksum-crc32

mc: <DEBUG> HTTP/1.1 200 OK
Content-Length: 0
Accept-Ranges: bytes
Date: Tue, 01 Apr 2025 15:04:02 GMT
Etag: "46273a30f232dc015ead1c0da8925c98"
Server: MinIO
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Origin
Vary: Accept-Encoding
X-Amz-Checksum-Crc32: wElc/A==
X-Amz-Id-2: 7987905dee74cdeb212432486a178e511309594cee7cb75f892cd53e35f09ea4
X-Amz-Request-Id: 18323A0F322B41C8
X-Content-Type-Options: nosniff
X-Ratelimit-Limit: 2478
X-Ratelimit-Remaining: 2478
X-Xss-Protection: 1; mode=block
```

Tested on multipart uploads as well.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses the issue of handling anonymous requests with trailing headers by adjusting the authorization logic in the streaming signature handling code. Key changes include:

  • Splitting the case for authTypeStreamingUnsignedTrailer from the combined case.
  • Adding a conditional to treat ErrMissingFields as a valid anonymous request.
  • Refining the authorization flow based on request header contents.
Comments suppressed due to low confidence (2)

cmd/auth-handler.go:759

  • Please ensure that unit tests specifically cover the authTypeStreamingUnsignedTrailer case, verifying that ErrMissingFields is interpreted correctly as an indication of an anonymous request.
case authTypeStreamingUnsignedTrailer:

cmd/auth-handler.go:761

  • [nitpick] Consider expanding the inline comment to explicitly clarify that encountering ErrMissingFields signifies an anonymous request with zero-valued credentials, ensuring future maintainability.
if s3Err == ErrMissingFields {

klauspost added a commit to klauspost/minio-go that referenced this pull request Apr 1, 2025
Trailing headers would be ignored on anonymous uploads.

Send these as unsigned aws chunked uploads.

Requires minio/minio#21095
@harshavardhana harshavardhana merged commit 5f243fd into minio:master Apr 1, 2025
22 checks passed
@klauspost klauspost deleted the fix-anon-trailing-headers branch April 1, 2025 19:22
harshavardhana pushed a commit to minio/minio-go that referenced this pull request Apr 2, 2025
Trailing headers would be ignored on anonymous uploads.

Send these as unsigned aws chunked uploads.

Requires minio/minio#21095
harshavardhana pushed a commit that referenced this pull request May 30, 2025
Do not fail on anonymous requests with trailing headers.

Fixes #21005

With modified minio-go (will send PR):

```
<DEBUG> PUT /tbb/mc.exe HTTP/1.1
Host: 127.0.0.1:9001
User-Agent: MinIO (windows; amd64) minio-go/v7.0.90 mc/DEVELOPMENT.GOGET
Content-Length: 44301288
Accept-Encoding: zstd,gzip
Content-Encoding: aws-chunked
Content-Type: application/x-msdownload
X-Amz-Content-Sha256: STREAMING-UNSIGNED-PAYLOAD-TRAILER
X-Amz-Date: 20250401T150402Z
X-Amz-Decoded-Content-Length: 44295168
X-Amz-Trailer: x-amz-checksum-crc32

mc: <DEBUG> HTTP/1.1 200 OK
Content-Length: 0
Accept-Ranges: bytes
Date: Tue, 01 Apr 2025 15:04:02 GMT
Etag: "46273a30f232dc015ead1c0da8925c98"
Server: MinIO
Strict-Transport-Security: max-age=31536000; includeSubDomains
Vary: Origin
Vary: Accept-Encoding
X-Amz-Checksum-Crc32: wElc/A==
X-Amz-Id-2: 7987905dee74cdeb212432486a178e511309594cee7cb75f892cd53e35f09ea4
X-Amz-Request-Id: 18323A0F322B41C8
X-Content-Type-Options: nosniff
X-Ratelimit-Limit: 2478
X-Ratelimit-Remaining: 2478
X-Xss-Protection: 1; mode=block
```

Tested on multipart uploads as well.
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.

Incompatiblity of anonymous PUT request to public bucket with S3 Java SDK version 2.30

2 participants