Skip to content

Possible local text file exfiltration by XML External entity injection

Moderate
ljacomet published GHSA-mrff-q8qj-xvg8 Oct 4, 2023

Package

Gradle (Java)

Affected versions

<7.6.3, <8.4

Patched versions

7.6.3, 8.4

Description

Impact

This is a XML external entities (XXE) vulnerability. See CWE-611 and OWASP XXE.

In some cases, when Gradle parses XML files, resolving XML external entities is not disabled. Combined with an Out Of Band XXE attack (OOB-XXE), just parsing XML can lead to exfiltration of local text files to a remote server.

Gradle parses XML files for several purposes. Most of the time, Gradle parses XML files it generated or were already present locally. Only Ivy XML descriptors and Maven POM files can be fetched from remote repositories and parsed by Gradle.

Impacted use-cases in the Gradle Build Tool:

Use case Vulnerable Exploitable remotely
Ivy descriptor parsing YES YES
Maven POM parsing NO NO
Maven Toolchains discovery YES NO
Generation of Ivy and Maven metadata for publishing YES NO
Dependency Verification metadata NO NO
EAR deployment descriptor parsing YES NO
IntelliJ, Eclipse, VisualStudio, xcode file generation YES NO

In the use-cases above, only Ivy descriptor parsing is exploitable remotely. This would require an attacker to have control over an Ivy repository used by your build or be able to publish a malicious Ivy descriptor to a repository your build uses for a dependency you use.

Other use-cases are either not exploitable because existing measures protect from the XXE vulnerability or are only exploitable from local files. An attacker would need to modify your build or local build tool configuration files to exploit the XXE vulnerability.

Note that the IDE files generation related use cases only refer to using the relative Gradle plugins to generate their configuration. Project import in IntelliJ, Android Studio or Eclipse are not impacted.

Patches

In Gradle 7.6.3 and 8.4, resolving XML external entities has been disabled for all use cases to protect against this vulnerability. Gradle will now refuse to parse XML files that have XML external entities.

It is recommended that users upgrade to a patched version.

Workarounds

If you are unable to upgrade to Gradle 7.6.3 or 8.4, you can disable resolving XML external entities by setting JAXP system properties.

This can be done on the command line by adding the following:

-Djavax.xml.accessExternalDTD=false -Djavax.xml.accessExternalSchema=false -Djavax.xml.accessExternalStylesheet=false 

This can be made persistent by adding the following lines in a gradle.properties file:

systemProps.javax.xml.accessExternalDTD=false
systemProps.javax.xml.accessExternalSchema=false
systemProps.javax.xml.accessExternalStylesheet=false 

References

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
High
Privileges required
None
User interaction
Required
Scope
Unchanged
Confidentiality
High
Integrity
None
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:N

CVE ID

CVE-2023-42445

Weaknesses

Improper Restriction of XML External Entity Reference

The product processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output. Learn more on MITRE.