Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

path-to-regexp

Latest version: v9.0.1

Overview

Last scanned
4 Dec 2026
Published
4 Dec 2026
npm package Publisher: blakeembrey, defunctzombie, dougwilson, jonathanong, jongleberry, ulisesgascon
8,619 Stars
492 Forks
2 Versions
1.4B Downloads
TypeScript Repo language

Scan summary

path-to-regexp was last scanned on 4 Dec 2026 at version 9.0.1. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 2 versions; the latest was published on 4 Dec 2026.
  • Findings: No rules fired in version 9.0.1.
  • Downloads: 1,417,120,687 downloads.

Versions

2 versions published
Versions and the rules that fired in each
VersionPublishedStatus
9.0.1 LATEST 4 Dec 2026 No rules fired
9.0.0 22 Oct 2026 No rules fired

No rules fired in 9.0.1

Findings

Findings for v9.0.1. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 9.0.1; other versions have their own rules, not their own score.

Known vulnerabilities

5 CVEs · last 26 Mar 2026

0 CRITICAL 4 HIGH 1 MEDIUM 0 LOW

Versions

  • ≥ 8.4.0
  • ≥ 8.0.0, < 8.4.0 1 HIGH 1 MEDIUM
  • ≥ 7.0.0, < 8.0.0 1 HIGH
  • ≥ 6.3.0, < 7.0.0
  • ≥ 4.0.0, < 6.3.0 1 HIGH
  • ≥ 3.3.0, < 4.0.0
  • ≥ 2.0.0, < 3.3.0 1 HIGH
  • ≥ 1.9.0, < 2.0.0
  • ≥ 0.2.0, < 1.9.0 1 HIGH
  • ≥ 0.1.13, < 0.2.0
Show all 13 version ranges
  • ≥ 0.1.12, < 0.1.13 1 HIGH
  • ≥ 0.1.10, < 0.1.12 2 HIGH
  • < 0.1.10 3 HIGH

Vulnerabilities

  • CVE-2026-4926 High 26 Mar 2026 path-to-regexp: path-to-regexp: Denial of Service via crafted regular expressions Fixed in 8.4.0
  • CVE-2026-4923 Medium 26 Mar 2026 path-to-regexp: path-to-regexp: Denial of Service via specially crafted paths with multiple wildcards Fixed in 8.4.0
  • CVE-2026-4867 High 26 Mar 2026 path-to-regexp: path-to-regexp: Denial of Service via catastrophic backtracking from malformed URL parameters Fixed in 0.1.13
  • CVE-2024-52798 High 5 Dec 2024 path-to-regexp: path-to-regexp Unpatched `path-to-regexp` ReDoS in 0.1.x Fixed in 0.1.12
  • CVE-2024-45296 High 9 Sep 2024 path-to-regexp: Backtracking regular expressions cause ReDoS Fixed in 1.9.0, 0.1.10, 8.0.0, 3.3.0, 6.3.0

Seal Security (npm)

Seal Security ships a patched build of this package. Its fixed versions:

  • CVE-2024-45296: 0.1.10-sp999
  • CVE-2024-52798: 0.1.7-sp2
  • CVE-2026-4867: 0.1.10-sp999, 0.1.7-sp3

README

The publisher’s own README, as collected from the registry.

Path-to-RegExp

Turn a path string such as /user/:name into a regular expression.

NPM version NPM downloads Build status Build coverage License

Installation

npm install path-to-regexp --save

Usage

import { match, pathToRegexp, compile, parse, stringify } from "path-to-regexp";
Parameters

Parameters match arbitrary strings in a path by matching up to the end of the segment, or up to any proceeding tokens. They are defined by prefixing a colon to the parameter name (:foo). Parameter names can use any valid JavaScript identifier, or be double quoted to use other characters (:"param-name").

const fn = match("/:foo/:bar");

fn("/test/route");
//=> { path: '/test/route', params: { foo: 'test', bar: 'route' } }
Wildcard

Wildcard parameters match one or more characters across multiple segments. They are defined the same way as regular parameters, but are prefixed with an asterisk (*foo).

const fn = match("/*splat");

fn("/bar/baz");
//=> { path: '/bar/baz', params: { splat: [ 'bar', 'baz' ] } }
Optional

Braces can be used to define parts of the path that are optional.

const fn = match("/users{/:id}/delete");

fn("/users/delete");
//=> { path: '/users/delete', params: {} }

fn("/users/123/delete");
//=> { path: '/users/123/delete', params: { id: '123' } }

Match

The match function returns a function for matching strings against a path:

  • path String, TokenData object, or array of strings and TokenData objects.
  • options (optional) (Extends pathToRegexp options)
    • decode Function for decoding strings to params, or false to disable all processing. (default: decodeURIComponent)
const fn = match("/foo/:bar");

Please note: path-to-regexp is intended for ordered data (e.g. paths, hosts). It can not handle arbitrarily ordered data (e.g. query strings, URL fragments, JSON, etc).

