Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-104182 Overview
CVE-2026-104182 is an algorithmic complexity vulnerability in stream-json, a Node.js micro-library for streaming JSON and JSONC processing. Versions prior to 3.6.0 contain a flaw in the JSONC parser at stream-json/jsonc/parser.js and the verifier at stream-json/jsonc/verifier.js. When a block or line comment spans multiple input chunks, both components restart comment-terminator scanning from the opening slash while retaining the accumulated comment buffer. Delivering a large comment across many small chunks produces quadratic CPU work and stalls the Node.js event loop. The plain JSON parser is not affected because it discards consumed string and number data as it advances.
Critical Impact
An attacker with local access to supply JSONC configuration input can trigger quadratic CPU consumption, stalling the Node.js event loop and causing denial of service against the host process.
Affected Products
- stream-json npm package versions prior to 3.6.0
- stream-json/jsonc/parser.js component
- stream-json/jsonc/verifier.js component
Discovery Timeline
- 2026-10-01 - CVE-2026-104182 published to NVD
- 2026-10-05 - Last updated in NVD database
Technical Details for CVE-2026-104182
Vulnerability Analysis
The vulnerability is an algorithmic complexity flaw classified under CWE-407: Inefficient Algorithmic Complexity. When the JSONC parser receives a block comment (/* ... */) or line comment that is split across multiple chunk writes to the stream, the parser rescans the comment from the opening / on every new chunk. The retained comment buffer grows with each chunk while the scan work repeats across the full accumulated buffer, producing O(n²) CPU behavior relative to comment size.
Because Node.js uses a single-threaded event loop, sustained quadratic scanning on a worker stream blocks the event loop and prevents the process from servicing other requests or timers. The maintainer scoped the attack vector as local, noting that JSONC input is treated as user-controlled configuration rather than untrusted internet-facing data.
Root Cause
The comment-terminator state machine does not persist its scan position across chunk boundaries. Instead of resuming the search for */ or newline at the end of the previously scanned region, it restarts from the comment opener while the buffer continues to accumulate characters from each write() call.
Attack Vector
An attacker who controls JSONC input delivered to a stream-json JSONC pipeline supplies a single large comment and arranges for it to be written in many small chunks. Each additional chunk triggers a rescan over the full buffered comment, exhausting a CPU core and stalling the event loop.
// Benchmark excerpt from the official patch demonstrating quadratic scaling
// Source: https://github.com/uhop/stream-json/commit/c0299dc168ce9455ef5ca5b6a0f6850ee7fa0468
import jsoncParser from '../src/jsonc/parser.js';
const feed = doc =>
new Promise((resolve, reject) => {
const stream = jsoncParser.asStream();
stream.on('data', () => {});
stream.on('error', reject);
stream.on('end', resolve);
for (let i = 0; i < doc.length; i += 16384) stream.write(doc.slice(i, i + 16384));
stream.end();
});
const K = 1024;
const docs = {
'comment 256K': '/*' + 'a'.repeat(256 * K) + '*/1',
'comment 512K': '/*' + 'a'.repeat(512 * K) + '*/1',
'comment 1M': '/*' + 'a'.repeat(1024 * K) + '*/1',
'string 1M': '"' + 'a'.repeat(1024 * K) + '"'
};
Source: GitHub commit c0299dc. Doubling comment size producing roughly 4x runtime confirms the quadratic regression; the fixed version scales linearly.
Detection Methods for CVE-2026-104182
Indicators of Compromise
- Sustained 100% CPU utilization by a Node.js process consuming JSONC input, with the event loop unresponsive to health checks
- stream-json versions below 3.6.0 present in package-lock.json, yarn.lock, or node_modules dependency trees
- JSONC input artifacts containing unusually large comment blocks (hundreds of kilobytes or more) delivered in small streamed chunks
Detection Strategies
- Perform software composition analysis across repositories and build artifacts to flag stream-json@<3.6.0 dependencies, including transitive uses
- Instrument Node.js services that parse JSONC with event-loop lag metrics (for example, perf_hooks monitoring) and alert on sustained lag exceeding normal baselines
- Review application logs for stream processing jobs that stall or time out while reading configuration or JSONC input files
Monitoring Recommendations
- Track per-process CPU time and event-loop delay on hosts running services that ingest JSONC configuration
- Monitor dependency manifests in CI pipelines and fail builds when vulnerable stream-json versions are detected
- Log JSONC input sizes and comment-to-content ratios at ingestion points to identify anomalous payloads
How to Mitigate CVE-2026-104182
Immediate Actions Required
- Upgrade stream-json to version 3.6.0 or later in all projects, including transitive dependencies, and rebuild deployment artifacts
- Audit services that accept JSONC input to confirm the source is locally owned or trusted configuration, consistent with the library's documented threat model
- Restrict write access to configuration files consumed by JSONC pipelines so untrusted local users cannot inject oversized comment payloads
Patch Information
The fix is included in stream-json release 3.6.0. The remediation, published in commit c0299dc, reworks comment handling so terminator scanning resumes at the current buffer position rather than restarting from the comment opener, restoring linear scaling. See the GitHub Security Advisory GHSA-hqr4-qq8f-hg3x for the full disclosure.
Workarounds
- Switch affected pipelines to the plain JSON parser if JSONC comment support is not required, since the plain JSON parser is not affected
- Enforce an input size cap on JSONC payloads before they reach the stream pipeline to bound worst-case CPU work
- Validate JSONC configuration offline in a sandboxed worker thread so a stalled parse does not block the main event loop
# Upgrade stream-json to the patched release
npm install stream-json@^3.6.0
# Verify the resolved version in the dependency tree
npm ls stream-json
# Audit for remaining advisories
npm audit --production
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

