-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
AWS SigV4 canonicalization does not handle pre-encoded URL components correctly #16927
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
Comments
I spent 10 minutes just now trying to find out how colons should be treated in this weirdo system but I failed. I don't know the correct way. The canon_string function encodes colons as |
If there is any further information I can provide, let me know. This was discovered while I was creating a burp suite extension to transform APIs to curl with sigv4 signing and observed the above behavior when testing. |
We need to find the detailed explanation/spec for how the canonicalization of that part of the URL is meant to work for sigv4. I couldn't find it. Then we need to make sure the code does what the spec says. Presumably by someone using adjusted code against a live server - I personally don't have anything I can test this against. |
I can fix this one if you like. |
That would be totally awesome! 🥳 |
I did this
I'm observing that when a URL contains already-encoded characters (e.g. %3A), the canonical request generated by cURL's AWS SigV4 signing (in lib/http_aws_sigv4.c, particularly in the canon_string() function) does not match the expected canonical request, leading to signature mismatches.
For example, when a URL containing %3A is used, the canonical string produced seems to miss the inclusion of the x-amz-security-token header in the signed headers, resulting in a signature error.
I have compared this behavior with awscurl, which handles the encoding correctly. I suspect that the logic in canon_string() (lines XYZ–ABC in lib/vauth/aws_sigv4.c) is not correctly normalizing already-encoded characters.
Could you please review this section and consider a fix so that pre-encoded URL components are handled consistently?
I expected the following
Running the above command fails to handle the %3A encoded characters already present in the URL. If I un-encode the URL, the request fails to the service. Encoding it however fails signing.
The error coming back:
So it looks like it is encoding the '%' again and failing to recognize the '%3A' as a valid hex digit
Example with single quote and unencoded characters
curl/libcurl version
curl 8.13
operating system
Ubuntu 22.04
The text was updated successfully, but these errors were encountered: