问题描述
我试图防止由我的应用程序处理的XML中的恶意XXE注入.因此,我使用的是XDocument而不是XmlDocument.
I'm trying to protect against malicious XXE injections in the XMLs processed by my app. Therefore I'm using XDocument instead of XmlDocument.
XML表示Web请求的有效负载,因此我在其字符串内容上调用XDocument.Parse.但是,我看到XML(& XXE)中包含的XXE引用在结果中被ENTITY xxe的实际值替换.
The XML represents the payload of a web request so I call XDocument.Parse on its string content. However, I'm seeing the XXE references contained in the XML (&XXE) being replaced in the result with the actual value of ENTITY xxe.
是否可以在不替换& xxe的情况下使用XDocument解析XML?
Is it possible to parse the XML with XDocument without replacing &xxe ?
谢谢
我设法避免使用XDocument.Load
推荐答案
使用以下示例停止解析XXE(方案和DTD).
Use the following example to stop resolving XXE (schemas and DTD).
Dim objXmlReader As System.Xml.XmlTextReader = Nothing
objXmlReader = New System.Xml.XmlTextReader(_patternFilePath)
objXmlReader.XmlResolver = Nothing
patternDocument = XDocument.Load(objXmlReader)
这篇关于XDocument.Parse:避免替换XXE引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!