-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
SigV4 fails when standard port included in --endpoint-url #2883
Comments
Thanks for reporting, I can repro this issue as well. Regarding the differences in behavior, that's likely due to us switching the default signature used for S3 from the older signature version to sigv4 (which signs the host header) in more recent versions of the CLI. We'll get this fixed. |
Looking into this, it seems we're also passing along the auth info since we're setting the host header to just be the netloc. |
To be more clear, that's only the auth info from the url. So we'll happily set the host to |
Supplying port 80 or 443 with host (ex. `storage.googleapis.com:443`) fails in v4 signing. Remove these default ports to prevent signature matching failure. Similar issue: aws/aws-cli#2883
Supplying port 80 or 443 with host (ex. `storage.googleapis.com:443`) fails in v4 signing. Remove these default ports to prevent signature matching failure. Similar issue: aws/aws-cli#2883
aws#2883) * Adds missing unit tests for LayerBuildDefinition in build_graph * fix black formatting
If the
--endpoint-url
includes a port that is the default for the specified scheme (e.g. 80 for HTTP, and 443 for HTTPS), then SigV4 includes this port in the host header used when generating the string to sign, however the port is stripped from the host header before being sent to the server. This results in a 403 as the client and server generate different strings to sign.This can be reproduced using:
We have tested this on our s3-compatible service, as well as the real s3 and both servers behave the same. When testing with a non-standard port, the aws cli includes the port in the string to sign AND sends it in the host header, ensuring the client and server generate the same string to sign.
RFC 2616 (https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23) says
A "host" without any trailing port information implies the default port for the service requested (e.g., "80" for an HTTP URL)
so I'm assuming the underlying HTTP implementation is stripping it out of the host header because it's not technically required, however by this point it has already been included in the string to sign.Included below is debug output and corresponding tcpdump packet trace outputs that show this behaviour. We tested on v1.11.132 and v1.11.168. We believe this used to behave differently in earlier releases.
v1.11.168 - Standard port (80) - tested against the real S3 service:
AWS CLI debug:
Packet trace:
v1.11.168 - Standard port (80) - tested against our s3-compatible service:
AWS CLI debug:
Packet trace:
v1.11.132 - Non-standard port (8080) - tested against our s3-compatible service:
AWS CLI debug:
Packet trace:
The text was updated successfully, but these errors were encountered: