[GHSA-fj2m-w3wv-x9pr] Apache Calcite before 1.32.0 vulnerable to potential XML External Entity (XXE) attack#8687
Open
levpachmanov wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updates
Comments
Summary
CVE-2022-39135 is an XML External Entity (XXE) vulnerability in Apache Calcite. A crafted SQL query can read local files (and reach internal network resources) through four SQL operators that parse XML without disabling Document Type Declarations / external entity resolution:
EXISTS_NODEEXTRACT_XMLXML_TRANSFORMEXTRACT_VALUEAll four are implemented in the class
org.apache.calcite.runtime.XmlFunctions. The fix (1.32.0) hardens that class to use a secureDocumentBuilderFactory/TransformerFactorywith DTDs and external entities disabled.Why 1.19.0 is not affected
The vulnerable code did not exist when 1.19.0 was released. The class
XmlFunctions.java— which contains all four affected operators — was added to Calcite'smainbranch ~9 months after 1.19.0 shipped, and first appeared in a release in 1.22.0.calcite-1.19.0XmlFunctions.javaintroduced1ddc1c3a0c61— [CALCITE-3552] MySQLExtractValueThe vulnerable class was created ~9 months after 1.19.0 was released, so 1.19.0 has no XML-parsing attack surface. This is consistent with NVD's affected range of 1.22.0 → 1.31.x (1.22.0 being the first release that shipped the class). 1.19.0 is therefore not applicable.
Source code references
XmlFunctions.javais absent):https://github.com/apache/calcite/tree/calcite-1.19.0/core/src/main/java/org/apache/calcite/runtime
https://github.com/apache/calcite/blob/calcite-1.22.0/core/src/main/java/org/apache/calcite/runtime/XmlFunctions.java
https://github.com/apache/calcite/blob/calcite-1.31.0/core/src/main/java/org/apache/calcite/runtime/XmlFunctions.java
https://github.com/apache/calcite/blob/calcite-1.32.0/core/src/main/java/org/apache/calcite/runtime/XmlFunctions.java
Fixing commit
ba80b9156afc0db26b194d97a031fcc0dc7f4c03— "[CALCITE-5263] Improve XmlFunctions by using an XML DocumentBuilder"
Vulnerability databases
1.22.0→1.31.x(i.e.[1.22.0, 1.32.0))[1.22.0, 1.32.0)< 1.32.0(no lower bound)