@@ -22,22 +22,18 @@ so unless you have explicitly enabled entity expansion, no further action needs
2222
2323<example >
2424<p >
25- The following example uses the <code >libxml </code > XML parser to parse a string <code >xmlSrc </code >.
25+ The following example uses the <code >Xerces-C++ </code > XML parser to parse a string <code >data </code >.
2626If that string is from an untrusted source, this code may be vulnerable to an XXE attack, since
27- the parser is invoked with the <code >noent</code > option set to <code >true</code >:
27+ the parser is constructed in its default state with <code >setDisableDefaultEntityResolution</code >
28+ set to <code >false</code >:
2829</p >
29- <sample src =" examples/Xxe.js " />
30+ <sample src =" XXEBad.cpp " />
3031
3132<p >
32- To guard against XXE attacks, the <code >noent</code > option should be omitted or set to
33- <code >false</code >. This means that no entity expansion is undertaken at all, not even for standard
34- internal entities such as <code >& amp;</code > or <code >& gt;</code >. If desired, these
35- entities can be expanded in a separate step using utility functions provided by libraries such
36- as <a href =" http://underscorejs.org/#unescape" >underscore</a >,
37- <a href =" https://lodash.com/docs/4.17.15#unescape" >lodash</a > or
38- <a href =" https://github.com/mathiasbynens/he" >he</a >.
33+ To guard against XXE attacks, the <code >setDisableDefaultEntityResolution</code > option should be
34+ set to <code >true</code >.
3935</p >
40- <sample src =" examples/XxeGood.js " />
36+ <sample src =" XXEGood.cpp " />
4137</example >
4238
4339<references >
@@ -46,6 +42,10 @@ OWASP:
4642<a href =" https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing" >XML External Entity (XXE) Processing</a >.
4743</li >
4844<li >
45+ OWASP:
46+ <a href =" https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html" >XML External Entity Prevention Cheat Sheet</a >.
47+ </li >
48+ <li >
4949Timothy Morgen:
5050<a href =" https://research.nccgroup.com/2014/05/19/xml-schema-dtd-and-entity-attacks-a-compendium-of-known-techniques/" >XML Schema, DTD, and Entity Attacks</a >.
5151</li >
0 commit comments