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

View File

@ -224,7 +224,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;
}
}