@@ -22,22 +22,18 @@ so unless you have explicitly enabled entity expansion, no further action needs
22
22
23
23
<example >
24
24
<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 >.
26
26
If 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 >:
28
29
</p >
29
- <sample src =" examples/Xxe.js " />
30
+ <sample src =" XXEBad.cpp " />
30
31
31
32
<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 >.
39
35
</p >
40
- <sample src =" examples/XxeGood.js " />
36
+ <sample src =" XXEGood.cpp " />
41
37
</example >
42
38
43
39
<references >
@@ -46,6 +42,10 @@ OWASP:
46
42
<a href =" https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Processing" >XML External Entity (XXE) Processing</a >.
47
43
</li >
48
44
<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 >
49
49
Timothy Morgen:
50
50
<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 >.
51
51
</li >
0 commit comments