REDHAT-BUG-2539279: Use After Free
Librsvg uses libxml2, a C library, to parse XML. When librsvg parses an SVG document which has a nested Xinclude, an XML entity declaration with a duplicate name as an existing one can cause a use-after-free error.
While libxml2 is expanding an internal entity, a recursive XInclude can parse another document that declares an entity with the same name. Both parses use the same XmlState entity map on the librsvg side. entityinsert() replaces the first entry, whose Drop implementation calls xmlFreeNode(). The outer xmlCtxtParseEntity() then keeps using the freed 144-byte xmlEntity.
The included parse should not free an entity that the outer parser is still using.
The fix is in commit 8a1b0cd319e9af2d1e9cf878081dd77f227a0504, where librsvg will no longer free xmlEntity pointers that libxml2 is still using.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
librsvgto a version that resolves this vulnerability.Patch 8a1b0cd319e9af2d1e9cf878081dd77f227a0504
Event History
Frequently Asked Questions
What input conditions are required to trigger the flaw?
The SVG must use a nested XInclude and an XML entity declaration whose name duplicates an existing entity. Exploitation occurs when libxml2 is expanding an internal entity while the recursive XInclude parses another document declaring that same entity name.
What component is affected during parsing?
The issue is in librsvg's shared XmlState entity map when it parses SVG XML through libxml2. Replacing the existing entity-map entry frees an xmlEntity that the outer libxml2 parse continues to use, causing a use-after-free.
What is the relevant remediation?
Use a librsvg build containing commit 8a1b0cd319e9af2d1e9cf878081dd77f227a0504. That change prevents librsvg from freeing xmlEntity pointers that libxml2 is still using.