Skip to content

fix(proxy-agent): decode SOCKS5 credentials from the proxy URI - #6040

Merged
mcollina merged 1 commit into
nodejs:mainfrom
alkaz-nodemaven:fix/socks5-proxyagent-decode-credentials
Nov 20, 2026
Merged

mcollina merged 1 commit into
nodejs:mainfrom
alkaz-nodemaven:fix/socks5-proxyagent-decode-credentials

Conversation

@alkaz-nodemaven

Copy link
Copy Markdown
Contributor

This relates to...

N/A

Rationale

new ProxyAgent('socks5://user%40example.com:p%40ss@host:1080') sends user%40example.com / p%40ss to the SOCKS5 server, so authentication fails for any username or password that needs percent-encoding. ProxyAgent passes url.username and url.password to Socks5ProxyAgent, and the URL getters return them still encoded. Socks5ProxyAgent decodes the credentials in its URI, but only when no username/password option is given, so the decoding never runs on this path. Using Socks5ProxyAgent directly with the same URI works.

Changes

Bug Fixes

  • ProxyAgent forwards only the explicit username/password options to Socks5ProxyAgent, which decodes the credentials from the URI it already receives.
  • Test: ProxyAgent with socks5://user%40example.com:p%40ss%3Aw%2Frd@... authenticates against the test SOCKS5 server that expects user@example.com / p@ss:w/rd. It fails without the change.

Breaking Changes and Deprecations

N/A

Status

ProxyAgent passed url.username and url.password to Socks5ProxyAgent,
which are still percent-encoded, so a password such as p%40ss was sent
to the SOCKS5 server literally. Socks5ProxyAgent already decodes the
credentials in the URI it receives; pass only the explicit options.
@codecov-commenter

codecov-commenter commented Nov 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.56%. Comparing base (bb6cc0a) to head (74bc45e).
⚠️ Report is 67 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6040      +/-   ##
==========================================
- Coverage   91.56%   91.56%   -0.01%     
==========================================
  Files         113      113              
  Lines       43839    43841       +2     
==========================================
+ Hits        40143    40144       +1     
- Misses       3696     3697       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina
mcollina merged commit ab93025 into nodejs:main Nov 20, 2026
34 of 38 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 20, 2026
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.

3 participants