Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix signature mismatch by sorting query parameters #299

Merged
merged 1 commit into from
Aug 18, 2024

Conversation

cpick
Copy link
Contributor

@cpick cpick commented Aug 14, 2024

https://cloud.google.com/storage/docs/authentication/canonical-requests#about-query-strings

The parameters in the query string must be sorted by name using a
lexicographical sort by code point value.

Fixes #298

https://cloud.google.com/storage/docs/authentication/canonical-requests#about-query-strings
> The parameters in the query string must be sorted by name using a
> lexicographical sort by code point value.

Fixes yoshidan#298
@cpick
Copy link
Contributor Author

cpick commented Aug 14, 2024

A simpler option that I had tested locally would be to just change query_parameter from a HashMap into a BTreeMap. This would require fewer allocations, but would be an API-breaking change and would still generate a signature mismatch if a user included a key that sorted lexicographically lower than "X-Goog-SignedHeaders" in query_parameters.

@yoshidan yoshidan added the safe to test safe to test label Aug 16, 2024
@yoshidan yoshidan merged commit e07d0b6 into yoshidan:main Aug 18, 2024
8 of 9 checks passed
@yoshidan
Copy link
Owner

Thanks!

@cpick cpick deleted the sort-query-params branch September 25, 2024 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test safe to test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

storage: signed URL signature mismatch due to unordered query parameters
2 participants