Skip to content

fix(http): stop trusting ambient system/environment proxy config - #11

Open
chryzsh wants to merge 1 commit into
SpecterOps:mainfrom
chryzsh:fix-http-proxy-trust-env
Open

fix(http): stop trusting ambient system/environment proxy config#11
chryzsh wants to merge 1 commit into
SpecterOps:mainfrom
chryzsh:fix-http-proxy-trust-env

Conversation

@chryzsh

@chryzsh chryzsh commented Sep 8, 2026

Copy link
Copy Markdown

Description

HttpClient.__init__ (clients/http.py) creates requests.Session() with no override. requests trusts ambient proxy config by default: environment variables, or on Windows the registry-configured system proxy via urllib.request.getproxies_registry().

Found against a real environment: every AdminService/HTTP request, including same-LAN, same-domain targets, got a ProxyError connect-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-set NO_PROXY environment 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 = False right after session construction.

Confirmed safe against --proxy: the SOCKS5 mechanism patches socket.socket/socket.create_connection/socket.getaddrinfo process-wide and never touches requests' own proxy resolution, so the two don't interact.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Testing

New test test_session_does_not_trust_ambient_proxy_env in tests/http_client_test.py. README's "Proxying / pivoting" section updated to state ambient proxies are never used automatically. Full suite passes.

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
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 this pull request may close these issues.

1 participant