Skip to content

Use credentials from the proxy URL for HTTP(S) proxies - #6162

Closed
3ddi wants to merge 1 commit into
sqlmapproject:masterfrom
3ddi:fix-http-proxy-url-credentials
Closed

3ddi wants to merge 1 commit into
sqlmapproject:masterfrom
3ddi:fix-http-proxy-url-credentials

Conversation

@3ddi

@3ddi 3ddi commented Oct 27, 2026 •

Copy link
Copy Markdown

Related to #5875.

We run sqlmap in an environment where all traffic goes through an authenticating proxy, set with HTTP_PROXY=http://user:pass@proxy:port. After upgrading from 1.8.x to 1.10.x, every request started coming back with 407 Proxy Authentication Required.

I tracked it down to 8f75402 (the fix for #5875). Since that commit, _setHTTPHandlers() parses username:password out of the proxy URL, but only the SOCKS branch uses them. For HTTP(S) proxies, the proxy string is rebuilt from --proxy-cred only, so credentials in the URL are silently dropped. It happens both with --proxy and with the environment variables. In 1.8.x the userinfo stayed glued to the hostname and urllib picked it up, which is why it used to work.

The change just falls back to the parsed credentials when --proxy-cred isn't set. --proxy-cred still wins if both are given.

To reproduce, point either of these at a proxy that requires Basic auth:

HTTP_PROXY=http://user:secret@127.0.0.1:8899 python sqlmap.py -u "http://target.invalid/p.php?id=1" --batch
python sqlmap.py -u "http://target.invalid/p.php?id=1" --proxy=http://user:secret@127.0.0.1:8899 --batch

On master the first request goes out without a Proxy-Authorization header and the run stops on the 407. With the patch every request carries the header. I also checked an HTTPS target (the header is sent on CONNECT) and a -r request file.

Unit tests and --smoke-test pass.

Since 8f75402 (sqlmapproject#5875), _setHTTPHandlers() parses username:password
from the proxy URL but only passes them to SOCKS. For HTTP(S) proxies the
proxy string is rebuilt from --proxy-cred alone, so credentials given in
--proxy or in the HTTP_PROXY environment variable are dropped and the
proxy answers 407.
@stamparm stamparm closed this in 81d17b1 Oct 27, 2026
@stamparm

Copy link
Copy Markdown
Member

Thanks. Fixed in our own commit together with the SOCKS counterpart (percent-encoded credentials from the proxy URL weren't decoded there).

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.

2 participants