Skip to content

Commit 434735f

Browse files
Arjen Poutsmaphilwebb
Arjen Poutsma
authored andcommitted
Fix potential security risk when using Spring OXM
Disable by default external entity resolution when using Spring OXM with jaxb. This prevents a XML entity from being able to resolve a local file on the host system. See: https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing Issue: SPR-10806 (cherry picked from commit 7576274)
1 parent 8f4221d commit 434735f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

spring-web/src/main/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ protected void writeToResult(T t, HttpHeaders headers, Result result) throws IOE
224224
* @return the created factory
225225
*/
226226
protected XMLInputFactory createXmlInputFactory() {
227-
return XMLInputFactory.newInstance();
227+
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
228+
inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);
229+
return inputFactory;
228230
}
229231

230232
}

0 commit comments

Comments
 (0)