The vulnerability lies in the deserialization of RegExp objects within the seroval library. The core of the issue is in the deserializeRegExp function, which, before the patch, would create a RegExp object from a serialized string without any checks on the string's length or complexity. This allows an attacker to craft a malicious payload with either an extremely long regular expression pattern to exhaust memory, or a pattern designed to cause catastrophic backtracking (ReDoS), effectively causing a Denial of Service.
The patch addresses this by introducing two main changes. First, it adds a feature flag, Feature.RegExp, which allows users to disable the serialization and deserialization of RegExp objects altogether via a disabledFeatures option in the main API functions like fromJSON and fromCrossJSON. Second, it introduces a length check (MAX_REGEXP_SOURCE_LENGTH) within the deserializeRegExp function to prevent the creation of overly large regular expressions even when the feature is enabled. The vulnerable functions identified are the entry points (fromJSON, fromCrossJSON) that accept the malicious data, the main deserialization dispatcher (deserialize), and the function where the vulnerable action occurs (deserializeRegExp).