HP fortify 在以下代码中向我展示了 XML 外部实体注入:
StringBuilder sb = new StringBuilder();
StringWriter stringWriter = new StringWriter(sb);
xmlSerializer.Serialize(stringWriter, o);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(stringWriter.ToString()); //bad code
result = xmlDoc.ChildNodes[1].OuterXml;
在上面它显示了以下行中的漏洞xmlDoc.LoadXml(stringWriter.ToString());
我该如何解决这种情况?