<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=PeterPichler</id>
		<title>OWASP - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=PeterPichler"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/PeterPichler"/>
		<updated>2026-05-27T09:11:59Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:XML_External_Entity_(XXE)_Processing&amp;diff=189038</id>
		<title>Talk:XML External Entity (XXE) Processing</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:XML_External_Entity_(XXE)_Processing&amp;diff=189038"/>
				<updated>2015-02-04T16:40:54Z</updated>
		
		<summary type="html">&lt;p&gt;PeterPichler: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== XXE Prevention in Java / Using an own EntiyResolver Implementation? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Context: We write Java Software, used in quite different environment (div. Operating System, OpenJDK, IBM-JDK, Sun-JDK, JDK 6 - JDK8). I am not really happy with the described solution to prevent External Entity Injection, because it is depending on some special XML parser Implementations.&lt;br /&gt;
&lt;br /&gt;
To prevent External Entity Injection flaws we primarily use our own EntityResolver and we think this alone should be enough to ensure that the parser can not access resources via URL´s from SGML Entity Declarations.&lt;br /&gt;
&lt;br /&gt;
Our Entity Resolver looks like:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;pre&amp;gt;public class SecureEntityResolver implements EntityResolver {&lt;br /&gt;
&lt;br /&gt;
	@Override&lt;br /&gt;
	public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {&lt;br /&gt;
		return new InputSource(new ByteArrayInputStream(&amp;quot;&amp;quot;.getBytes()));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
When parsing XML we register our Entity-Resolver&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;DocumentBuilderFactory newFactory = DocumentBuilderFactory.newInstance();&lt;br /&gt;
newFactory.setNamespaceAware(true);&lt;br /&gt;
&lt;br /&gt;
DocumentBuilder builder = newFactory.newDocumentBuilder();&lt;br /&gt;
builder.setEntityResolver(new SecureEntityResolver()); /* !!!! */&lt;br /&gt;
&lt;br /&gt;
Document doc = builder.parse(...);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Does anyone see problems with this way to prevent XXE Injection attacks?&lt;br /&gt;
--[[User:PeterPichler|PeterPichler]] ([[User talk:PeterPichler|talk]]) 10:40, 4 February 2015 (CST)&lt;br /&gt;
&lt;br /&gt;
: I like your approach in general because it gets away from the silliness of each processor. Have you ran different test cases to see what happens? Even better, could you enable the Java security manager and grant only file access to the test case? I'm interested in seeing if a network connection is attempted during the resolution. --[[User:Jon Passki|Jon Passki]] ([[User talk:Jon Passki|talk]])&lt;br /&gt;
&lt;br /&gt;
:: I do not have the resources to make extensive tests currently. We had an white box security review of our software, and our security review partner (SecConsult) found an XXE Entity Injection Flaw. We was able to reproduce it... When using our own EntityResolver, it was not possible any more to access local resources. With this entity resolver we passed the recheck (by the company detected the XXE bug). This summer we will have a recheck again. I will stress this topic again during recertification... and try to bring back infos to this page. --[[User:PeterPichler|PeterPichler]] ([[User talk:PeterPichler|talk]]) 10:40, 4 February 2015 (CST)&lt;/div&gt;</summary>
		<author><name>PeterPichler</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:XML_External_Entity_(XXE)_Processing&amp;diff=189033</id>
		<title>Talk:XML External Entity (XXE) Processing</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:XML_External_Entity_(XXE)_Processing&amp;diff=189033"/>
				<updated>2015-02-04T15:19:35Z</updated>
		
		<summary type="html">&lt;p&gt;PeterPichler: Removed non functional code&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== XXE Prevention in Java / Using an own EntiyResolver Implementation? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Context: We write Java Software, used in quite different environment (div. Operating System, OpenJDK, IBM-JDK, Sun-JDK, JDK 6 - JDK8). I am not really happy with the described solution to prevent External Entity Injection, because it is depending on some special XML parser Implementations.&lt;br /&gt;
&lt;br /&gt;
To prevent External Entity Injection flaws we primarily use our own EntityResolver and we think this alone should be enough to ensure that the parser can not access resources via URL´s from SGML Entity Declarations.&lt;br /&gt;
&lt;br /&gt;
Our Entity Resolver looks like:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;pre&amp;gt;public class SecureEntityResolver implements EntityResolver {&lt;br /&gt;
&lt;br /&gt;
	@Override&lt;br /&gt;
	public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {&lt;br /&gt;
		return new InputSource(new ByteArrayInputStream(&amp;quot;&amp;quot;.getBytes()));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
When parsing XML we register our Entity-Resolver&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;DocumentBuilderFactory newFactory = DocumentBuilderFactory.newInstance();&lt;br /&gt;
newFactory.setNamespaceAware(true);&lt;br /&gt;
&lt;br /&gt;
DocumentBuilder builder = newFactory.newDocumentBuilder();&lt;br /&gt;
builder.setEntityResolver(new SecureEntityResolver()); /* !!!! */&lt;br /&gt;
&lt;br /&gt;
Document doc = builder.parse(...);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Does anyone see problems with this way to prevent XXE Injection attacks?&lt;br /&gt;
: I like your approach in general because it gets away from the silliness of each processor. Have you ran different test cases to see what happens? Even better, could you enable the Java security manager and grant only file access to the test case? I'm interested in seeing if a network connection is attempted during the resolution. --[[User:Jon Passki|Jon Passki]] ([[User talk:Jon Passki|talk]])&lt;/div&gt;</summary>
		<author><name>PeterPichler</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:XML_External_Entity_(XXE)_Processing&amp;diff=189031</id>
		<title>Talk:XML External Entity (XXE) Processing</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:XML_External_Entity_(XXE)_Processing&amp;diff=189031"/>
				<updated>2015-02-04T15:08:26Z</updated>
		
		<summary type="html">&lt;p&gt;PeterPichler: XXE Injection / Java / Using special EntityResolver&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== XXE Prevention in Java / Using an own EntiyResolver Implementation? ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Context: We write Java Software, used in quite different environment (div. Operating System, OpenJDK, IBM-JDK, Sun-JDK, JDK 6 - JDK8). I am not really happy with the described solution to prevent External Entity Injection, because it is depending on some special XML parser Implementations.&lt;br /&gt;
&lt;br /&gt;
To prevent External Entity Injection flaws we primarily use our own EntityResolver and we think this alone should be enough to ensure that the parser can not access resources via URL´s from SGML Entity Declarations.&lt;br /&gt;
&lt;br /&gt;
Our Entity Resolver looks like:&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&amp;lt;pre&amp;gt;public class SecureEntityResolver implements EntityResolver {&lt;br /&gt;
	List&amp;lt;String&amp;gt; allowedSystemIds = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;
&lt;br /&gt;
	@Override&lt;br /&gt;
	public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {&lt;br /&gt;
		if(allowedSystemIds.contains(systemId)) {&lt;br /&gt;
			// return a special input source&lt;br /&gt;
			return new InputSource(new ByteArrayInputStream(systemId.getBytes()));&lt;br /&gt;
		}&lt;br /&gt;
		return new InputSource(new ByteArrayInputStream(&amp;quot;&amp;quot;.getBytes()));&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	public void addAllowedSystemIds(List&amp;lt;String&amp;gt; allowedSystemIds) {&lt;br /&gt;
		this.allowedSystemIds = allowedSystemIds;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
When parsing XML we register our Entity-Resolver&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;DocumentBuilderFactory newFactory = DocumentBuilderFactory.newInstance();&lt;br /&gt;
newFactory.setNamespaceAware(true);&lt;br /&gt;
&lt;br /&gt;
DocumentBuilder builder = newFactory.newDocumentBuilder();&lt;br /&gt;
builder.setEntityResolver(new SecureEntityResolver()); /* !!!! */&lt;br /&gt;
&lt;br /&gt;
Document doc = builder.parse(...);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Does anyone see problems with this way to prevent XXE Injection attacks?&lt;/div&gt;</summary>
		<author><name>PeterPichler</name></author>	</entry>

	</feed>