mkulesh / microMathematics

microMathematics Plus - Extended visual calculator
GNU General Public License v3.0
566 stars 68 forks source link

XXE in ImportFromSMathStudio.java #79

Closed prodigysml closed 5 years ago

prodigysml commented 5 years ago

The Issue

An XML External Entity attack is a type of attack against an application that parses XML input. This attack occurs when XML input containing a reference to an external entity is processed by a weakly configured XML parser. This attack may lead to the disclosure of confidential data, denial of service, server side request forgery, port scanning from the perspective of the machine where the parser is located, and other system impacts.

Where the Issue Occurred

The following code snippets display the usage of DocumentBuilderFactory without securely disabling entities:

https://github.com/mkulesh/microMathematics/blob/1b8a59e5464e37457342ffff85cf9fa506042b7d/app/src/main/java/com/mkulesh/micromath/io/ImportFromSMathStudio.java#L179

mkulesh commented 5 years ago

Dear @ProDigySML, thanks for submitting this issue. I studied https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Prevention_Cheat_Sheet and found, that only setExpandEntityReferences(false) is possible for Android DocumentBuilderFactory. All other recommendations from above mentioned link produce some exceptions. Therefore, I only added setExpandEntityReferences(false) for the DocumentBuilderFactory. I hope, the problem is solved. Are you agree with this solution?

mkulesh commented 5 years ago

Fixed and released in 2.17.3