Prototype Pollution in flat-wrap
Summary
GHSA-g7h8-p22m-2rvx: Prototype Pollution in flat-wrap. Affects flat-wrap versions >= 0.0.0. No fix is published. 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 flat-wrap package is an npm package that provides a function called unflatten. This function is used to convert a flattened object back into its original nested structure. It is commonly used in JavaScript applications to manipulate and transform data. However, all versions of flat-wrap are vulnerable to prototype pollution.
Vulnerability Detail
Prototype pollution is a vulnerability that occurs when an attacker can modify the prototype of an object. In the case of flat-wrap, the unflatten function does not restrict the modification of an object's prototype. This allows an attacker to add or modify properties that will exist on all objects. This can lead to various security issues, such as remote code execution, information disclosure, or denial of service attacks.
How To Fix
No fixed version is published for this vulnerability.
Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →
Workaround
As there is no fix available, a possible workaround is to implement your own version of the unflatten function with proper prototype checks and restrictions. Here is an example of a modified unflatten function that includes prototype protection:
function unflatten(obj) {
if (typeof obj !== 'object' || obj === null) {
return obj;
}
const result = {};
for (const key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
const keys = key.split('.');
let currentObj = result;
for (let i = 0; i < keys.length - 1; i++) {
const currentKey = keys[i];
if (!currentObj[currentKey] || typeof currentObj[currentKey] !== 'object') {
currentObj[currentKey] = {};
}
currentObj = currentObj[currentKey];
}
const lastKey = keys[keys.length - 1];
currentObj[lastKey] = obj[key];
}
}
return result;
}
Conclusion
The flat-wrap package is vulnerable to prototype pollution, which can have serious security implications. It is recommended to use an alternative package or implement a modified version of the unflatten function with prototype protection. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for flat-wrap →
FAQ
Prototype pollution is a vulnerability that allows an attacker to modify the prototype of an object, leading to various security issues.
The unflatten function in flat-wrap does not restrict the modification of an object's prototype, making it vulnerable to prototype pollution.
The prototype pollution vulnerability in flat-wrap can potentially result in remote code execution, information disclosure, or denial of service attacks.
Currently, there is no fix available for this vulnerability in the flat-wrap package. It is recommended to use an alternative package.
A possible workaround is to implement a modified version of the unflatten function with proper prototype checks and restrictions.