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

SocketsHttpHandler: Proxied IPv6 requests have incorrectly formatted host/port in request line #25677

Closed
caesar-chen opened this issue Mar 29, 2018 · 12 comments
Assignees
Labels
Milestone

Comments

@caesar-chen
Copy link
Contributor

On WinHttpHandler, we will append [] around the IPv6 address.
"GET http://[::1234]/ HTTP/1.1", "Proxy-Connection: Keep-Alive", "Host: [::1234]"

On SocketsHttpHandler, currently we don't:
"GET http://::1234/ HTTP/1.1", "Host: [::1234]"

Also, if we specify a port number, SocketsHttpHandler will strip that in the uri send to the proxy as well.

WinHttpHandler:
In value: List ["GET http://[::1234]:8080/ HTTP/1.1", "Proxy-Connection: Keep-Alive", "Host: [::1234]:8080"]

SocketsHttpHandler:
In value: List ["GET http://::1234/ HTTP/1.1", "Host: [::1234]:8080"]

@karelz
Copy link
Member

karelz commented Mar 30, 2018

@Caesar1995 that seems rather impactful - doesn't it mean that proxies won't work with IPv6 at all? Moving to 2.1 for now ...

Also, I am concerned about missing "Proxy-Connection: Keep-Alive" header - we should file separate bug IMO - @geoffkizer @stephentoub thoughts?

@caesar-chen
Copy link
Contributor Author

doesn't it mean that proxies won't work with IPv6 at all?

I don't know, it unlikely doesn't work. I can do a testing on this.

@caesar-chen caesar-chen self-assigned this Mar 30, 2018
@geoffkizer geoffkizer changed the title The Uri sent to the proxy is not correctly formatted on SocketsHttpHandler SocketsHttpHandler: Proxied IPv6 requests have incorrectly formatted host/port in request line Apr 1, 2018
@geoffkizer
Copy link
Contributor

It seems really weird that the port handling is screwed up for IPv6 but not IPv4. Do we understand this? Do we have an issue with IPv4 as well?

(The hostname handling doesn't surprise me that much...)

@caesar-chen
Copy link
Contributor Author

I found out setting up environment and do IPv6 multi machine testing cost me more time, and I'm blocked on this approach.

I think a better next step for me is that: testing the behavior on .NET Framework & WinHttpHandler about the port/host name handling for IPv6 and IPv4, to see if there is a difference with the SocketsHttpHandler. If Framework and WinHttpHandler behave the same, we will need to fix the SocketsHttpHandler.

@geoffkizer
Copy link
Contributor

It seems like you can test this with a fake proxy, same as you're doing here: dotnet/corefx#28578 (review)

@geoffkizer
Copy link
Contributor

BTW it looks to me like we're not sending the port in the IPv4 case either. This is bad.

@geoffkizer
Copy link
Contributor

In the proxy case, the Host header and the authority part of the request Uri should be the same. We should be able to use the same code for both.

@geoffkizer
Copy link
Contributor

We should add a bunch of tests here for various combinations -- DNS hostname, IPv4 hostname, IPv6 hostname, default port/non default port, secure/nonsecure.

Also interesting to check how we handle if you specify the default port explicitly, e.g. RequestUri = "http://foo.com:80/" or "https://foo.com:443/". I believe that SocketHttpHandler will strip off the port if it's the default, which I believe is correct. I'm curious what other handlers do...

@caesar-chen
Copy link
Contributor Author

Tested on Framework, the behavior is the same as WinHttpHandler:

IPv6 testing:

On Framework & WinHttpHandler:

No port provided:
In value: List<String> ["GET http://[::1234]/ HTTP/1.1", "Host: [::1234]", "Proxy-Connection: Keep-Alive"]

With port:
In value: List<String> ["GET http://[::1234]:8080/ HTTP/1.1", "Host: [::1234]:8080", "Proxy-Connection: Keep-Alive"]

On SocketsHttpHandler:

No port provided:
In value: List<String> ["GET http://::1234/ HTTP/1.1", "Host: [::1234]"]

With port:
In value: List<String> ["GET http://::1234/ HTTP/1.1", "Host: [::1234]:8080"]

Summary:

  1. [] is missing in request line.
  2. port number is missing.
  3. Proxy-Connection: Keep-Alive is missing.

IPv4 testing:

On Framework & WinHttpHandler:

No port provided:
In value: List<String> ["GET http://321.123.456.789/ HTTP/1.1", "Proxy-Connection: Keep-Alive", "Host: 321.123.456.789"]

With port:
List<String> ["GET http://321.123.456.789:8080/ HTTP/1.1", "Proxy-Connection: Keep-Alive", "Host: 321.123.456.789:8080"]

On SocketsHttpHandler:

No port provided:
In value: List<String> ["GET http://321.123.456.789/ HTTP/1.1", "Host: 321.123.456.789"]

With port:
In value: List<String> ["GET http://321.123.456.789/ HTTP/1.1", "Host: 321.123.456.789:8080"]

Summary:

  1. port number is missing.
  2. Proxy-Connection: Keep-Alive is missing.

@caesar-chen
Copy link
Contributor Author

BTW it looks to me like we're not sending the port in the IPv4 case either. This is bad.

Yes, the port is not sent in IPv4 case. We should fix it.

@geoffkizer
Copy link
Contributor

Let's fix the IPv6 handling and the port handling. Let's file a separate issue on Proxy-Connection since that's a different issue.

@caesar-chen
Copy link
Contributor Author

Let's fix the IPv6 handling and the port handling.

Will do.

Let's file a separate issue on Proxy-Connection since that's a different issue.

Opened dotnet/corefx#28708 to track it.

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 2.1.0 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants