Skip to content

Commit 39debf9

Browse files
dvorarogawskiydnath
authored andcommitted
Add OWASP recommended xxe protections
1 parent e466f27 commit 39debf9

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

  • src/main/java/net/juniper/netconf

src/main/java/net/juniper/netconf/XML.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
package net.juniper.netconf;
1010

1111
import com.google.common.base.Preconditions;
12+
13+
import javax.xml.XMLConstants;
14+
1215
import org.w3c.dom.Document;
1316
import org.w3c.dom.Element;
1417
import org.w3c.dom.Node;
@@ -504,6 +507,8 @@ public String toString() {
504507
String str;
505508
try {
506509
TransformerFactory transFactory = TransformerFactory.newInstance();
510+
transFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD,"");
511+
transFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET,"");
507512
Transformer transformer = transFactory.newTransformer();
508513
StringWriter buffer = new StringWriter();
509514
transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC,"yes");

0 commit comments

Comments
 (0)