Skip to content

fix(deps): update dependency urllib to v5 [security] - #76

Open
renovate[bot] wants to merge 1 commit into
masterfrom
renovate/npm-urllib-vulnerability
Open

renovate[bot] wants to merge 1 commit into
masterfrom
renovate/npm-urllib-vulnerability

Conversation

@renovate

@renovate renovate Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

This PR contains the following updates:

Package Change Age Confidence
urllib ^3.3.0 → ^5.0.0 age confidence

urllib's cross-origin redirects preserve credential-bearing request headers, leading to potential credential leakage

CVE-2026-55553 / GHSA-hq3h-g68c-hp78

More information

Details

Summary

urllib supports redirect-following through followRedirect, which is expected behavior for an HTTP client. The issue is that, when following a redirect to a different origin, urllib preserves the caller-supplied request headers verbatim, including credential-bearing headers such as Authorization, Cookie, Proxy-Authorization, and custom auth headers (x-api-key, x-auth-token, x-access-token).

If the redirect target is attacker-controlled or outside the trust boundary of the original target, credentials intended for the original origin can be delivered to the redirected origin. In a local multi-library reproduction, urllib v4.9.0 was the only tested client that stripped no headers on cross-origin redirect.

Affected behavior

Confirmed against urllib v4.9.0. The relevant code is in #requestInternal (src/HttpClient.ts:639-656):

     // https://developer.mozilla.org/en-US/docs/Web/HTTP/Redirections
      if (RedirectStatusCodes.includes(res.statusCode) && maxRedirects > 0 && requestContext.redirects < maxRedirects) {
        if (res.headers.location) {
          requestContext.redirects++;
          const nextUrl = new URL(res.headers.location, requestUrl.href);
          // Ensure the response is consumed
          await response.body.arrayBuffer();
          debug(
            'Request#%d got response, status: %s, headers: %j, timing: %j, redirect to %s',
            requestId,
            res.status,
            res.headers,
            res.timing,
            nextUrl.href,
          );
          return await this.#requestInternal(nextUrl.href, options, requestContext);
        }
      }

The recursive call this.#requestInternal(nextUrl.href, options, requestContext) reuses the original options object. If the caller supplied credential-bearing headers in options.headers, those headers are reused for the redirected request, regardless of whether the redirect target shares the original origin.

Redirect-header handling context

The CHANGELOG suggests that redirect-related header handling has been considered before, including changes around preserving or cleaning up Host during redirects. Given that context, sensitive-header stripping may be an unintentional gap rather than an explicit policy decision.

Proof of Concept: 3-container topology

The reproduction uses three separate containers (partner, attacker, client) connected over a Podman bridge network. Each container has its own hostname, port, and process, so the redirect crosses a clear origin boundary. This is not a localhost vs 127.0.0.1 same-host case.

[client container]                       [partner container]              [attacker container]
hostname: client                         hostname: partner                hostname: attacker
                                         port: 3001                       port: 3002
   urllib v4.9.0
        │
        │ GET http://partner:3001/start
        │ + 6 credential-bearing headers
        ↓
                                         302 Location:
                                         http://attacker:3002/captured
                                                   │
                                                   │ urllib follows redirect
                                                   │ → DIFFERENT ORIGIN
                                                   │   (different hostname and port)
                                                   │ → all 6 headers preserved
                                                   ↓
                                                                          headers logged
                                                                          inside attacker
                                                                          container

The origin tuple is (scheme, host, port):

  • source origin: http://partner:3001
  • destination origin: http://attacker:3002

The host and port both differ, so the redirect target is a different URL origin. The headers are logged in a separate process inside a separate container.

Client invocation (client/poc.mjs):

import urllib from 'urllib' // v4.9.0

await urllib.request('http://partner:3001/start', {
  followRedirect: true,
  maxRedirects: 5,
  headers: {
    'Authorization': 'Bearer LIVE-AUTH-3CONTAINER',
    'Cookie': 'session=LIVE-COOKIE-3CONTAINER',
    'Proxy-Authorization': 'Bearer proxy-LIVE-3CONTAINER',
    'x-api-key': 'sk-LIVE-3CONTAINER-x123',
    'x-auth-token': 'auth-LIVE-3CONTAINER-y456',
    'x-access-token': 'access-LIVE-3CONTAINER-z789',
  },
})

Observed result
urllib 4.9.0, Node.js 22.22.2, linux/arm64:

[attacker] CAPTURED HEADERS:
  "authorization":       "Bearer LIVE-AUTH-3CONTAINER"
  "cookie":              "session=LIVE-COOKIE-3CONTAINER"
  "proxy-authorization": "Bearer proxy-LIVE-3CONTAINER"
  "x-api-key":           "sk-LIVE-3CONTAINER-x123"
  "x-auth-token":        "auth-LIVE-3CONTAINER-y456"
  "x-access-token":      "access-LIVE-3CONTAINER-z789"
  "user-agent":          "node-urllib/4.9.0 Node.js/22.22.2 (linux; arm64)"

