The vulnerability is a prototype pollution issue within the seroval library's deserialization logic. The root cause lies in the deserializeProperties function, which, prior to the patch, failed to sanitize property keys before assigning them to a JavaScript object. This allowed a malicious actor to craft a serialized payload with a key of __proto__, which would then modify the Object.prototype.
Once the Object.prototype is polluted, an attacker can introduce properties that can be triggered by other parts of the application, leading to Remote Code Execution. The vulnerability description mentions that this can be achieved by overriding constant values and through error deserialization, which points to the involvement of deserializeConstant and deserializeError in the exploit chain.
The patch addresses this vulnerability by introducing several security enhancements:
- Key Sanitization: A new
isValidKey function is used to check for and disallow malicious keys like __proto__, constructor, and prototype during property assignment.
- Depth Limiting: A recursion depth limit is introduced in the deserialization functions to prevent stack exhaustion attacks from deeply nested objects.
- Hardened Deserialization: Functions like
deserializeDictionary were updated to use Object.defineProperties instead of Object.assign to avoid triggering potentially malicious setters on the prototype chain.
- Input Validation: Additional checks were added to validate the length of
BigInt, RegExp, and base64 encoded ArrayBuffer data to prevent resource exhaustion.
The identified vulnerable functions are all part of the deserialization process that would be triggered when an application uses fromJSON or fromCrossJSON to process untrusted data.