-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Extra round trip due to 407 proxy authentication when using proxy with basic auth #66244
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsDescriptionNot sure, but this may be the same as #24865 . I'm doing https requests using a proxy that requires basic auth using I've got an EventListener setup for http and am seeing that each request is doing a CONNECT to the proxy and getting nacked with 407 and then following up with another request that correclty includes the Is there any way to force the initial request to include the authorization information (or can i include a custom header on the initial connect)? This extra round trip is highly inefficient. Reproduction StepsHttpClient request via proxy that requires username/password Expected behaviorinclude Proxy-Authorization on initial request if the configured WebProxy includes NetworkCredentials Actual behavior407s Regression?unknown Known WorkaroundsNo response Configuration.net 6, windows x64 Other informationNo response
|
You can try to set |
yep, tried PreAuthenticate. no dice. IMO there should be a way to either force the header for a proxy or allow me to insert a custom header and achieve the same. When explicitly providing an ip/host/user/password via new WebProxy(ip, port) { Credentials = } I dont see how sending the header can leak. |
Triage: we can look at it. It should probably be controlled via property. Basic auth is insecure and it probably should not be used with plain-text like connect to proxy. |
Hello, has there been any progress on this issue? I've encountered this too, on a proxy that doesn't return 407 but 401 so HttpClient doesn't actually work at all with this proxy. Plus, with #50763 debugging was made harder since the proxy response cannot be accessed. I believe this behavior should at least be documented somewhere. I don't think it's expected by anyone, for example both curl and Python's urllib send credentials immediately if you provide them. Is passing the |
@wfurt it's been 1 1/2 years and upon revisting your last response and I would like to make a few points:
I think the precise statement here is that basic auth is inseure IF used via plaintext HTTP. It is not insecure if used over HTTPS.
|
we may look at it for 9. With #31113 done, there at least could be extra layer of protection. (or the auth targets random users & malware) I would expect that the cost is not as high as for example #33964 as the extra round would be amortized over all the requests over duration of the proxy connection, right? What bothers me personally is that |
True, but in some cases proxies are rotating proxies and they may require a new connection/session in order to be assigned to a new exit IP, so if you reconnect often the impact might not be negligible. The current behavior also makes it more likely to be blacklisted because of too many attempts without credentials (happened to me).
I'm not entirely familiar with what Also, I'm still not sure I understand why credentials aren't sent directly on the first request. I don't see where the security issue is. If you're explicitly setting a proxy and its credentials, why should the credentials not be sent? That's how other frameworks work, it's a reasonable expectation. Plus, RFC9110 says that:
Given the SHOULD, a proxy server can be RFC-compliant and not return 407. In that case the proxy won't work at all with the .NET HttpClient. |
@wfurt unfortunately my proxy requests are one and done due to either the proxy closing the connection or rotation. as you say, |
How about an API like |
On normal request, I can agree with argument that if Now there were also references to rotating proxies. AFAIK HttpClient does not handle that very well IMHO and it may be interesting to dig deeper into it. .NET would pick proxy on application start and that would generally remain static |
imo rotating proxies do not need to be handled internally and are easily managed by the user who may have more application specific analytics as to which proxy to choose. whatever API you think is not overly complicated i'm fine with as long is there is some way to avoid sending initial requests without the authentication information. |
Second this request. For me the problem is diagnosing 407 errors is hard enough, without having HttpClient generate them by default. Edit. Also confirm setting |
I like it @yowl because it is explicit and fully in your control. |
Description
Not sure, but this may be the same as #24865 .
I'm doing https requests using a proxy that requires basic auth using
HttpClient
.I've got an EventListener setup for http and am seeing that each request is doing a CONNECT to the proxy and getting nacked with 407 and then following up with another request that correclty includes the
Proxy-Authorization
.Is there any way to force the initial request to include the authorization information (or can i include a custom header on the initial connect)?
This extra round trip is highly inefficient.
Reproduction Steps
HttpClient request via proxy that requires username/password
Expected behavior
include Proxy-Authorization on initial request if the configured WebProxy includes NetworkCredentials
Actual behavior
407s
Regression?
unknown
Known Workarounds
No response
Configuration
.net 6, windows x64
Other information
No response
The text was updated successfully, but these errors were encountered: