The vulnerability is a classic 'Billion Laughs' XML entity expansion attack. SVGO, in its process of parsing SVG files, was susceptible to denial of service. The root cause was in the XML parsing logic, which did not properly restrict recursive entity references within the SVG's DOCTYPE. The analysis of the provided patches across three different major versions (v2, v3, and v4) consistently points to changes in lib/parser.js and the underlying sax dependency.
The function parseSvg in lib/parser.js is identified as the core vulnerable function. It is responsible for creating and configuring the SAX parser. Before the fix, it used a vulnerable version of the parser or configured it in a way that allowed for uncontrolled entity expansion. The patches address this by upgrading the sax dependency to a version that includes protections against this attack (e.g., limits on entity expansion depth and count) and ensuring the parser is configured correctly.
The optimize function, being the primary entry point of the SVGO library as demonstrated in the PoC, is the function that receives the untrusted input and initiates the parsing process by calling parseSvg. Therefore, it is a key runtime indicator for this vulnerability.