The vulnerability is a prototype pollution issue within the setByPath utility function in @casl/ability. This function is used to set nested properties on an object using a string path. The vulnerability occurs because, prior to the patch, setByPath did not sanitize or validate the property names within the path. An attacker could provide a path containing __proto__, constructor, or prototype to modify the Object.prototype.
The primary function that exposes this vulnerability is rulesToFields, which is part of the public API. This function takes CASL rules and uses setByPath to transform them into a different object structure. If an attacker can control the conditions of the rules passed to rulesToFields, they can craft a malicious path (e.g., { "__proto__.isAdmin": true }) that will be processed by setByPath, leading to prototype pollution. This could allow them to escalate privileges or cause a denial of service by modifying the behavior of all objects in the application.
The patch addresses this by introducing a FORBIDDEN_PROPERTIES set containing __proto__, constructor, and prototype. The setByPath function was modified to check each part of the property path against this set, refusing to process any forbidden properties and thus preventing the pollution.