fix: enforce SignedHeaders validation for SigV4 requests#2158
Open
niksis02 wants to merge 1 commit into
Open
Conversation
Validate required signed headers for both Authorization-header SigV4 requests and presigned URLs. The required signed header set is now `host` plus every incoming header with the `x-amz-` prefix. During request reconstruction, signed headers and explicitly ignored headers are copied into the generated request used for signature verification. If an incoming `x-amz-*` header is present but missing from the client-provided `SignedHeaders`, return `AccessDenied` with a `HeadersNotSigned` field. The `host` header remains part of the canonical request and signed header calculation. Previously, a client could sign a request without an S3 control header and then add that header after signing. For example, a presigned `PUT` URL could be generated with only `host` signed, then the actual request could include an unsigned `X-Amz-Tagging` or `X-Amz-Copy-Source` header. Because the verifier reconstructed the request only from `SignedHeaders`, that extra header was omitted from signature calculation and could pass authentication even though it changed the request semantics. This is now rejected with `AccessDenied`. Expose v4 helper methods for checking required and ignored headers, and update canonical header signing so ignored headers can still be included when a client explicitly lists them in `SignedHeaders`, while `Authorization` remains excluded from signature calculation.
891c53b to
5774702
Compare
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.
Validate incoming request headers against the client-provided
SignedHeadersfor both Authorization-headerSigV4requests and presigned URLs.During request reconstruction, only signed headers and explicitly ignored headers are copied into the generated request used for signature verification. If an incoming header is present, is required to be signed, and is missing from
SignedHeaders, return a newAccessDeniedresponse with aHeadersNotSignedfield.Previously, a client could sign a request without an S3 control header and then add that header after signing. For example, a presigned
PUTURL could be generated with onlyhostsigned, then the actual request could include an unsignedX-Amz-TaggingorX-Amz-Copy-Sourceheader. Because the verifier reconstructed the request only fromSignedHeaders, that extra header was omitted from signature calculation and could pass authentication even though it changed the request semantics. This is now rejected withAccessDenied.Update
SigV4header rules so allX-Amz-*headers are treated as required signed headers to match the S3 behavior.Expose v4 helper methods for checking required and ignored headers, and update canonical header signing so ignored headers can still be included when a client explicitly lists them in
SignedHeaders, whileAuthorizationremains excluded from signature calculation.