The vulnerability is a command injection flaw within the ImageMagick's internal SVG decoder. The root cause is the failure to properly sanitize and escape user-controllable data from an SVG file before constructing Magick Vector Graphics (MVG) commands. An attacker can embed malicious MVG syntax within various parts of an SVG file, such as element attributes (e.g., href), style properties, or descriptive text.
The analysis of the patches reveals that several functions in coders/svg.c were involved in processing this untrusted data. The primary vulnerable functions are SVGStartElement, SVGProcessStyleElement, and SVGEndElement. These functions were responsible for parsing the SVG structure and directly using values from the file to generate the output MVG file. The patches systematically add escaping to mitigate this, primarily by introducing a new SVGEscapeString function and applying it to all incoming values from attributes and styles. The changes in SVGEndElement show how unescaped data, like URLs, were previously being written directly into the MVG command stream. During the rendering of the malicious SVG, these injected commands would be executed by the MVG engine, leading to the vulnerability.