genotrance / px

An HTTP proxy server to automatically authenticate through an NTLM proxy
MIT License
955 stars 99 forks source link

Spaces in PAC proxy list cause blank proxies to be added #184

Closed chunderbolt closed 9 months ago

chunderbolt commented 1 year ago

If you've got multiple proxies in your PAC file (see the Examples section), they're formatted with a semicolon separator. The Mozilla docs give this example:

PROXY w3proxy.netscape.com:8080; PROXY mozilla.netscape.com:8081

Wikipedia has a fairly arcane looking definition for the returnValue format, but from what I can tell it says they're semicolon separated with no space? I don't think people generally stick to that definition.

I see something like this in my Px logs fairly often:

Process-3: Thread_7: 1687968010: /do_CONNECT/do_curl/get_destination: 0ee0e0f633ce30675d71bc5356a0500ca8cb3724: Proxy = [('one.proxy.mycompany.com', 8080), ('', 80), ('two.proxy.mycompany.com', 8080)]

Now, fortunately my PAC file just concatenates the two proxies with a "; ", so the blank proxy is never first in the list to be chosen. If you had a space at the start of one of them, though, the blank proxy will appear first in the list and be used, causing a timeout.

genotrance commented 1 year ago

Was just looking at the code for this:

https://github.com/genotrance/px/blob/0064b74ec398b7a5adaa39e0ba671216b9dd2491/px/pac.py#L84

Not sure why “ “ is replaced with “,”. It means every blank space is treated as another entry. I need to look at the PAC spec again to see what spaces really mean.

genotrance commented 11 months ago

This is fixed in v0.9.0 still in development - see branch.