CVE-2019-10795: Prototype Pollution in undefsafe
Summary
CVE-2019-10795: Prototype Pollution in undefsafe. Affects undefsafe versions < 2.0.3. Fixed in 2.0.3. 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 package under scrutiny is undefsafe, an npm package. It is designed to safely access deeply nested properties of an object without throwing any errors. It is commonly used in JavaScript applications to prevent crashes caused by accessing undefined properties. However, versions prior to 2.0.3 are vulnerable to Prototype Pollution. This vulnerability allows an attacker to manipulate or add properties to the Object.prototype using a __proto__ payload.
Vulnerability Detail
The Prototype Pollution vulnerability in undefsafe arises from the 'a' function's susceptibility to a __proto__ payload. By exploiting this vulnerability, an attacker can modify or add properties to the Object.prototype, potentially leading to unexpected behavior or security issues in the application. The impact of this vulnerability can range from data integrity issues to remote code execution.
How To Fix
Minimum fixed version
2.0.3
This is the first release that contains the fix.
npm install undefsafe@2.0.3
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If upgrading to the fixed version is not immediately feasible, a temporary workaround is to avoid using the vulnerable 'a' function or to implement input validation and sanitization to prevent malicious payloads from reaching the vulnerable function. Here is an example of input validation for the 'a' function:
function safeAccess(obj, path) {
if (typeof obj !== 'object' || obj === null) {
return undefined;
}
const keys = path.split('.');
let result = obj;
for (const key of keys) {
if (!Object.prototype.hasOwnProperty.call(result, key)) {
return undefined;
}
result = result[key];
}
return result;
}
Conclusion
In conclusion, the undefsafe package prior to version 2.0.3 is vulnerable to Prototype Pollution. This vulnerability allows an attacker to manipulate or add properties to the Object.prototype, potentially leading to unexpected behavior or security issues. It is crucial to upgrade to the fixed version or implement the recommended workarounds to mitigate the risk. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for undefsafe →
FAQ
undefsafe is an npm package used to safely access deeply nested properties of an object without throwing errors. It helps prevent crashes caused by accessing undefined properties.
Prototype Pollution is a vulnerability that allows an attacker to modify or add properties to the Object.prototype. This can lead to unexpected behavior or security issues in the application.
The vulnerability in undefsafe allows an attacker to manipulate or add properties to the Object.prototype using a __proto__ payload. This can result in data integrity issues or even remote code execution.
To fix the vulnerability, it is recommended to upgrade to version 2.0.3 or later of the undefsafe package. This version includes a fix for the Prototype Pollution issue.
If upgrading to the fixed version is not immediately feasible, a temporary workaround is to avoid using the vulnerable 'a' function or to implement input validation and sanitization to prevent malicious payloads from reaching the vulnerable function.