CVE-2024-31573: Medium severity maven/org.xmlunit:xmlunit-core vulnerability
Impact When performing XSLT transformations XMLUnit for Java did not disable XSLT extension functions by default. Depending on the XSLT processor being used this could allow arbitrary code to be executed when XMLUnit is used to transform data with a stylesheet who's source can not be trusted. If the stylesheet can be provided externally this may even lead to a remote code execution.
Patches Users are advised to upgrade to XMLUnit for Java 2.10.0 where the default has been changed by means of https://github.com/xmlunit/xmlunit/commit/b81d48b71dfd2868bdfc30a3e17ff973f32bc15b
Workarounds XMLUnit's main use-case is performing tests on code that generates or processes XML. Most users will not use it to perform arbitrary XSLT transformations.
Users running XSLT transformations with untrusted stylesheets should explicitly use XMLUnit's APIs to pass in a pre-configured TraX TransformerFactory with extension functions disabled via features and attributes. The required setFactory or setTransformerFactory methods have been available since XMLUnit for Java 2.0.0.
References Bug Report JAXP Security Guide
Other sources
XMLUnit for Java before 2.10.0, in the default configuration, might allow code execution via an untrusted stylesheet (used for an XSLT transformation), because XSLT extension functions are enabled.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
maven/org.xmlunit:xmlunit-coreto a version that resolves this vulnerability.Fixed in 2.10.0 - Upgrade
Upgrade
XMLUnit for Javato a version that resolves this vulnerability.Fixed in 2.10.0 - Configuration
Use XMLUnit's APIs to provide a pre-configured TraX TransformerFactory with extension functions disabled via features and attributes when processing untrusted stylesheets.
XMLUnit for Java XSLT transformations XSLT extension functions = disabled
Event History
Frequently Asked Questions
Who is realistically exposed to this issue?
Users are exposed when XMLUnit for Java performs XSLT transformations using a stylesheet whose source is not trusted. XMLUnit's main use case is XML testing, so users that do not perform arbitrary XSLT transformations are less likely to be affected.
What does an attacker need to exploit it?
An attacker needs a way to influence the XSLT stylesheet used by an XMLUnit transformation. If the stylesheet can be supplied externally, exploitation may lead to remote code execution depending on the XSLT processor in use.
What should be done if upgrading is not immediately possible?
Explicitly provide XMLUnit with a pre-configured TraX TransformerFactory that disables extension functions through its features and attributes. XMLUnit APIs for supplying the factory, including setFactory or setTransformerFactory, have been available since version 2.0.0.
Which version changes the unsafe default?
XMLUnit for Java 2.10.0 changes the default to disable XSLT extension functions. Users are advised to upgrade to that version.