Skip to content

Commit 7576274

Browse files
Arjen Poutsmaphilwebb
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
1 parent 28be8e9 commit 7576274

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
@@ -226,7 +226,9 @@ protected void writeToResult(T t, HttpHeaders headers, Result result) throws IOE
226226
* @return the created factory
227227
*/
228228
protected XMLInputFactory createXmlInputFactory() {
229-
return XMLInputFactory.newInstance();
229+
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
230+
inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);
231+
return inputFactory;
230232
}
231233

232234
}

0 commit comments

Comments
 (0)