CVE-2026-2391
Publication date:
12/02/2026
### Summary<br />
The `arrayLimit` option in qs does not enforce limits for comma-separated values when `comma: true` is enabled, allowing attackers to cause denial-of-service via memory exhaustion. This is a bypass of the array limit enforcement, similar to the bracket notation bypass addressed in GHSA-6rw7-vpxm-498p (CVE-2025-15284).<br />
<br />
### Details<br />
When the `comma` option is set to `true` (not the default, but configurable in applications), qs allows parsing comma-separated strings as arrays (e.g., `?param=a,b,c` becomes `[&#39;a&#39;, &#39;b&#39;, &#39;c&#39;]`). However, the limit check for `arrayLimit` (default: 20) and the optional throwOnLimitExceeded occur after the comma-handling logic in `parseArrayValue`, enabling a bypass. This permits creation of arbitrarily large arrays from a single parameter, leading to excessive memory allocation.<br />
<br />
**Vulnerable code** (lib/parse.js: lines ~40-50):<br />
```js<br />
if (val && typeof val === &#39;string&#39; && options.comma && val.indexOf(&#39;,&#39;) > -1) {<br />
return val.split(&#39;,&#39;);<br />
}<br />
<br />
if (options.throwOnLimitExceeded && currentArrayLength >= options.arrayLimit) {<br />
throw new RangeError(&#39;Array limit exceeded. Only &#39; + options.arrayLimit + &#39; element&#39; + (options.arrayLimit === 1 ? &#39;&#39; : &#39;s&#39;) + &#39; allowed in an array.&#39;);<br />
}<br />
<br />
return val;<br />
```<br />
The `split(&#39;,&#39;)` returns the array immediately, skipping the subsequent limit check. Downstream merging via `utils.combine` does not prevent allocation, even if it marks overflows for sparse arrays.This discrepancy allows attackers to send a single parameter with millions of commas (e.g., `?param=,,,,,,,,...`), allocating massive arrays in memory without triggering limits. It bypasses the intent of `arrayLimit`, which is enforced correctly for indexed (`a[0]=`) and bracket (`a[]=`) notations (the latter fixed in v6.14.1 per GHSA-6rw7-vpxm-498p).<br />
<br />
### PoC<br />
**Test 1 - Basic bypass:**<br />
```<br />
npm install qs<br />
```<br />
<br />
```js<br />
const qs = require(&#39;qs&#39;);<br />
<br />
const payload = &#39;a=&#39; + &#39;,&#39;.repeat(25); // 26 elements after split (bypasses arrayLimit: 5)<br />
const options = { comma: true, arrayLimit: 5, throwOnLimitExceeded: true };<br />
<br />
try {<br />
const result = qs.parse(payload, options);<br />
console.log(result.a.length); // Outputs: 26 (bypass successful)<br />
} catch (e) {<br />
console.log(&#39;Limit enforced:&#39;, e.message); // Not thrown<br />
}<br />
```<br />
**Configuration:**<br />
- `comma: true`<br />
- `arrayLimit: 5`<br />
- `throwOnLimitExceeded: true`<br />
<br />
Expected: Throws "Array limit exceeded" error.<br />
Actual: Parses successfully, creating an array of length 26.<br />
<br />
<br />
### Impact<br />
Denial of Service (DoS) via memory exhaustion.
Severity CVSS v4.0: MEDIUM
Last modification:
12/02/2026