Skip to content

deriveUrlFromHeaders does unsafe URL parsing and crashes #7275

@tmcw

Description

@tmcw

Preliminary Checks

Reproduction

This is not replayable in a browser

Publishable key

pk_test_aHVtb3JvdXMtZGFzc2llLTE4LmNsZXJrLmFjY291bnRzLmRldiQ

Description

Steps to reproduce:

  1. Use the React-Router integration with Clerk
  2. Be a phishing attacker and send a request with a host header like https://z2cgvm.xfh"></script><script>alert(document.domain);</script>/

Expected behavior:

Clerk should not crash

Actual behavior:

Clerk does this:

private deriveUrlFromHeaders(req: Request) {

Which it calls when initializing ClerkRequest, and the URL constructor throws an error, and so any security scanner / phishing / bad actor can trigger an uncaught exception from Clerk.

Environment

System:
    OS: macOS 26.0.1
    CPU: (8) arm64 Apple M2
    Memory: 2.40 GB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.8.0 - /Users/tmcw/.local/share/mise/installs/node/24.8.0/bin/node
    npm: 11.6.0 - /Users/tmcw/.local/share/mise/installs/node/24.8.0/bin/npm
    pnpm: 10.22.0 - /Users/tmcw/.local/share/mise/installs/pnpm/10.22.0/pnpm
    Deno: 2.5.5 - /Users/tmcw/.local/share/mise/installs/deno/2.5.5/bin/deno
    Watchman: 2025.11.10.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 142.0.7444.176
    Chrome Canary: 144.0.7535.0
    Firefox: 144.0
    Safari: 26.0.1
  npmPackages:
    @clerk/backend: ^1.30.0 => 1.34.0
    @clerk/express: ^1.4.9 => 1.4.9
    @clerk/fastify: 2.2.9 => 2.2.9
    @clerk/react-router: ^1.9.6 => 1.9.6
    @react-aria/interactions: ^3.25.5 => 3.25.5
    @react-email/components: ^1.0.1 => 1.0.1
    @react-router/dev: ^7.9.4 => 7.9.4
    @react-router/express: ^7.9.4 => 7.9.4
    @react-router/fs-routes: ^7.9.4 => 7.9.4
    @react-router/node: ^7.9.4 => 7.9.4
    @react-router/serve: ^7.9.4 => 7.9.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageA ticket that needs to be triaged by a team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions