Skip to content

Commit 25e5d9b

Browse files
author
Vladimir Kotal
authored
prohibit access to external entities (#3780)
1 parent f1ffd6a commit 25e5d9b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/SubversionRepository.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.List;
3131
import java.util.logging.Level;
3232
import java.util.logging.Logger;
33+
import javax.xml.XMLConstants;
3334
import javax.xml.parsers.DocumentBuilder;
3435
import javax.xml.parsers.DocumentBuilderFactory;
3536
import javax.xml.parsers.ParserConfigurationException;
@@ -123,6 +124,10 @@ private Document getInfoDocument() {
123124
if (executor.exec() == 0) {
124125
try {
125126
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
127+
// Prohibit the use of all protocols by external entities:
128+
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
129+
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
130+
126131
DocumentBuilder builder = factory.newDocumentBuilder();
127132
document = builder.parse(executor.getOutputStream());
128133
} catch (SAXException saxe) {

0 commit comments

Comments
 (0)