Why it matters
A document can declare external entities that read local files or exhaust memory.
How to fix it
Keep DtdProcessing at Prohibit (the default) or Ignore.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
using System.IO;
using System.Xml;
public static class Feed
{
public static XmlReader Open(Stream s)
{
var settings = new XmlReaderSettings();
settings.DtdProcessing = DtdProcessing.Parse;
return XmlReader.Create(s, settings);
}
}using System.IO;
using System.Xml;
public static class Feed
{
public static XmlReader Open(Stream s)
{
var settings = new XmlReaderSettings();
settings.DtdProcessing = DtdProcessing.Prohibit;
return XmlReader.Create(s, settings);
}
}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
- XXE XML resolver (C#)
C#Severity: High
trustivan-csharp-xxe-xml-resolver - Weak hash (C#)
C#Severity: Medium
trustivan-csharp-weak-hash - Json type name handling (C#)
C#Severity: High
trustivan-csharp-json-type-name-handling - Weak cipher (C#)
C#Severity: High
trustivan-csharp-weak-cipher - BinaryFormatter use (C#)
C#Severity: High
trustivan-csharp-binaryformatter-use - ECB mode (C#)
C#Severity: High
trustivan-csharp-ecb-mode
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