Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 Oracle and/or its affiliates.
* Copyright (c) 2020, 2025, Oracle and/or its affiliates.
*
* Licensed under the Universal Permissive License v 1.0 as shown at
* http://oss.oracle.com/licenses/upl.
Expand Down Expand Up @@ -104,6 +104,11 @@ public void populateSchema(Schema schema)
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);

// prevent XXE (XML External Entity) attacks
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);

DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(m_inputXml);
Element root = doc.getDocumentElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,20 @@ protected static Parser getParser()
ClassHelper.invoke(factory,
"setValidating", new Object[] {Boolean.FALSE});

// prevent XXE (XML External Entity) attacks
// factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
ClassHelper.invoke(factory,
"setFeature", new Object[] {
"http://xml.org/sax/features/external-general-entities", Boolean.FALSE});
// factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
ClassHelper.invoke(factory,
"setFeature", new Object[] {
"http://xml.org/sax/features/external-parameter-entities", Boolean.FALSE});
// factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
ClassHelper.invoke(factory,
"setFeature", new Object[] {
"http://apache.org/xml/features/nonvalidating/load-external-dtd", Boolean.FALSE});

// parser = factory.newSAXParser().getParser();
Object SAXParser = ClassHelper.invoke(factory,
"newSAXParser", ClassHelper.VOID);
Expand Down