qs.stringify with allowEmptyArrays does not encode the keys of empty arrays, allowing query string parameter injection
影響パッケージ
| パッケージ | 影響を受ける版 → 修正版 | |
|---|---|---|
| ljharbqs |
6.12.0 以上 6.12.6 未満→ 6.12.6 6.13.0 以上 6.13.4 未満→ 6.13.4 6.14.0 以上 6.14.3 未満→ 6.14.3 6.15.0 以上 6.15.4 未満→ 6.15.4 6.16.0 以上 6.16.2 未満→ 6.16.2 |
6.12.6 6.13.4 6.14.3 6.15.4 6.16.2 |
ディストリビューション別の修正状況
各ディストリビューションが公開している、この CVE の記録です。修正版は配布版ごとに違うので、リンク先で確かめてください。
- Debian DEBIAN-CVE-2026-110910 node-qs この記録に修正版の記載なし
- Ubuntu UBUNTU-CVE-2026-110910 node-qs この記録に修正版の記載なし
原文の説明 取得元が公開している説明をそのまま載せています (多くは英語)。
Summary
qs.stringify with allowEmptyArrays: true writes the key of an empty array without encoding it, even though keys are encoded by default. A key that contains & (or the configured delimiter), =, or # therefore becomes query string syntax instead of data, so a caller-supplied key name can add parameters to the serialized query string, or cut it short.
Details
In lib/stringify.js, the allowEmptyArrays branch returns adjustedPrefix + '[]' early, before the code that passes every other key through encoder and formatter. So { "x&k=v": ["1"] } serializes as x%26k%3Dv%5B0%5D=1, but { "x&k=v": [] } serializes as x&k=v[]. The early return applies at any depth ({ "a": { "b&k=v": [] } } gives a[b&k=v][]), under every arrayFormat, with allowDots, and with a custom encoder, which is never called for that key. With encode: false or encodeValuesOnly: true, keys are intentionally left unencoded on every path; those configurations are not affected.
PoC
var qs = require("qs");
var query = qs.stringify({ q: "hi", "x&apiKey=evil&y": [] }, { allowEmptyArrays: true });
// "q=hi&x&apiKey=evil&y[]"
qs.parse(query);
// { q: "hi", x: "", apiKey: "evil", y: [""] }
qs.stringify({ "x#": [], z: "1" }, { allowEmptyArrays: true });
// "x#[]&z=1": in a URL, everything after "#" becomes the fragment
Fix
Applied in 234d505 on main and released as v6.17.0, and backported to v6.16.2, v6.15.4, v6.14.3, v6.13.4, and v6.12…
出典: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory
参照URL
- advisory github.com
- advisory github.com
- advisory nvd.nist.gov
- package github.com
- patch github.com
- patch github.com
- patch github.com
- patch github.com
- patch github.com
- patch github.com
- patch github.com
- REDHAT Red Hat
- report github.com
- web npmjs.com