我们在我们的 asp.net asmx 网络服务中发现了一个 XML 外部实体漏洞。
我们正在使用 burp 套件测试 asp.net .asmx 网络服务,以检查 XML 外部实体处理漏洞。看: https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html#net
我们看到,当 DTD 包含在请求中时,如下所示:
<!DOCTYPE soapenv:envelope PUBLIC "-//B/A/EN" "http://1234565.cigitalcollaborator.com">
DNS 请求被发送到 cigitalcollaborator.com。这表明 asmx 网络服务正在处理请求中的 DTD。
我们使用的是 .net 版本 4.5.2。
根据此链接,.net 4.5.2 及更高版本应隐式阻止 XXE 漏洞: https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Prevention_Cheat_Sheet#.NET_4.5.2_and_later
但这不是...我们进行 DNS 查找。
底层 .net 框架正在处理这个 asmx 网络服务的 XML 反序列化/序列化,因此我们没有代码可以真正修复这里。我们不能正确地改变行为,因为它在底层框架中的某个地方?
我们如何为我们的 ASMX 网络服务修复这个 XXE 漏洞?
谢谢
乔恩·鲍
最佳答案
我认为在这里考虑两点很重要:
首先 - 设计用于使用各种不同技术的 Web 应用程序的自动扫描并不能证明存在漏洞。 DNS 查找与完全处理相关实体不同。如果对有问题的 url 发出后续请求,并且处理了来自该 url 的数据,然后你就有了漏洞。您可以使用 Fiddler 等代理配置您的应用程序来验证是否发出了此类请求。
其次,.NET 自 4.5.2 以来一直是安全的默认。这与保证安全不同。如果应用程序需要 DTD 处理,可以在设置中启用它:
var xmlReaderSettings = new XmlReaderSettings();
xmlReaderSettings.DtdProcessing = DtdProcessing.Parse;
var xmlReader = XmlReader.Create(new StringReader("EvilXml", xmlReaderSettings));
或者
var xmlTextReader = new XmlTextReader(new StringReader("EvilXml");
xmlTextReader..DtdProcessing = DtdProcessing.Parse;
并使用 XDocument 解析器实现流程 DTD
var xmlDocument = new XmlDocument();
// Implementations of XmlResolver are probably unsafe
xmlDocument.XmlResolver = new MyCustomResolver();
// xmlDocument.XmlResolver = null is safe - should be the default from 4.5.2
xmlDocument.LoadXml("EvilXml");
我可能会在源代码中搜索两个相关的文本字符串 "DtdProcessing.Parse"
和 "XmlResolver"
以排除这种情况。
关于c# - asp.net .asmx web 服务 ishow XXE 漏洞 - 外部 DNS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51428514/