CodeQL False Positive? java/xxe with javax.xml.transform.Transformer
- 主要语言
- CodeQL
- 星标
- 10.1k
- 派生
- 2.1k
- 平均合并
- 2 天 15 小时
- 30 天内合并 PR
- 141
描述
CodeQL reports a "Resolving XML external entity in user-controlled data" alert for the following Java code. This appears to be a false positive.
Could the query be enhanced to recognise the following fixes applied to the javax.xml.transform.Transformer instance?
```import javax.xml.transform.*;
...
TransformerFactory factory = TransformerFactory.newInstance();
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); // fixes the vulnerability
factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, ""); // fixes the vulnerability
Transformer transformer = factory.newTransformer();
transformer.transform(source, result); /// wrongly (?) reports a java/xxe vulnerability
return result.getNode();
```
Also the following should/could be recognised as a fix?
```
...
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); // fixes the vulnerability where supported
Transformer transformer = factory.newTransformer();
```
CodeQL version: 2.7.6
See also: https://github.com/github/codeql/issues/7607
贡献指南
评估
这个 Issue 还没有评估数据。