Skip to content
Permalink
Browse files Browse the repository at this point in the history
TMDM-15304 [CVE] - Fix XXE Vulnerabilities In MDM (#1598)
  • Loading branch information
hw-zhu committed Jul 27, 2022
1 parent 43f3d6b commit 95590db
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Expand Up @@ -80,6 +80,7 @@ public static Element getRootElement(String elementName, String namespace, Strin
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setExpandEntityReferences(false);
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
DocumentBuilder builder = factory.newDocumentBuilder();
DOMImplementation impl = builder.getDOMImplementation();
Document namespaceHolder = impl.createDocument(namespace,(prefix==null?"":prefix+":")+elementName, null);
Expand Down
Expand Up @@ -24,6 +24,7 @@
import java.util.Set;

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -75,7 +76,12 @@ public class SystemStorageWrapper extends StorageWrapper {
private static final Logger LOGGER = LogManager.getLogger(SystemStorageWrapper.class);

public SystemStorageWrapper() {
DOCUMENT_BUILDER_FACTORY.setNamespaceAware(true);
try {
DOCUMENT_BUILDER_FACTORY.setNamespaceAware(true);
DOCUMENT_BUILDER_FACTORY.setFeature(MDMXMLUtils.FEATURE_DISALLOW_DOCTYPE, true);
} catch (ParserConfigurationException e) {
throw new RuntimeException("Unable to initialize document builder.", e);
}
// Create "system" storage
StorageAdmin admin = getStorageAdmin();
if (!admin.exist(StorageAdmin.SYSTEM_STORAGE, StorageType.SYSTEM)) {
Expand Down

0 comments on commit 95590db

Please sign in to comment.