LEAK RATE: 6/6

The user-agent value confirms that the redirected request was sent by urllib v4.9.0.

Independent reproduction: multi-library comparison

A separate local harness tested the same cross-origin redirect topology against multiple Node.js HTTP clients:

  • same partner:3001 → attacker:3002 redirect;
  • same six credential-bearing headers;
  • same RFC 6454 origin boundary.

The results were deterministic across runs:

Library Leak rate Headers stripped on cross-origin redirect
undici 6.21.0 3/6 authorization, cookie, proxy-authorization
needle 3.5.0 3/6 authorization, cookie, proxy-authorization
node-fetch 3.3.2 4/6 authorization, cookie
superagent 10.3.0 4/6 authorization, cookie
@​hapi/wreck 18.1.0 4/6 authorization, cookie
request 2.88.2 5/6 authorization
urllib 4.9.0 6/6 none

urllib was the only tested library that stripped no headers on cross-origin redirect. Custom auth headers such as x-api-key, x-auth-token, and x-access-token are an ecosystem-wide gap in this comparison. The urllib-specific issue is the absence of any strip step for standard credential-bearing headers such as Authorization, Cookie, and Proxy-Authorization.

The reproduction harness is small and can be shared if useful.

Impact

This affects Node.js applications that use urllib to make authenticated HTTP requests while allowing redirects to be followed automatically.

1. Application sends an authenticated request:
     GET https://api.partner.example/data
     Authorization: Bearer <token>
     Cookie: session=<session-id>

2. The partner endpoint, a compromised intermediary, or a misconfigured CDN returns:
     302 Location: https://attacker.example/captured

3. urllib follows the redirect and sends the original Authorization and Cookie headers
   to attacker.example.

This exposes credentials to an origin that was not the intended recipient. Depending on the credential type and server-side validation, the leaked credentials may be reusable against the original partner API or related services.

This requires no user interaction. Realistic triggers include compromised partner subdomains, DNS hijacking, malicious partner endpoints during onboarding, internal services redirecting across trust boundaries, or an open redirect upstream of urllib's call site.

Severity

  • CVSS Score: 7.5 / 10 (High)
  • Vector String: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

References

This data is provided by the GitHub Advisory Database (CC-BY 4.0).


Release Notes

node-modules/urllib (urllib)

v5.0.0

Compare Source

Upgrading from 4.x

  • Node.js and modules. Use Node.js 22.19.0 or later. urllib now ships a single ES module. Use import { request } from 'urllib' in ESM or await import('urllib') inside an async CommonJS function. #​722 · #​904 · #​820
  • HTTP/2 by default. With undici 8, HTTPS requests negotiate HTTP/2 when the server supports it. To force HTTP/1.1, pass { allowH2: false } to request() or HttpClient. If you supply an undici Pool or Client as the dispatcher, set the option when you construct it. #​820
  • Timeout handling. If you inspect err.cause.code for HTTP/2 response-header timeouts, update your check from UND_ERR_INFO to UND_ERR_HEADERS_TIMEOUT. #​820
  • TypeScript. The declarations now use type-fest 6, which requires TypeScript 6 or later with strict enabled. RequestOptions.signal now accepts AbortSignal | EventEmitter. #​995 · #​820

Redirects and query strings

  • When urllib follows a 303 See Other, it changes any method other than GET or HEAD to GET and drops the body and content headers. If the target needs a retry, urllib retries only the target. A failed redirect after a POST upload no longer resends the upload. #​1000
  • For GET and HEAD, urllib appends request data to the query string before the URL fragment. For example, adding { page: 2 } to /search?q=node#top sends /search?q=node&page=2 to the server. #​1000

API and diagnostics

  • Import getCookies, getSetCookies, setCookie, deleteCookie, parseCookie, and the Cookie type directly from urllib. #​742
  • res.timing.dnslookup reports milliseconds from the start of the request until DNS lookup completes. It is 0 on a reused socket. getDispatcherPoolStats() combines HTTP/1.1 and HTTP/2 counters for each origin. #​743 · #​820
  • The exported RequestOptions type now includes rejectUnauthorized for top-level request() and curl(). For an HttpClient instance, configure connect.rejectUnauthorized. #​919

Security fixes also available in 4.x. Version 4.9.1 stopped forwarding credentials on cross-origin redirects. Version 4.9.2 added escaping for multipart filenames and field names. Both fixes are included in 5.0.0. v4.9.1 · v4.9.2

First-time contributor. @​dependabot[bot] contributed #​631.

Full changelog since v4.9.0

v4.9.2

Compare Source

What's Changed

Full Changelog: node-modules/urllib@v4.9.1...v4.9.2

