LOW 4.0

CVE-2024-31573

XMLUnit for Java has Insecure Defaults when Processing XSLT Stylesheets

Description

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 ReportJAXP Security Guide

Affected Maven artifacts (1)

ArtifactAffected versionsFixed in
org.xmlunit » xmlunit-core
< 2.10.0
2.10.0

Blast radius

1affected artifacts
29affected versions
5,874dependent artifacts (est.)
198,700dependent versions

64% of the dependent artifacts (3,812) still pull an affected version in their latest release.

DepthDependent versions
Direct
7,939
2 hops
53,828
3 hops
66,726
4 hops
38,076
5 hops
16,331
6 hops
15,800

Most used dependents

Computed from the dependency graph of build 20261124.0621 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.