Why it matters
A document can then read local files or make the server send requests (XXE).
How to fix it
Set XmlResolver = null on XmlDocument and XmlReaderSettings (the default on .NET Core and on .NET Framework 4.5.2 and later).
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
using System.Xml;
public static class Feed
{
public static XmlDocument Parse(string xml)
{
var doc = new XmlDocument();
doc.XmlResolver = new XmlUrlResolver();
doc.LoadXml(xml);
return doc;
}
}using System.Xml;
public static class Feed
{
public static XmlDocument Parse(string xml)
{
var doc = new XmlDocument();
doc.XmlResolver = null;
doc.LoadXml(xml);
return doc;
}
}What TrustIvan reads
Runs on repository scans of C# source once static analysis is turned on (SAST_RULES and the separately built analyzer image); it is off by default.
Weakness classes and references
Related checks
- Json type name handling (C#)
C#Severity: High
trustivan-csharp-json-type-name-handling - XXE DTD processing (C#)
C#Severity: High
trustivan-csharp-xxe-dtd-processing - BinaryFormatter use (C#)
C#Severity: High
trustivan-csharp-binaryformatter-use - Weak hash (C#)
C#Severity: Medium
trustivan-csharp-weak-hash - SQL string concatenation (C#)
C#Severity: Medium
trustivan-csharp-sql-string-concatenation - Weak cipher (C#)
C#Severity: High
trustivan-csharp-weak-cipher
Terms: SAST (static application security testing), Taint analysis, CWE (Common Weakness Enumeration), OWASP Top 10
All static analysis (SAST) checks · The whole catalogue · How this works in TrustIvan · Documentation