v4.9.1

Compare Source

What's Changed

Security
  • Do not forward credential headers (Authorization, Cookie, Proxy-Authorization) on cross-origin redirect, and clear auth/digestAuth, matching the WHATWG Fetch spec and undici's RedirectHandler (#​812). Same-origin redirects are unchanged and the caller's options object is never mutated.
Dependencies
  • Update runtime dependencies: undici (^7.24.0), qs, form-data, formstream, and type-fest.
Internal
  • Migrate the toolchain to Vite+ (Vitest 4, Oxlint, Oxfmt, tsdown).
  • Two-stage release workflow with manual approval, publishing the 4.x line to the latest-4 npm dist-tag (#​817).

Full Changelog: node-modules/urllib@v4.9.0...v4.9.1

v4.9.0

Compare Source

What's Changed

Full Changelog: node-modules/urllib@v4.8.2...v4.9.0


This release is also available on:

v4.8.2

Compare Source

What's Changed

New Contributors

Full Changelog: node-modules/urllib@v4.8.1...v4.8.2


This release is also available on:

v4.8.1

Compare Source

4.8.1 (2025-08-06)


This release is also available on:

v4.8.0

Compare Source

Features

This release is also available on:

v4.7.1

Compare Source

Bug Fixes
  • compatible with urllib@​2 timeout string format (#​580) (5eaf790)

This release is also available on:

v4.7.0

Compare Source

Features

This release is also available on:

v4.6.12

Compare Source

Bug Fixes

This release is also available on:

v4.6.11

Compare Source

Bug Fixes

This release is also available on:

v4.6.10

Compare Source

Bug Fixes

This release is also available on:

v4.6.9

Compare Source

Bug Fixes
  • should got undici:client:sendHeaders message on H2 (#​553) (bd19f6d)

This release is also available on:

v4.6.8

Compare Source

Bug Fixes

This release is also available on:

v4.6.7

Compare Source

Bug Fixes

This release is also available on:

v4.6.6

Compare Source

Bug Fixes
  • allow set rejectUnauthorized = true on urllib.request options (#​561) (88785e1)

This release is also available on:

v4.6.5

Compare Source

Bug Fixes

This release is also available on:

v4.6.4

Compare Source

Bug Fixes

This release is also available on:

v4.6.3

Compare Source

Bug Fixes

This release is also available on:

v4.6.2

Compare Source

Bug Fixes

This release is also available on:

v4.6.1

Compare Source

Bug Fixes

This release is also available on:

v4.6.0

Compare Source

Features

v4.5.1

Compare Source

Bug Fixes

This release is also available on:

v4.5.0

Compare Source

Features

This release is also available on:

v4.4.0

Compare Source

Features

This release is also available on:

v4.3.1

Compare Source

Bug Fixes

This release is also available on:

v4.3.0

Compare Source

Features

This release is also available on:

v4.2.2

Compare Source

Bug Fixes
  • uncaught exception due to second response with digest auth (#​530) (9a7833e)

This release is also available on:

v4.2.1

Compare Source

Bug Fixes

This release is also available on:

v4.2.0

Compare Source

Features

This release is also available on:

v4.1.0

Compare Source

Features

This release is also available on:

v4.0.0

Compare Source

⚠ BREAKING CHANGES
  • drop Node.js < 18.19.0 support

part of eggjs/egg#3644

Summary by CodeRabbit

  • New Features

    • Updated dynamic badge for contributors in README.md.
    • Enhanced form data handling in HttpClient.
  • Bug Fixes

    • Improved error handling and performance tracking in Socket methods.
    • Adjusted imports for better compatibility and error handling.
  • Refactor

    • Updated Node.js versions in CI workflow.
  • Revised exports and scripts in package.json for better
    consistency.

    • Simplified subscribe function in diagnostics channel.
  • Chores

    • Removed outdated configurations from .eslintrc.
    • Updated TypeScript compiler options in tsconfig.json.
  • Documentation

    • Linked license section to contributors-img in README.md.
  • Tests

  • Refined import paths and added new imports for better error handling
    in test files.

Features

This release is also available on:


Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.


This change is Reviewable

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4a0e02ed-2cd2-40f0-97fa-3be3c314d282

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@socket-security

socket-security Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​urllib@​3.27.3 ⏵ 5.0.097 -2100 +1610095 +1100

View full report

@renovate
renovate Bot force-pushed the renovate/npm-urllib-vulnerability branch from a0a2f79 to c9b557b Compare November 5, 2026 20:04
@renovate
renovate Bot force-pushed the renovate/npm-urllib-vulnerability branch from c9b557b to 11644fc Compare November 25, 2026 17:59
@renovate renovate Bot changed the title fix(deps): update dependency urllib to v4 [security] fix(deps): update dependency urllib to v5 [security] Nov 25, 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.

0 participants