CVE-2022-24999: Vulnerability in qs Package Causes Node Process Hang in Express
Summary
CVE-2022-24999: qs before 6.10.3, as used in Express before 4.17.3 and other products, allows attackers to cause a Node process hang for an Express application because an proto key can be used. Affects node-qs across 3 version ranges.
< 3d7fce56a35f4f73fa437866cd1401587a212334
< 6.9.4+ds-1+deb11u1
< 90d9f2b45715b7b03da92113a7b8af236c01088d
Fixed in 6.9.4+ds-1+deb11u1. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The qs package is a querystring parsing and stringifying library for Node.js. It is commonly used in Express applications and other products. The vulnerability (CVE-2022-24999) allows attackers to cause a Node process hang for an Express application by exploiting the proto key. This vulnerability affects qs versions before 6.10.3 and Express versions before 4.17.3.
Vulnerability Detail
The vulnerability arises from the ability of an unauthenticated remote attacker to manipulate the query string of a URL used to visit an Express application. By including a payload like a[proto]=b&a[proto]&a[length]=100000000, the attacker can trigger a hang in the Node process. This occurs due to prototype poisoning in the qs package. The fix for this vulnerability was backported to qs versions 6.9.7, 6.8.3, 6.7.3, 6.6.1, 6.5.3, 6.4.1, 6.3.3, and 6.2.4, as well as Express version 4.17.3.
How To Fix
Minimum fixed version
6.9.4+ds-1+deb11u1
This is the first release that contains the fix.
sudo apt-get install --only-upgrade node-qs
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If updating the packages is not immediately feasible, a workaround can be implemented by manually patching the vulnerable code. The following code snippet demonstrates how to remove the proto key from the query string using the qs.parse() method:
const qs = require('qs');
const queryString = 'a[__proto__]=b&a[__proto__]&a[length]=100000000';
const parsedQuery = qs.parse(queryString);
if (parsedQuery.__proto__) {
delete parsedQuery.__proto__;
}
const sanitizedQueryString = qs.stringify(parsedQuery);
console.log(sanitizedQueryString);
Conclusion
The vulnerability in the qs package (CVE-2022-24999) can lead to a hang in the Node process for Express applications. It is crucial to update the qs and Express packages to the fixed versions to mitigate this vulnerability. If updating is not immediately possible, the provided workaround can be implemented. For further support on vulnerability remediation, you can reach out to DevNack.com.
See every vulnerability recorded for node-qs →
FAQ
The vulnerability allows an attacker to cause a hang in the Node process for an Express application. This can lead to denial of service and disrupt the normal functioning of the application.
The vulnerability affects qs versions before 6.10.3 and Express versions before 4.17.3.
You can use the Vulert Playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Simply upload your package-lock.json file and the tool will analyze it for vulnerabilities.
There are currently no known exploits of this vulnerability. However, it is important to patch the vulnerability as soon as possible to prevent any potential attacks.
The recommended workaround is to update the packages to the fixed versions. However, if immediate updating is not feasible, you can manually patch the vulnerable code as shown in the provided code snippet.
Related vulnerabilities
Recent vulnerabilities recorded for node-qs.