-
Notifications
You must be signed in to change notification settings - Fork 862
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
AWS4SigningResult.ForQueryParameters does not escape semicolons #1953
Comments
Appears to be reproducible using customer's code. It generates URL something like:
Not sure if semicolons should be escaped to Semicolon is not special in URLs themselves, but they are special in the parameter list in the query component (sometimes, they are used in place of &). Then they need to be escaped. Also refer https://skorks.com/2010/05/what-every-developer-should-know-about-urls/. Needs discussion with team since we also need to make sure there are no breaking changes. |
@ashishdhingra One thing I will point out is that the semicolon is being escaped to %3B while generating the signature.
aws-sdk-net/sdk/src/Core/Amazon.Runtime/Internal/Auth/AWS4Signer.cs Lines 926 to 929 in 82ec756
aws-sdk-net/sdk/src/Core/Amazon.Runtime/Internal/Auth/AWS4Signer.cs Lines 958 to 964 in 82ec756
Consequently, it seems like the AWS server must convert semicolon to %3B on the way in, in order for the signature to match, which is quite surprising. |
This appears to be a breaking change and should be opt-in behavior. |
hello @ashishdhingra I what this might caused by not identical code which use for compose path and signature
and if go little bit deeper
which deprecated in .net 6.0 might create issues https://docs.microsoft.com/en-us/dotnet/api/system.uri.escapeuristring?view=net-6.0 P.S AWS CLI compose correct URL - encode |
@ashishdhingra By that logic all bug fixes would have to be opt-in on the off chance that someone was relying on the incorrect behavior. |
This is fixed in latest version, refer
|
|
Description
The
ForQueryParameters
method does not escape special characters. In particular, if there are multiple signed headers, then it includes them delimited by a literal semicolon instead of%3B
. This is a violation of the RFC spec, and also causes issues with parsers in other languages. For example, Go treats the semicolon either as a delimiter between query parameters or as an invalid character, depending on the language version.aws-sdk-net/sdk/src/Core/Amazon.Runtime/Internal/Auth/AWS4SigningResult.cs
Lines 93 to 106 in ce85687
Reproduction Steps
The resulting URL will have
X-Amz-SignedHeaders=host;x-custom-header
instead ofX-Amz-SignedHeaders=host%3Bx-custom-header
.(Yes, we are referencing some internal packages here, until #1905 is addressed. Regardless, this bug still needs to be fixed.)
Resolution
The
ForQueryParameters
method must escapeSignedHeaders
while constructing the query string. In particular, semicolons must be replaced with%3B
.Alternatively, use
AWSSDKUtils.UrlEncode
, as is done internally while generating the signature.This is a 🐛 bug-report
The text was updated successfully, but these errors were encountered: