← Java / Spring 목차

JAVA-030 / 고급

XML 외부 엔티티(XXE) 허용

A05:2021 Security Misconfiguration · CWE-611 XXE

왜 문제가 될까요?

file:///etc/passwd 읽기, SSRF.

이렇게 수정하세요

java
DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
f.setFeature("https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html", true);
f.setFeature("https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html", false);
f.setFeature("https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html", false);
f.setXIncludeAware(false); f.setExpandEntityReferences(false);

더 읽기