Skip to content

mask proxy credentials by rebuilding netloc, not substring replace - #3752

Open
ubeddulla wants to merge 1 commit into
boto:developfrom
ubeddulla:mask-proxy-url-credential-leak
Open

mask proxy credentials by rebuilding netloc, not substring replace#3752
ubeddulla wants to merge 1 commit into
boto:developfrom
ubeddulla:mask-proxy-url-credential-leak

Conversation

@ubeddulla

Copy link
Copy Markdown

mask_proxy_url masks the userinfo with proxy_url.replace(username, mask, 1) and the same for the password, but str.replace swaps the first occurrence of that substring anywhere in the url, so when the credential value also appears earlier (in the scheme or host) the mask lands there and the real secret survives in the string that gets logged through ProxyConnectionError. for instance https://user:https@proxy.example.com masks to https://***:https@proxy.example.com with the password still visible. rebuilding the netloc from the parsed userinfo and host masks only the actual credential fields.

@ubeddulla
ubeddulla requested a review from a team as a code owner July 18, 2026 05:28
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