DEV Community

Cover image for Proxy password leak lab: where a canary password showed up
proxymint
proxymint

Posted on Originally published at proxymint.com

Proxy password leak lab: where a canary password showed up

Originally published on proxymint.

A canary proxy password tested on loopback: where it showed up in curl -v, ps, shell history, pip, npm, git, Python errors and CI logs, and a fix for each.

TL;DR

  • Run curl -v with the proxy in http_proxy and you get the password in plain text. The "Uses proxy env variable" line prints the whole URL, and every -v run prints the Proxy-Authorization header, which is just Base64 of user:password.
  • ps shows curl -x http://user:pass@host to every local account on macOS. curl blanks --proxy-user and -U after a moment. pip --proxy and git -c http.proxy stay in the process list in full, so a -K config file is the safer habit.
  • npm masks its own proxy setting and then prints HTTP_PROXY raw. npm 11.11.0 showed the env var in full under "environment-related config", and every npm run script saw npm_config_proxy with the password in it.
  • git quietly saved the proxy login to .git-credentials. With credential.helper=store, one successful ls-remote through the proxy wrote http://canaryuser:CANARYpw7731@127.0.0.1%3a18941 to the file, even when the proxy came from http_proxy.
  • Masks and grep miss the encoded copies. The same password showed up literal, percent-encoded and as Base64. In curl's hex trace the Base64 was split across dump lines, and nothing caught it.

Key takeaways

  • Keep curl -v out of saved CI logs, or pipe it through a sed filter that redacts the Proxy-Authorization line and any user:pass@ in URLs. That filter worked here on -v and --trace-ascii, not on hex --trace.
  • Type the password at a read -rs prompt and export the variable from it, so zsh and bash history hold ${PROXY_PASS} instead of the value, even without HIST_IGNORE_SPACE.
  • Give git a proxy URL with only the username and let a credential helper supply the password, and don't run the store helper on a machine that uses a proxy login.
  • In Python, pass aiohttp the login through proxy_auth and log str(err) rather than repr(err), parse host:port:user:pass strings before handing them to requests, and log err.code and err.message in Node instead of the whole error.
  • After a leak, change the password first, then search your logs for the literal, percent-encoded and Base64 forms, and delete what you find.

Read the full guide on proxymint, with the commands, tables and sources.

Top comments (0)