← Back to Pull requests

interceptors: enforce cache-after-redirect composition order #6220

Merged
mcollina merged 11 files (213 lines) on Nov 19, 2026 14:47 UTC
View on GitHub
mcollina mcollina commented on Nov 18, 2026 13:05 UTC
Author

This relates to...

  • GHSA-MQG3-3V4R-CM32 (cross-origin redirect cache bypass)

  • GHSA-4W7W-5XRC-9H26 (cross-origin redirect cached under original origin)

  • GHSA-7XG3-FPHP-28HG (credential-bearing same-origin redirect replay under the alias key)
  • Rationale

    All of the above were fixed in the cache handler's redirect guards. Those guards
    depend on CacheHandler observing the redirect history threaded through
    context.history by the redirect handler. That only happens when the cache
    handler is composed below the redirect handler.

    When cache() is composed before redirect(), the cache handler is wrapped
    above the redirect handler and never receives the history, so every
    history-based guard is silently disabled. The result is reproducible against the
    current tree:

  • cross-origin: a cacheable 302 to an attacker origin stores the attacker's

  • response under the trusted key and replays it to a later caller without
    contacting either origin (substituted: true, trustedHits: 1,
    attackerHits: 1).
  • credential-bearing same-origin: /me -> /profile/{user} leaks Alice's

  • response to Bob (bob == ALICE ssn=..., me:1 profile:1).

    The existing reverse-order regression test only "passes" because its 302 is not
    explicitly cacheable, so it never exercises the vulnerable storage path.

    Changes

    Interceptors are opaque functions, so Dispatcher.compose() cannot tell which
    ones are order-sensitive without metadata. This change:

  • Tags the cache, redirect, and deduplicate interceptors with a

  • kInterceptorKind symbol.
  • Makes Dispatcher.compose() throw an InvalidArgumentError when cache is

  • composed before redirect, with a message naming the affected CVEs.
  • Documents the constraint in docs/docs/api/Dispatcher.md and

  • docs/docs/api/Interceptors.md.

    deduplicate is in the same set (it participates in the redirect-history
    contract and copies request options), but it has no positional constraint of its
    own: cache must follow redirect regardless of where deduplicate sits. Verified
    empirically across all 8 orderings of cache/redirect/deduplicate.

    Features

    N/A

    Bug Fixes

  • Fail fast when the cache and redirect interceptors are composed in an order

  • that silently disables the cache's cross-origin and credential redirect
    guards.

    Breaking Changes and Deprecations

    compose(cache(), redirect()) now throws InvalidArgumentError instead of
    silently producing an unsafe shared cache. This is a semver-major change
    (the previous order did work, just unsafely); I propose backporting it to v7.

    Note: the relative order of interceptors is fundamentally the end-user's
    responsibility (they wrap each other). This is a fail-fast guard against the one
    order we know to be dangerous, not a reordering of interceptors.

    Status

  • I have read and agreed to the [Developer's Certificate of Origin][cert]

  • Tested

  • Benchmarked (optional)

  • Documented

  • Review ready

  • In review

  • Merge ready
  • [cert]: https://github.com/nodejs/undici/blob/main/CONTRIBUTING.md#developers-certificate-of-origin

    Diff: 213 lines (+150 / -63) across 11 files Reviewer: ronag Review duration: 1541m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.50) × (1 − Review Confidence (0.71)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 213 lines diff across 11 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.53 · 1 substantive comment(s)
    0.53
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    71%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.321
    Real PR Conversation Timeline
    4 items
    codecov-commenter codecov-commenter commented on Nov 18, 2026 13:30 UTC
    Contributor

    Codecov Report


    :white_check_mark: All modified and coverable lines are covered by tests.
    :white_check_mark: Project coverage is 91.68%. Comparing base (02c4f8c) to head (cefb273).
    :warning: Report is 5 commits behind head on main.

    <details><summary>Additional details and impacted files</summary>

    @@           Coverage Diff           @@
    ##             main    #6220   +/-   ##
    =======================================
      Coverage   91.68%   91.68%           
    =======================================
      Files         113      113           
      Lines       44462    44520   +58     
    =======================================
    + Hits        40763    40820   +57     
    - Misses       3699     3700    +1     
    

    </details>

    :umbrella: View full report in Codecov by Harness.
    :loudspeaker: Have feedback on the report? Share it here.
    <details><summary> :rocket: New features to boost your workflow: </summary>

  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

  • </details>

    ronag ronag approved these changes on Nov 18, 2026 21:32 UTC
    Approved Reviewer

    Approved these changes.

    metcoder95 metcoder95 approved these changes on Nov 19, 2026 07:41 UTC
    Approved Reviewer

    Approved these changes.

    Reviewers
    Assignees
    mcollina mcollina
    Labels
    risk: low confidence: 71.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.8% (MEDIUM) · Higher = larger blast radius
    49.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 71.3% · Lower = rushed or shallow review
    71.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.3% · Safe to merge
    14.3%
    Repository