aizu-m opened a new pull request, #165:
URL: https://github.com/apache/poi-xmlbeans/pull/165

   Reproducer, Apache Xerces 2.12.2 on the classpath:
   
       String xml = "<!DOCTYPE r [<!ENTITY x SYSTEM 
'file:///tmp/secret.txt'>]><r>&x;</r>";
       LoadSaveUtils.xmlText2GenericDom(in, DocumentHelper.createDocument())
           .getDocumentElement().getTextContent();
       // before: "SECRET-FILE-CONTENTS\n"
       // after:  ""
   
   Found while checking which parse paths skip SAXHelper.newXMLReader and 
DocumentHelper. This is the only one.
   
   Observations:
   - `SAXParser.parse(is, handler)` makes Sax2Dom, a DefaultHandler, the entity 
resolver. It resolves nothing, so the parser fetches the entity itself.
   - With the JDK parser, FEATURE_SECURE_PROCESSING blocks the read through 
accessExternalDTD and the call throws a SAXParseException instead. With Apache 
Xerces 2.12.2 nothing blocks it.
   - `XmlObject.Factory.parse` on the same input returns `<r/>`.
   - No XmlBeans entity expansion limit was applied either: Xerces default 
100,000 against the XmlOptions default of 2,048.
   
   The fix builds the reader with `SAXHelper.newXMLReader(new XmlOptions())`, 
as Locale does. Sax2Dom stays the content, error and lexical handler, so 
documents without external entities give the same DOM. Nothing inside XmlBeans 
calls this method. It is a public helper, so removing it would also work if you 
prefer that.
   
   LoadSaveUtilsTest fails on trunk and passes with the fix. The full test 
suite passes (3269 tests).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to