-
Notifications
You must be signed in to change notification settings - Fork 17.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
vhost doesn't work correctly in the http protocol in net/http package #58601
Comments
Hi @s4hm4d - this seems to be working as documented. Per https://cs.opensource.google/go/go/+/refs/tags/go1.20.1:src/net/http/request.go;l=238-242: // For client requests, Host optionally overrides the Host
// header to send. If empty, the Request.Write method uses
// the value of URL.Host. Host may contain an international
// domain name. If you want Go's http client to send the request to the IP instead, just follow the docs and don't set the |
Hi @jimen0 Due to this issue many tools that written with Golang don't work correctly. google.com wikipedia.org github.com stackoverflow.com And run the ffuf: $ ffuf -u http://91.198.174.192 -H "Host: FUZZ" -w domains.txt Output: wikipedia.org [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 121ms] The output is correct, because I used the Wikipedia server IP. Now, I run it again, just add the burp suite address as the proxy: $ ffuf -u http://91.198.174.192 -H "Host: FUZZ" -w domains.txt -x http://127.0.0.1:8080 Output: github.com [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 263ms] wikipedia.org [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 376ms] stackoverflow.com [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 413ms] google.com [Status: 301, Size: 219, Words: 9, Lines: 7, Duration: 546ms] Note again that the protocol is I run it again in $ ffuf -u https://91.198.174.192 -H "Host: FUZZ" -w domains.txt -x http://127.0.0.1:8080 Output: wikipedia.org [Status: 301, Size: 234, Words: 14, Lines: 8, Duration: 1451ms] |
@neild per owners. Just as a general remark, please use plain text when including examples/transcripts in your issue, as opposed to pictures/screendumps, a lot of what you have posted is difficult to read. |
You're getting different results with HTTP and HTTPS requests through a proxy because HTTP requests are sent unencrypted to the proxy while HTTPS requests request a tunnel to the destination with CONNECT.
|
looks to be working as intended |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I wrote a simple script to test virtual host.
And added a proxy address to check the requests. I used Burp Suite. Also tested with Postman and other addresses. no difference.
It doesn't work correctly for the HTTP protocol when using the proxy.
If use the HTTPS protocol or comment the proxy address in the HTTP protocol, It works correctly.
For example:
If I send a request to the Wikipedia server with the
Host: github.com
, I will receive an error.It's 400 status code and It's an error.
Also I sent the request to the proxy (Burp Suite):
This is a Golang script to check this:
vhostTest.go
ScriptFirst, I commented the proxy address and run the script:
![goscript_http](https://user-images.githubusercontent.com/67481724/220030866-706b623b-540c-48df-89f9-d16b17140a62.png)
The output is correct.
Next run is with the proxy address:
![goscript_http_proxy](https://user-images.githubusercontent.com/67481724/220031084-bb6250de-ff22-4368-b022-beeb6639dbeb.png)
This is wrong, because the request sent to
http://github.com
instead ofhttp://91.198.174.192
Next run is with the proxy address and the HTTPS protocol:
![goscript_https_proxy](https://user-images.githubusercontent.com/67481724/220031227-3e9ef682-5432-4a52-a815-ff955d3fd1e6.png)
The output is correct.
What did you expect to see?
When using the proxy address in the HTTP protocol, I expect the 400 status code, like the curl.
What did you see instead?
It ignore the server IP and the request will be sent to the host value address.
The text was updated successfully, but these errors were encountered: