GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — url: restrict option copying in urlToHttpOptions to URL instances by mcollina · Pull Request #67454 · nodejs/node

Conversation

@mcollina

@mcollina mcollina commented Nov 13, 2026

Copy link
Copy Markdown
Member

urlToHttpOptions() currently spreads all own enumerable properties of its argument into the request options. When http.request()/https.request() is passed a URL-shaped object that satisfies the duck-typed isURL() check but is not a genuine WHATWG URL instance, arbitrary transport/connection options such as socketPath, method, headers, or agent are copied into the request options. This lets an attacker-supplied object redirect a hostname-validated request to a Unix domain socket (for example the Docker daemon), defeating hostname-based SSRF defenses.

The spread is only meaningful for a genuine WHATWG URL instance that a user has extended with additional own enumerable properties (for example url.headers = ...), as introduced in #46989. A real URL instance has no own enumerable properties of its own, so gating the spread on the existing isURLInstance() brand check preserves that feature while preventing the duck-typed smuggling vector.

Adds a unit test in test-url-urltooptions.js and an end-to-end regression test verifying that a hostname-validated request is no longer redirected to an injected socketPath.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodejs-github-bot

nodejs-github-bot commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/url
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Nov 13, 2026
@mcollina
mcollina force-pushed the fix-urltohttpoptions-options-injection branch from 38881e3 to 75bfa0e Compare November 13, 2026 12:56
@codecov

codecov Bot commented Nov 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.70%. Comparing base (2929073) to head (edbd599).
⚠️ Report is 169 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #67454      +/-   ##
==========================================
- Coverage   92.62%   90.70%   -1.92%     
==========================================
  Files         430      802     +372     
  Lines      196333   282114   +85781     
  Branches    29897    54349   +24452     
==========================================
+ Hits       181849   255886   +74037     
- Misses      14159    16369    +2210     
- Partials      325     9859    +9534     
Files with missing lines Coverage Δ
lib/internal/url.js 93.76% <100.00%> (+11.62%) ⬆️

... and 530 files with indirect coverage changes

🚀 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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina
mcollina force-pushed the fix-urltohttpoptions-options-injection branch from 75bfa0e to 19b7a66 Compare November 13, 2026 14:58
@mcollina
url: restrict option copying in urlToHttpOptions to URL instances
edbd599
Only spread own enumerable properties for URL instances created by this
realm's URL constructor. Duck-typed objects accepted by isURL() can no
longer smuggle connection options (socketPath, method, headers, agent)
into a request.

This fixes a footgun where a hostname-validated http.request() could be
redirected to a Unix socket (e.g. the Docker daemon) via a URL-shaped
object, bypassing hostname-based SSRF checks. Extending a genuine URL
object with extra options is preserved.

PR-URL: nodejs#67454
Refs: nodejs#46989
Signed-off-by: Matteo Collina <[email protected]>
@mcollina
mcollina force-pushed the fix-urltohttpoptions-options-injection branch from 19b7a66 to edbd599 Compare November 13, 2026 15:27
jasnell
jasnell approved these changes Nov 14, 2026
View reviewed changes
@mcollina mcollina added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 14, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 14, 2026
@nodejs-github-bot

This comment was marked as outdated.

Sign in to view
@nodejs-github-bot

This comment was marked as outdated.

Sign in to view
ShogunPanda
ShogunPanda approved these changes Nov 18, 2026
View reviewed changes
@jasnell jasnell added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 18, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 18, 2026
@nodejs-github-bot

nodejs-github-bot commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/79250/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mcollina mcollina added the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 19, 2026
@nodejs-github-bot
nodejs-github-bot merged commit c47b8d8 into nodejs:main Nov 19, 2026
68 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Landed in c47b8d8

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 19, 2026
aduh95 pushed a commit that referenced this pull request Nov 19, 2026
@mcollina @aduh95
url: restrict option copying in urlToHttpOptions to URL instances
c35398d
Only spread own enumerable properties for URL instances created by this
realm's URL constructor. Duck-typed objects accepted by isURL() can no
longer smuggle connection options (socketPath, method, headers, agent)
into a request.

This fixes a footgun where a hostname-validated http.request() could be
redirected to a Unix socket (e.g. the Docker daemon) via a URL-shaped
object, bypassing hostname-based SSRF checks. Extending a genuine URL
object with extra options is preserved.

Refs: #46989
Signed-off-by: Matteo Collina <[email protected]>
PR-URL: #67454
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Paolo Insogna <[email protected]>
@github-actions github-actions Bot mentioned this pull request Nov 24, 2026
2026-11-25, Version 27.0.0-alpha.0.2.0 (Alpha) #67757
Merged
gabylb pushed a commit to gabylb/node that referenced this pull request Nov 27, 2026
@mcollina @gabylb
url: restrict option copying in urlToHttpOptions to URL instances
89d3dc6
Only spread own enumerable properties for URL instances created by this
realm's URL constructor. Duck-typed objects accepted by isURL() can no
longer smuggle connection options (socketPath, method, headers, agent)
into a request.

This fixes a footgun where a hostname-validated http.request() could be
redirected to a Unix socket (e.g. the Docker daemon) via a URL-shaped
object, bypassing hostname-based SSRF checks. Extending a genuine URL
object with extra options is preserved.

Refs: nodejs#46989
Signed-off-by: Matteo Collina <[email protected]>
PR-URL: nodejs#67454
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Paolo Insogna <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ShogunPanda ShogunPanda ShogunPanda approved these changes
@jasnell jasnell jasnell approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@mcollina @nodejs-github-bot @ShogunPanda @jasnell
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.