CVE-2015-7326 (published 2017-06-07T14:29Z)

XML External Entity (XXE) vulnerability in Milton Webdav before 2.7.0.3.

Severity: HIGH
CVSS v2 base score: 7.5 (AV:N/AC:L/Au:N/C:P/I:P/A:P)
CVSS v3 base score: 9.8, CRITICAL (CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-611
cwe_name: Improper Restriction of XML External Entity Reference
description: 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.
extended_description: 
            XML documents optionally contain a Document Type Definition (DTD), which, among other features, enables the definition of XML entities. It is possible to define an entity by providing a substitution string in the form of a URI. The XML parser can access the contents of this URI and embed these contents back into the XML document for further processing.
            By submitting an XML file that defines an external entity with a file:// URI, an attacker can cause the processing application to read the contents of a local file. For example, a URI such as "file:///c:/winnt/win.ini" designates (in Windows) the file C:\Winnt\win.ini, or file:///etc/passwd designates the password file in Unix-based systems. Using URIs with other schemes such as http://, the attacker can force the application to make outgoing requests to servers that the attacker cannot reach directly, which can be used to bypass firewall restrictions or hide the source of attacks such as port scanning.
            Once the content of the URI is read, it is fed back into the application that is processing the XML. This application may echo back the data (e.g. in an error message), thereby exposing the file contents.
         
         

Fix information:
repo_url: https://github.com/miltonio/milton2
commit_details: repo_url: https://github.com/miltonio/milton2
author: brad
author_date: 2015-09-26 10:04:35+12:00
msg: patch XXE vulnerability
repository: repo_url: https://github.com/miltonio/milton2
repo_name: miltonio/milton2
description: Milton Java WebDAV / CalDAV / CardDAV Server Library that runs on Windows, Mac, Linux, Android and iOS.
repo_language: Java
owner: miltonio
file_changes: filename: DefaultPropFindRequestFieldParser.java
change_type: ModificationType.MODIFY
diff: @@ -53,7 +53,7 @@ public class DefaultPropFindRequestFieldParser implements PropFindRequestFieldPa
 	@Override
     public PropertiesRequest getRequestedFields( InputStream in ) {
 		final Set<QName> set = new LinkedHashSet<QName>();
-        try {            
+        try {
             ByteArrayOutputStream bout = new ByteArrayOutputStream();
             StreamUtils.readTo( in, bout, false, true );
             byte[] arr = bout.toByteArray();
@@ -61,6 +61,9 @@ public class DefaultPropFindRequestFieldParser implements PropFindRequestFieldPa
                 ByteArrayInputStream bin = new ByteArrayInputStream( arr );
                 XMLReader reader = XMLReaderFactory.createXMLReader();
 				reader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+				// https://www.owasp.org/index.php/XML_External_Entity_%28XXE%29_Processing
+				reader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+				reader.setFeature("http://xml.org/sax/features/external-general-entities", false);
                 PropFindSaxHandler handler = new PropFindSaxHandler();
                 reader.setContentHandler( handler );
                 try {
@@ -77,7 +80,7 @@ public class DefaultPropFindRequestFieldParser implements PropFindRequestFieldPa
                     log.warn( "exception parsing request body", e );
                     // ignore
                 }
-            }            
+            }
         } catch( Exception ex ) {
 			// There's a report of an exception being thrown here by IT Hit Webdav client
 			// Perhaps we can just log the error and return an empty set. Usually this

programming_language: Java
filename: DefaultPropPatchParser.java
change_type: ModificationType.MODIFY
diff: @@ -69,6 +69,10 @@ public class DefaultPropPatchParser implements PropPatchRequestParser {
             ByteArrayInputStream bin = new ByteArrayInputStream( arr );
             XMLReader reader = XMLReaderFactory.createXMLReader();
 			reader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+			// https://www.owasp.org/index.php/XML_External_Entity_%28XXE%29_Processing
+			reader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+			reader.setFeature("http://xml.org/sax/features/external-general-entities", false);
+
             PropPatchSaxHandler handler = new PropPatchSaxHandler();
             reader.setContentHandler( handler );
             reader.parse( new InputSource( bin ) );

programming_language: Java