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

Proxy port in URI #1448

Closed
srvkb01 opened this issue Jan 25, 2024 · 9 comments
Closed

Proxy port in URI #1448

srvkb01 opened this issue Jan 25, 2024 · 9 comments

Comments

@srvkb01
Copy link

srvkb01 commented Jan 25, 2024

Hello,

I try to use bruno 1.6.1 in a windows10 professional environment (mitm proxy https, Web Gateway, firewall...).
I send all my traffic through a local http proxy :

"proxy": {
			"enabled": true,
			"protocol": "http",
			"hostname": "127.0.0.1",
			"port": 31280,
			"auth": {
				"enabled": false,
				"username": "",
				"password": ""
			},
			"bypassProxy": ""
		}

When I try to get https request :

meta {
  name: simple get
  type: http
  seq: 1
}

get {
  url: https://reqres.in/api/users
  body: none
  auth: none
}

bruno send bad, he add the proxy port to the uri hostname https://reqres.in:31280/api/users
and get error Error invoking remote method 'send-http-request': Error: socket hang up

Frame 68: 304 bytes on wire (2432 bits), 304 bytes captured (2432 bits) on interface \Device\NPF_Loopback, id 7
Internet Protocol Version 4, Src: localhost (127.0.0.1), Dst: localhost (127.0.0.1)
Transmission Control Protocol, Src Port: 50914 (50914), Dst Port: 31280 (31280), Seq: 1, Ack: 1, Len: 260
Hypertext Transfer Protocol
    GET https://reqres.in:31280/api/users HTTP/1.1\r\n
    Accept: application/json, text/plain, */*\r\n
    request-start-time: 1706195677467\r\n
    User-Agent: axios/1.5.1\r\n
    Accept-Encoding: gzip, compress, deflate, br\r\n
    host: reqres.in\r\n
    Proxy-Connection: close\r\n
    Connection: close\r\n
    \r\n
    [Full request URI: https://reqres.in:31280/api/users]
    [HTTP request 1/1]

I got the same with http request : GET http://reqres.in:31280/api/users HTTP/1.1\r\n

I very much appreciate your app and wish it the success it deserves

Kind regards,

@rfmae
Copy link

rfmae commented Feb 2, 2024

I experience similar issues, but the problem is not just the port. The authority part "https://reqres.in" should be in the host header and the GET method should only contain the path. Like this:

GET /api/users HTTP/1.1
Host: reqres.in
...

I am using Bruno version 1.7.1

@SC-CTS
Copy link

SC-CTS commented Mar 11, 2024

Issue still persists in 1.10.0

Some CNTLM logs to illustrate the issue:

Bruno:

******* Round 1 C: 4 *******
Reading headers (4)...
HEAD: GET https://api.mistral.ai:3128/v1/models HTTP/1.1

Curl:

******* Round 1 C: 4 *******
Reading headers (4)...
HEAD: CONNECT api.mistral.ai:443 HTTP/1.1

Also: The DevTools don't show anything in the network tab for these requests.

Can someone acknowledge this and maybe give some insights/roadmap?

samuel-deal-tisseo added a commit to samuel-deal-tisseo/bruno that referenced this issue Mar 21, 2024
This patched have been tested with http proxy:
* on http requests
* on https requests
* on proxy auth with basic auth
* on proxy without auth
* on tinnyproxy proxy
* on squid proxy

It should have no effects on SOCK proxy (And I don't know if the issue exists on those config anyway)

Given the following configuration
* System proxy: http://system.proxy:8080
* Bruno proxy: http://explicit.proxy:9000

On http request (to http://neverssl.com): it try to send the http request
to http://neverssl.com:8080 (wrong port) via the proxy http://explicit.proxy:9000 (correct proxy)

On https request (to https://www.example.com): it try send a CONNECT ::1 request (can be seen with wireshark)

An issue is opened on the proxy-agent repo: TooTallNate/proxy-agents#298
even tho I don't know if it's an axios issue, a proxy-agent issue or a bruno issue

```javascript
import { parse as parseURL } from "url";
import axios from 'axios';
import { HttpsProxyAgent } from 'https-proxy-agent';
import { HttpProxyAgent } from 'http-proxy-agent';

class PatchedHttpsProxyAgent extends HttpsProxyAgent {
	async connect(req, opts) {
		const url = parseURL(req.path);
		url.port = Number(url.port) || (url.protocol.includes('https') ? 443 : 80);
		return super.connect(req, { ...opts, ...url });
	}
}

function proxyObjToStr(proxyConf) {
	return proxyConf.protocol+"://"+proxyConf.host+":"+proxyConf.port.toString();
}

function test_req(url, proxyConf, applyPatch) {
	let request = {
		method: 'get',
		url: url,
		responseType: 'string',
		httpAgent: new HttpProxyAgent(proxyObjToStr(proxyConf)),
		httpsAgent: new HttpsProxyAgent(proxyObjToStr(proxyConf)),
		proxy: proxyConf
	};
	if (applyPatch) {
		request.proxy = {}
		request.httpsAgent = new PatchedHttpsProxyAgent(proxyObjToStr(proxyConf));
	}
	const axiosInstance = axios.create();
	const test_descr= url + (applyPatch ? " [patched]: " : " [current]: ");
	return axiosInstance(request).then(function (response) {
		console.log(test_descr + 'Ok');
	}).catch(function (error) {
		console.log(test_descr + "KO");
		if (error.response) {
			console.log({
				http_head: error.response.request._header.split("\r\n")[0],
				path: error.response.request.path,
				host: error.response.request.host
			});
		}
	});
}

async function main() {
	process.env["HTTPS_PROXY"] = "http://implicit.proxy:8080";
	const proxyConf = {
		protocol: 'http',
		host: 'explicit',
		port: 9000
	};
	await test_req("http://neverssl.com", proxyConf, false);
	await test_req("https://www.example.com/", proxyConf, false);
	await test_req("http://neverssl.com", proxyConf, true);
	await test_req("https://www.example.com/", proxyConf, true);
}

await main();
```

Here the following result:

```
http://neverssl.com: KO
{
  http_head: 'GET http://neverssl.com:8080/ HTTP/1.1',
  path: 'http://neverssl.com:8080/',
  host: 'implicit.proxy'
}
https://www.example.com/: KO
{
  http_head: 'GET https://www.example.com:8080/ HTTP/1.1',
  path: 'https://www.example.com:8080/',
  host: 'implicit.proxy'
}
http://neverssl.com [patched]: Ok
https://www.example.com/ [patched]: Ok
```
@samuel-deal-tisseo
Copy link

I have the same issue.

I made a bug report to http-proxy lib (TooTallNate/proxy-agents#298)
I made a PR #1883

Please test this PR and confirm it's the same issue and that the PR fixes the bug for you.
I made a release for my convenience here: https://github.com/samuel-deal-tisseo/bruno/releases/tag/v1.12.3-sam
But you should try the PR itself for security reasons

Thank you

@srvkb01
Copy link
Author

srvkb01 commented Mar 28, 2024

Hello,

I will try with the 1.12.3-sam version, it's good for me :
image

Thanks !

@samuel-deal-tisseo
Copy link

Great to here that :)
I hope It will be merged upstream soon

@gaac510
Copy link

gaac510 commented Jun 5, 2024

Tried both 1.18.0 Windows and Linux. Having the same issue.

Windows proxy log:
image

Linux proxy log:
image

@IGNBPesty
Copy link

IGNBPesty commented Aug 12, 2024

Having the same issue on version 1.24.0 on Linux.

Proxy is correctly contacted, but the proxy port is added to the original request when it shouldn't.

@MarcoDroll
Copy link

Same issue here in Windows with version 1.26.1

@helloanoop
Copy link
Contributor

This issue has already been fixed in latest version of Bruno v1.30.1 Closing this issue.
Please reopen the issue if the problem still persists,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants