NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · npm

CVE-2026-118664: decode-uri-component vulnerable to denial of service via quadratic replacement of percent-encoded runs

highCVSS 4.0 8.2GHSA-qr28-fpjm-wq7f

The npm package `decode-uri-component` 0.5.0 and earlier takes quadratic time to decode malformed input with many distinct percent-encoded runs. One unauthenticated request of about 224 KB can freeze a Node.js event loop for roughly 20 seconds. Upgrade to 0.5.1. It also reaches apps through `query-string`.

Published Oct 29, 2026 · Analysis Oct 31, 2026

What an attacker can do

When native decodeURIComponent throws, the package falls back to customDecodeURIComponent. That function records every distinct percent-encoded run (such as %C3%A5) in a lookup table. It then runs one full-string input.replace(new RegExp(key, 'g'), ...) for each entry. With K distinct runs in an input of length L, that is K regex compilations and K full scans, so O(K·L). K grows with L, and a trailing %zz is enough to force the fallback.

The 0.5.0 release fixed CVE-2026-45822 by replacing a recursive decode() with a linear scanner, but kept this replacement loop. That is why 0.5.0 is still vulnerable.

Node.js runs JavaScript on one thread, so one slow decode stalls every other client. The harm depends on where the input comes from. Node's default 16 KB header limit holds URL query strings to about 40 ms per request. Request bodies have no such limit, so a form body parsed with query-string.parse() is fully exposed. The advisory rates it availability only, with no confidentiality or integrity impact.

Who is affected

All versions up to and including 0.5.0 are affected. Applications are exposed when untrusted input reaches decodeUriComponent(), directly or through a dependency such as query-string. The risk is highest where large request bodies are decoded.

Find every copy in your tree:

npm ls decode-uri-component

decode-uri-component

Ecosystem
npm
Affected
<= 0.5.0
Fixed in
0.5.1
Check
npm ls decode-uri-component

How to fix it

Upgrade to decode-uri-component 0.5.1. The fix replaces the per-key replace loop with a single pass, input.replace(multiMatcher, run => decode(run)), and never rescans decoded output.

npm install [email protected]

For transitive copies, update the parent package, for example query-string, or add an overrides entry (npm) or resolutions entry (yarn) pinning 0.5.1. The sources give no other workaround. Capping request body size reduces exposure until you patch.

How to tell if you were hit

Look for event-loop stalls: request latency spikes, health checks timing out, or a Node process pinned at 100% CPU on one core while handling form or query-string parsing. Check access logs for unusually large request bodies (hundreds of KB) containing long runs of %XX%YY sequences, often ending in an invalid escape such as %zz. A CPU profile of a stalled process will show time in customDecodeURIComponent and String.prototype.replace.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Summary

decodeUriComponent() takes quadratic time on malformed input that has many distinct percent-encoded runs. A single unauthenticated request of about 224 KB can block the Node.js event loop for about 20 seconds. Version 0.5.0, the release that fixed CVE-2026-45822, is affected.

Details

When native decodeURIComponent throws, decodeUriComponent() falls back to customDecodeURIComponent (index.js:122). That function:

  1. Scans the input for every run of percent-encoded bytes (e.g. %C3%A5) and stores each distinct run, with its decoded value, in a lookup table (index.js:130-144).
  2. Runs one full-string input.replace(new RegExp(key, 'g'), …) per table entry (index.js:154).

With K distinct runs in an input of length L, that's K regex compilations and K full scans of the string, so O(K·L). An attacker controls both K and L, and K grows with L. One malformed sequence such as a trailing %zz is enough to force the fallback path.

The 0.5.0 fix for CVE-2026-45822 (fa479da) replaced the recursive decode() routine with a linear scanner, but left this replacement loop unchanged.

Proof of concept

Running the following code takes ~20 seconds.

import decodeUriComponent from 'decode-uri-component';

let payload = '';
for (let i = 0; i < 32000; i++) {
	const high = Math.floor(i / 256).toString(16).padStart(2, '0');
	const low = (i % 256).toString(16).padStart(2, '0');
	payload += `%${high}%${low}x`; // distinct run each iteration
}
payload += '%zz'; // forces the fallback decoder

console.time('decode');
decodeUriComponent(payload); // ~224 KB
console.timeEnd('decode');

Impact

This is an availability issue only and there's no confidentiality or integrity impact. Any application that passes untrusted input to decodeUriComponent(), directly or through a dependency such as query-string, can be made unresponsive. Because Node.js runs on one thread, one request stalls every other client.

The worst case needs input well beyond URL length limits. Node's default 16 KB header limit keeps payloads passed in via a URL query string to roughly 40 ms per request. Applications that decode request bodies are fully exposed, for example form bodies parsed with query-string.parse().

Credited to gdegrange.

Questions

Is decode-uri-component 0.5.0 safe since it fixed CVE-2026-45822?

No. The 0.5.0 fix replaced the recursive decoder with a linear scanner but left the per-key regex replacement loop in customDecodeURIComponent. That loop is the cause here, and 0.5.1 removes it.

Can an attacker exploit this through a URL query string?

Only weakly. Node's default 16 KB header limit keeps a query-string payload to about 40 ms per request. The 20-second case needs about 224 KB, so request bodies, such as forms parsed with query-string.parse(), are the real exposure.

Is this exploited in the wild?

No source reports exploitation, and it is not in CISA's KEV catalog. The advisory includes a short proof of concept, and the EPSS score is low at 0.32%.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More npm vulnerabilities

All npm entries