fix(http): stop trusting ambient system/environment proxy config - #11
Open
chryzsh wants to merge 1 commit into
Open
fix(http): stop trusting ambient system/environment proxy config#11chryzsh wants to merge 1 commit into
chryzsh wants to merge 1 commit into
Conversation
requests.Session() trusts HTTP_PROXY/HTTPS_PROXY env vars and, on Windows, the registry-configured system proxy by default. On a real engagement this silently routed every AdminService/HTTP request -- including same-LAN, same-domain targets -- through the operator's corporate web proxy, which has no route to internal hosts, producing a ProxyError timeout on every single probe until worked around with a manually-set NO_PROXY env var. This collector already has its own explicit pivoting mechanism (-x/--proxy, a SOCKS5 tunnel at the socket layer); silently deferring to an ambient corporate proxy was never intended. Set trust_env=False on the session -- confirmed safe against --proxy, which operates entirely at the socket layer and never touches requests' own proxy resolution. Ticket: con-8bed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
HttpClient.__init__(clients/http.py) createsrequests.Session()with no override.requeststrusts ambient proxy config by default: environment variables, or on Windows the registry-configured system proxy viaurllib.request.getproxies_registry().Found against a real environment: every AdminService/HTTP request, including same-LAN, same-domain targets, got a
ProxyErrorconnect-timeout. All of them tried to route through the operator's corporate web proxy (configured for general internet access), which has no route to internal hosts. Worked around mid-engagement with a manually-setNO_PROXYenvironment variable.This collector already has its own explicit, intentional pivoting mechanism,
-x/--proxy(a SOCKS5 tunnel installed at the socket layer). Silently trusting a random ambient corporate proxy was never intended.Fix
self._session.trust_env = Falseright after session construction.Confirmed safe against
--proxy: the SOCKS5 mechanism patchessocket.socket/socket.create_connection/socket.getaddrinfoprocess-wide and never touchesrequests' own proxy resolution, so the two don't interact.Type of Change
Testing
New test
test_session_does_not_trust_ambient_proxy_envintests/http_client_test.py. README's "Proxying / pivoting" section updated to state ambient proxies are never used automatically. Full suite passes.