apify / proxy-chain

Node.js implementation of a proxy server (think Squid) with support for SSL, authentication and upstream proxy chaining.
https://www.npmjs.com/package/proxy-chain
Apache License 2.0
851 stars 145 forks source link

SOCKS Authentication fails for CONNECT if username contains special characters #548

Closed mschfh closed 3 months ago

mschfh commented 3 months ago

SOCKS authentication fails for CONNECT requests when the username contains a @:

proxyChain.anonymizeProxy({url: "socks5://foo@bar.baz:hunter2@example.com:1080", port: 12345})

For a HTTP request, everything works as expected (the username is sent as-is).

curl -v --proxy 'http://127.0.0.1:12345' 'http://ifconfig.co'
image

For a HTTPS / CONNECT request, the username sent to the upstream SOCKS5 proxy is URL escaped (e.g. foo%40bar.baz, as seen in a packet capture) and the SOCKS authentication request fails due to incorrect credentials, the proxy returns a 597 error.

curl -v --proxy 'http://127.0.0.1:12345' 'https://ifconfig.co'
image
jirimoravcik commented 3 months ago

Fixed in #550

mschfh commented 3 months ago

Thank you, the fix works as expected.