Threats tagged 'ghsa-jj87-hc4r-jwfw'
1 threat
Most recently published first
| Severity | CVSS | Signals | Threat | Source | Published | Score and star |
|---|---|---|---|---|---|---|
| Medium | 6.2 | EPSS 0.1% | CVE-2026-114129stream-json · Inefficient Algorithmic Complexity Medium6.2EPSS 0.1%CVE Database V5CVE-2026-114129 ## Summary `FlexAssembler`, the custom-container assembler shipped in the `stream-json` package (`src/core/utils/flex-assembler.js`, re-exported at `stream-json/utils/flex-assembler.js` and `stream-json/web/utils/flex-assembler.js`), compiles a string or RegExp path `filter` into a matcher that runs `keyStack.join(separator)` on every container start. Because the key stack grows one entry per open object or array with no depth bound, a JSON document nested to depth D drives D container-start tokens that each perform an O(D) join, for O(D^2) total CPU on the single-threaded event loop. An unauthenticated party who can supply JSON bytes to a pipeline that uses a `FlexAssembler` with a string or RegExp rule filter can stall the process with a small input: roughly 96 KB (depth 16000) blocks the event loop for over a second, and the cost grows quadratically. ## Root Cause `FlexAssembler` reconstructs JavaScript values from the parser token stream and supports custom containers selected by path-matching rules. When a rule `filter` is a string or RegExp, `compileFilter` returns a matcher that computes the joined path from the full key stack before making any match decision. That join is O(current depth), and it is invoked unconditionally for every rule on every container start. The key stack that feeds the join has no depth cap. The package does have a depth guard (`maxDepth`), but it exists only in the unrelated filter base state machine and never executes on the `FlexAssembler` code path, so nested input is unbounded here. ```text src/core/utils/flex-assembler.js compileFilter (lines 5-21): string branch computes `path.join(separator)` (line 10) before the `=== filter || startsWith(...)` comparison; RegExp branch computes `filter.test(path.join(separator))` (line 17). The join runs first, unconditionally. FlexAssembler._matchRule (lines 160-166): calls `rule.filter(this.keyStack)` for every rule; invoked from startObject (line 184) and startArray (line 197) on every container start. FlexAssembler._pushState (lines 168-176): pushes one entry onto `keyStack` per open container with no depth bound. ``` ## Impact An attacker who can deliver JSON to a pipeline whose `FlexAssembler` is configured with a string or RegExp rule filter (a documented, tested, first-class option: `Filter = string | RegExp | FilterFunction`) can cause quadratic CPU consumption. The join runs regardless of whether the rule ultimately matches, so no attacker knowledge of the schema is required beyond nesting depth, which the attacker fully controls. The demonstrated capability is an availability impact: a small crafted document blocks the Node.js event loop, stalling all concurrent work on the process. There is no confidentiality or integrity impact. A consumer that uses only a function filter or no rules is not affected, which narrows the vulnerable population but does not raise attack complexity once such a configuration is in use. ## Proof of Concept `Node.js and the published stream-json@3.6.0 package. Drive a FlexAssembler configured with a string rule filter, comparing against a function filter as a negative control.` 1. Install `stream-json@3.6.0`. 2. Construct a deeply nested object token stream (or equivalently parse a document like `'{"k":'` repeated D times, a `1`, then `'}'` repeated D times, through `parser`/`parserStream`). 3. Feed it to a `FlexAssembler` whose `objectRules` contains a rule with a string `filter`. 4. Observe wall-clock time scaling as roughly 4x per doubling of D (quadratic), while a function-filter configuration stays flat. ```js import FlexAssembler from 'stream-json/utils/flex-assembler.js'; function run(filter, D) { const asm = new FlexAssembler(filter ? {objectRules: [{filter, create: () => ({})}]} : undefined); const t = performance.now(); asm.startObject(); for (let i = 0; i < D; i++) { asm.keyValue('k'); asm.startObject(); } return performance.now() - t; } for (const D of [4000, 8000, 16000, 32000]) console.log('string', D, run('k', D).toFixed(1), 'ms'); for (const D of [4000, 8000, 16000, 32000]) console.log('function(control)', D, run(p => p.length > 0, D).toFixed(1), 'ms'); ``` ```text string filter (path.join per token): function filter (negative control, no join): D=4000 91.9 ms D=4000 1.6 ms D=8000 341.9 ms D=8000 0.9 ms D=16000 1359.2 ms (~4x per doubling) D=16000 1.7 ms (flat) D=32000 5430.0 ms (= O(D^2)) D=32000 2.6 ms ``` End to end through a real `parserStream`, roughly 96 KB (depth 16000) of attacker-supplied JSON stalls the event loop for over 1.3 seconds. ## Attack Chain 1. **Exposure:** The attacker supplies JSON bytes to a service pipeline that assembles values with a `FlexAssembler` configured with a string or RegExp rule filter; `FlexAssembler` is a documented submodule of the published package on both the Node and Web Streams surfaces. 2. | CVE Database V5 |
Showing 1–1 of 1 result