PathToRegexp

The pathToRegexp function returns the regexp for matching strings against paths, and an array of keys for understanding the RegExp#exec matches.

  • path String, TokenData object, or array of strings and TokenData objects.
  • options (optional) (See parse for more options)
    • sensitive Regexp will be case sensitive. (default: false)
    • end Validate the match reaches the end of the string. (default: true)
    • delimiter The default delimiter for segments, e.g. [^/] for :named parameters. (default: '/')
    • trailing Allows optional trailing delimiter to match. (default: true)
const { regexp, keys } = pathToRegexp("/foo/:bar");

regexp.exec("/foo/123"); //=> ["/foo/123", "123"]

Compile ("Reverse" Path-To-RegExp)

The compile function will return a function for transforming parameters into a valid path:

  • path A string or TokenData object.
  • options (See parse for more options)
    • delimiter The default delimiter for segments, e.g. [^/] for :named parameters. (default: '/')
    • encode Function for encoding input strings for output into the path, or false to disable entirely. (default: encodeURIComponent)
const toPath = compile("/user/:id");

toPath({ id: "name" }); //=> "/user/name"
toPath({ id: "café" }); //=> "/user/caf%C3%A9"

const toPathRepeated = compile("/*segment");

toPathRepeated({ segment: ["foo"] }); //=> "/foo"
toPathRepeated({ segment: ["a", "b", "c"] }); //=> "/a/b/c"

// When disabling `encode`, you need to make sure inputs are encoded correctly. No arrays are accepted.
const toPathRaw = compile("/user/:id", { encode: false });

toPathRaw({ id: "%3A%2F" }); //=> "/user/%3A%2F"

Stringify

Transform a TokenData object to a Path-to-RegExp string.

  • data A TokenData object.
const data = {
  tokens: [
    { type: "text", value: "/" },
    { type: "param", name: "foo" },
  ],
};

const path = stringify(data); //=> "/:foo"

Developers

  • If you are rewriting paths with match and compile, consider using encode: false and decode: false to keep raw paths passed around.
  • To ensure matches work on paths containing characters usually encoded, such as emoji, consider using encodeurl for encodePath.
Parse

The parse function accepts a string and returns TokenData, which can be used with match and compile.

  • path A string.
  • options (optional)
    • encodePath A function for encoding input strings. (default: x => x, recommended: encodeurl)
Tokens

TokenData has two properties:

  • tokens A sequence of tokens, currently of types text, param, wildcard, or group.
  • originalPath The original path used with parse, shown in error messages to assist debugging.
Custom path

In some applications you may not be able to use the path-to-regexp syntax, but you still want to use this library for match and compile. For example:

import { match } from "path-to-regexp";

const tokens = [
  { type: "text", value: "/" },
  { type: "param", name: "foo" },
];
const originalPath = "/[foo]"; // To help debug error messages.
const path = { tokens, originalPath };
const fn = match(path);

fn("/test"); //=> { path: '/test', params: { foo: 'test' } }

Errors

An effort has been made to ensure ambiguous paths from previous releases throw an error. This means you might be seeing an error when things worked before.

Missing parameter name

Parameter names must be provided after : or *, for example /*path. They can be valid JavaScript identifiers (e.g. :myName) or JSON strings (:"my-name").

Unexpected ? or +

In past releases, ?, *, and + were used to denote optional or repeating parameters. As an alternative, try these:

  • For optional (?), use braces: /file{.:ext}.
  • For one or more (+), use a wildcard: /*path.
  • For zero or more (*), use both: /files{/*path}.
Unexpected (, ), [, ], etc.

Previous versions of Path-to-RegExp used these for RegExp features. This version no longer supports them so they've been reserved to avoid ambiguity. To match these characters literally, escape them with a backslash, e.g. "\\(".

Unterminated quote

Parameter names can be wrapped in double quote characters, and this error means you forgot to close the quote character. For example, :"foo.

Express \<= 4.x

Path-To-RegExp breaks compatibility with Express \<= 4.x in the following ways:

  • The wildcard * must have a name and matches the behavior of parameters :.
  • The optional character ? is no longer supported, use braces instead: /:file{.:ext}.
  • Regexp characters are not supported.
  • Some characters have been reserved to avoid confusion during upgrade (()[]?+!).
  • Parameter names now support valid JavaScript identifiers, or quoted like :"this".

License

MIT

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm path-to-regexp

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Copy of Template Design OX Blog (3)
Research

Ruby2Shell: Ruby Memory Corruption Flaws Expose Applications to Remote Code Execution, But is it an Actual Risk?

Ethersphere Hijacked With Crypto Stealing Malware (1)
npm

Ethersphere Hijacked With Crypto Stealing Malware Via Github & npm

CVE

Java4Shell (CVE-2026-114938): Easy to Crash, Hard to Exploit — Less Than 0.12% of JVMs Estimated at Risk of RCE

Frame 2085668439 (1)
Group 1261154229