You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have verified all of my SDK modules are up-to-date (you can perform a bulk update with go get -u github.com/aws/aws-sdk-go-v2/...)
Describe the bug
When assembling the canonical query string for the canonical request, the AWS docs specify that query parameters should first be percent-encoded to cover for all special characters, and after that the parameters should be sorted. However, v4.Signer currently does the sorting first, and then the percent-encoding. This seems to cause a signature mismatch when the query parameters contain special characters in such a way that it affects their position after sorting.
CanonicalQueryString – The URI-encoded query string parameters. You URI-encode each name and value individually. You must also sort the parameters in the canonical query string alphabetically by key name. The sorting occurs after encoding.
Looking at the implementation, it seems the issue is that query params uses the built in url.URL and writes it back using url.Values.Encode(). This automatically handles param encoding and sorting, but in the opposite order. There might be need for a custom encoder here.
Additional Information/Context
The example above is contrived. We are not using emoji in parameters, but we do have a real production cases where there are special characters in the parameters that do affect the sorting and does break the signature.
adev-code
added
investigating
This issue is being investigated and/or work is in progress to resolve the issue.
needs-review
This issue or pull request needs review from a core team member.
p2
This is a standard priority issue
and removed
needs-triage
This issue or PR still needs to be triaged.
investigating
This issue is being investigated and/or work is in progress to resolve the issue.
labels
Jan 22, 2025
adev-code
added
queued
This issues is on the AWS team's backlog
and removed
needs-review
This issue or pull request needs review from a core team member.
labels
Jan 30, 2025
Acknowledgements
go get -u github.com/aws/aws-sdk-go-v2/...
)Describe the bug
When assembling the canonical query string for the canonical request, the AWS docs specify that query parameters should first be percent-encoded to cover for all special characters, and after that the parameters should be sorted. However, v4.Signer currently does the sorting first, and then the percent-encoding. This seems to cause a signature mismatch when the query parameters contain special characters in such a way that it affects their position after sorting.
https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv-create-signed-request.html
Regression Issue
Expected Behavior
Using a URL query
a=1&🍺=2
, the signer should use the following canonical query stringFirst the query param names and values should be percent-encoded, then sorted as above since "%" comes before "a".
Current Behavior
Using a URL query
a=1&🍺=2
, the signer uses the following canonical query stringThis indicates that the sorting happens before encoding, and "a" comes before "🍺".
Full log output:
Reproduction Steps
Possible Solution
Looking at the implementation, it seems the issue is that query params uses the built in
url.URL
and writes it back usingurl.Values.Encode()
. This automatically handles param encoding and sorting, but in the opposite order. There might be need for a custom encoder here.Additional Information/Context
The example above is contrived. We are not using emoji in parameters, but we do have a real production cases where there are special characters in the parameters that do affect the sorting and does break the signature.
AWS Go SDK V2 Module Versions Used
github.com/aws/aws-sdk-go-v2@v1.33.0 github.com/aws/smithy-go@v1.22.1
github.com/aws/aws-sdk-go-v2@v1.33.0 github.com/jmespath/go-jmespath@v0.4.0
github.com/aws/aws-sdk-go-v2@v1.33.0 go@1.21
Compiler and Version used
go version go1.23.2 darwin/arm64
Operating System and version
macOS Sonoma 14.7.2
The text was updated successfully, but these errors were encountered: