Aug 8, 2026·6 min read·32 visits
SvelteKit versions before 2.70.2 are vulnerable to a CPU-exhausting ReDoS via malformed Accept headers due to an unanchored regular expression in its content negotiation parser.
A Regular Expression Denial of Service (ReDoS) vulnerability exists in SvelteKit's content negotiation header parser prior to version 2.70.2. An unauthenticated remote attacker can exploit this vulnerability by sending a crafted Accept header with highly repetitive malformed values. This triggers catastrophic backtracking on the single-threaded Node.js/Bun event loop, leading to CPU exhaustion and full denial of service.
SvelteKit utilizes a content negotiation system to determine how to format and serve responses to clients. This mechanism, residing in packages/kit/src/utils/http.js, inspects incoming HTTP request headers—specifically the Accept header—to identify the appropriate MIME types requested by the client.
Because content negotiation occurs globally early in the middleware request lifecycle, the parsing path is exposed to all incoming network requests. This introduces an unauthenticated attack surface that does not require any session establishment, specific API privileges, or application-specific configurations.
The parsing logic relies on a regular expression designed to break down comma-separated MIME types and extract quality values (such as q=0.9). However, due to an unanchored configuration within this pattern (CWE-1333), the parser is susceptible to a catastrophic backtracking loop when presented with a specially crafted string. An attacker can exploit this behavior to force high CPU utilization, exhausting server-side compute resources.
The root cause of this vulnerability lies in the unanchored nature of SvelteKit's MIME-type parsing regular expression:
/([^/ \\t]+)\\/([^; \\t]+)[ \\t]*(?:;[ \\t]*q=([0-9.]+))?/When evaluating a regular expression, engines typically attempt to find a match starting at the first character of the string. If a match attempt fails, and the regular expression does not contain a start anchor (such as ^), the engine advances the starting pointer to the next character in the string and restarts the entire matching routine.
Consider an input string of length $N$ consisting entirely of the character 'a' without any forward slash / (e.g., "aaaa...aaa"). The engine begins matching at index 0, where the greedy group ([^/ \\t]+) matches the entire sequence of $N$ characters. The engine then attempts to match the literal slash \\/ character, which is missing from the input. This mismatch triggers back-tracking, forcing the engine to test smaller subsets of the greedy group.
Once all backtracking paths at index 0 fail, the unanchored engine shifts its starting window to index 1 and repeats the process. It continues this behavior for every index up to $N$. This results in a quadratic execution complexity of $O(N^2)$, executing roughly $\frac{N \times (N+1)}{2}$ steps. In a single-threaded execution model like Node.js or Bun, this computationally intensive loop completely blocks the main event loop.
The vulnerable logic is found within the negotiate function inside packages/kit/src/utils/http.js. The function splits the Accept header on commas and processes each segment:
// Vulnerable Code Path
export function negotiate(accept, types) {
const parts = [];
accept.split(',').forEach((str, i) => {
// Unanchored regex allows the engine to retry matching at every character offset
const match = /([^/ \\t]+)\\/([^; \\t]+)[ \\t]*(?:;[ \\t]*q=([0-9.]+))?/.exec(str);
if (match) {
// processing matches...
}
});
}The fix, introduced in commit 82712fc02c24b1dcf5b25d7a52129cd8455f04f5, prepends the start-of-line anchor ^[ \\t]* to lock the evaluation to the very beginning of each segment:
// Patched Code Path
export function negotiate(accept, types) {
const parts = [];
accept.split(',').forEach((str, i) => {
// Prepending the ^ anchor limits attempts strictly to the beginning of the string
const match = /^[ \\t]*([^/ \\t]+)\\/([^; \\t]+)[ \\t]*(?:;[ \\t]*q=([0-9.]+))?/.exec(str);
if (match) {
// processing matches...
}
});
}By forcing the regular expression to match only from the start of the string, the engine is prevented from shifting its evaluation window. If the match fails at index 0, the evaluation is immediately aborted. This restricts the execution complexity to a safe, linear $O(N)$ runtime.
Exploitation of this vulnerability is straightforward and requires only a single, malformed HTTP request. An attacker targets any SvelteKit endpoint with a custom Accept header containing a highly repetitive pattern of alphanumeric characters containing no slash.
An example of a conceptual payload sent via HTTP:
GET / HTTP/1.1
Host: vulnerable-app.internal
Accept: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Connection: closeBecause many standard web servers and reverse proxies enforce an 8 KB limit on request headers, the size of a single header segment is physically constrained. However, even an 8,000-character payload forces millions of evaluations inside the regular expression engine. Multiple concurrent requests containing this payload will quickly saturate all available CPU threads allocated to the Node.js application process.
The impact of this vulnerability is a complete loss of service availability. While confidential data exposure and unauthorized write actions are not possible (resulting in a CVSS vector of C:N/I:N/A:L or A:H depending on deployment topology), the blocking of the single-threaded Node.js or Bun event loop ensures that no other network requests can be processed.
In containerized or auto-scaling environments (such as AWS ECS, Kubernetes, or serverless platforms), the CPU exhaustion will trigger horizontal scaling, potentially resulting in inflated operational costs. In single-instance node architectures, this attack will permanently freeze the web server until the process is manually restarted or killed by a health check timeout.
The recommended remediation is upgrading @sveltejs/kit to version 2.70.2 or later. This replaces the vulnerable regular expression engine configuration with the anchored version.
If immediate software upgrade is not possible, implement the following mitigations:
Accept headers longer than 1024 bytes.Accept header contains long contiguous sequences of letters without a / character.SvelteKit developers integrated the following regression test inside packages/kit/src/utils/http.spec.js to ensure backtracking issues do not reappear:
test('ignores an accept segment with no slash without catastrophic backtracking', () => {
assert.equal(negotiate('a'.repeat(200_000), ['text/html']), undefined);
}, 100);This test suite fails if the execution of negotiate on a 200,000-character string takes longer than the strict 100ms timeout threshold.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L| Product | Affected Versions | Fixed Version |
|---|---|---|
@sveltejs/kit Svelte | < 2.70.2 | 2.70.2 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-1333 (Inefficient Regular Expression Complexity) |
| Attack Vector | Network (AV:N) |
| CVSS | 5.3 (Medium) |
| EPSS | N/A |
| Impact | Denial of Service (DoS) |
| Exploit Status | PoC Available |
| KEV Status | Not Listed |
The software uses a regular expression that can take a very long time to evaluate on certain inputs, leading to a Denial of Service.
CVE-2026-126298 (also tracked as GHSA-r53h-rw34-8h97) is an algorithmic complexity Denial of Service (DoS) vulnerability in the Natural Language Toolkit (NLTK) Python library affecting all versions prior to 3.10.4. The vulnerability resides in the nltk.tree.transforms.chomsky_normal_form function and its corresponding public method Tree.chomsky_normal_form(). When transforming a parse tree into Chomsky Normal Form using the default right-factoring strategy, the function repeatedly invokes list.pop(0) inside a loop iterating over all children of a node. In CPython, removing the initial element of a standard list requires an O(N) memory shift operation, causing the overall binarization algorithm to degrade to O(N^2) quadratic time complexity relative to the width of a node. Furthermore, converting horizontal node width into vertical tree depth bypasses initial parsing depth bounds, triggering subsequent stack exhaustion (RecursionError) when recursive methods traverse the mutated structure. Unauthenticated remote attackers who can submit bracketed tree strings to applications invoking this transformation can exhaust single-threaded CPU resources or induce unhandled application exceptions.
An algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) before version 3.10.4 allows remote unauthenticated attackers to cause a denial of service via crafted Combinatory Categorial Grammar (CCG) lexicon strings. The parser in nltk.ccg.lexicon.fromstring performs repeated immutable string slicing, concatenation, and regex tail capturing, resulting in O(n^2) CPU consumption when processing wide, flat category definitions.
CVE-2026-126295 (also tracked as GHSA-fg9w-wfp5-j933) is a path confinement bypass vulnerability in the Natural Language Toolkit (NLTK) affecting versions 3.10.0 prior to 3.10.4. The flaw resides in nltk/parse/bllip.py within the BllipParser class and its factory method BllipParser.from_unified_model_dir(). Unlike sibling tool wrappers in NLTK that enforce data-root confinement via the nltk.pathsec module, BllipParser passes caller-supplied filesystem paths directly into the third-party bllipparser native C extension without validation. When an application passes untrusted input as model paths or directories to BllipParser, an attacker can force the native extension to open arbitrary files on the local filesystem. This leads to information disclosure through parser diagnostic oracles, local model tampering via shared directories, and denial of service by hanging worker threads on blocking special files (such as FIFOs or device nodes) or exhausting memory via oversized files.
CVE-2026-126300 (GHSA-ffr9-mgrr-wcvr) is an inefficient algorithmic complexity vulnerability (CWE-407) in the Natural Language Toolkit (NLTK) Python library affecting versions 3.2.5 prior to 3.10.4. The flaw resides in the quote-restoration routine of TreebankWordTokenizer.span_tokenize and NLTKWordTokenizer.span_tokenize, where repeated calls to list.pop(0) over matched quote tokens introduce quadratic O(n^2) time complexity. An unauthenticated remote attacker who supplies input containing long sequences of double-quote characters can exhaust CPU resources and degrade service availability.
The Natural Language Toolkit (NLTK) versions 3.6 through 3.10.3 contain an algorithmic complexity vulnerability in the LegalitySyllableTokenizer.tokenize method. When processing tokens composed of continuous runs of vowels, an unguarded string reversal and set membership lookup loop executes in quadratic time relative to the input token length. Remote attackers capable of submitting arbitrary text to applications utilizing this tokenizer can trigger sustained single-core CPU exhaustion and application-level denial of service.
CVE-2026-126304 is a symlink path traversal vulnerability (CWE-59) in the Natural Language Toolkit (NLTK) versions 3.10.0 prior to 3.10.4. The YCOECorpusReader class constructs internal sub-readers for the 'psd' and 'pos' subdirectories using FileSystemPathPointer.join(), which relies exclusively on lexical string-prefix validation rather than canonical path resolution. An attacker who supplies a crafted YCOE corpus containing symbolic links in place of the 'psd' or 'pos' subdirectories can bypass directory confinement and read arbitrary files from sibling corpora or sensitive directories within the NLTK data sandbox.