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
This commit is contained in:
Arjen Poutsma 2013-08-06 15:04:09 -07:00 committed by Phillip Webb
parent 28be8e9063
commit 7576274874
1 changed files with 3 additions and 1 deletions

View File

@ -226,7 +226,9 @@ public class Jaxb2CollectionHttpMessageConverter<T extends Collection>
* @return the created factory
*/
protected XMLInputFactory createXmlInputFactory() {
return XMLInputFactory.newInstance();
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, false);
return inputFactory;
}
}