The vulnerability lies in the way the devalue library handled object serialization and deserialization, specifically concerning the __proto__ property, which is a known vector for prototype pollution attacks in JavaScript. The core issue was the use of for...in loops in the uneval, stringify, and unflatten functions. A for...in loop iterates over all enumerable properties of an object, including those inherited from its prototype chain. An attacker could provide a crafted object (e.g., JSON.parse('{"__proto__":{"polluted":true}}')) to these functions. The for...in loop would then iterate over the __proto__ property, causing the library to generate a string of code. When this output string is later executed by eval(), it modifies the global Object.prototype, polluting it with properties controllable by the attacker. The patch addresses this by replacing all instances of for...in with for (const key of Object.keys(...)), which only iterates over an object's own properties, and by adding explicit checks to throw an error if a key is named __proto__, thus preventing the pollution vector.