Skip to content

Commit 1559f3a

Browse files
Fix code scanning alert no. 6: Resolving XML external entity in user-controlled data
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 45953df commit 1559f3a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/org/apache/ibatis/parsing/XPathParser.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,13 +231,16 @@ private Document createDocument(InputSource inputSource) {
231231
try {
232232
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
233233
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
234+
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
235+
factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
236+
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
234237
factory.setValidating(validation);
235238

236239
factory.setNamespaceAware(false);
237240
factory.setIgnoringComments(true);
238241
factory.setIgnoringElementContentWhitespace(false);
239242
factory.setCoalescing(false);
240-
factory.setExpandEntityReferences(true);
243+
factory.setExpandEntityReferences(false);
241244

242245
DocumentBuilder builder = factory.newDocumentBuilder();
243246
builder.setEntityResolver(entityResolver);

0 commit comments

Comments
 (0)