Skip to content
Open
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
6 changes: 6 additions & 0 deletions java/com/google/copybara/xml/XmlModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ public Object compile(String xmlContent, String expression, String type)
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
try {
// Prevent XML External Entity (XXE) processing: reject DTDs (which also
// disables entity resolution) and external entities, since the parsed XML
// content may come from an untrusted source (e.g. a migrated repository).
builderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
builderFactory.setXIncludeAware(false);
builderFactory.setExpandEntityReferences(false);
builder = builderFactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
throw new RuntimeException("Error creating document builder for parsing XML");
Expand Down
Loading