Trustwave SpiderLabs Uncovers Ov3r_Stealer Malware Spread via Phishing and Facebook Advertising. Learn More

Trustwave SpiderLabs Uncovers Ov3r_Stealer Malware Spread via Phishing and Facebook Advertising. Learn More

Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

Database Security

Prevent unauthorized access and exceed compliance requirements.

Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Microsoft Exchange Server Attacks
Stay protected against emerging threats
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats
SpiderLabs Blog

Too XXE For My Shirt

Until tonight, I'd never gotten a chance to try an xml external entity (XXE) attack. Earlier, I was updating XMLmao and XSSmh with the same interface improvements and custom blacklist features already present in SQLol. The idea, eventually, is to combine them to form a training environment whose working title is the "Magical Code Injection Rainbow" and which would continue to be free (both as in liberty and as in beer) as the individual projects are.

XMLmao has had support for XML injection attacks since its inception, but only allowed for XXE attacks since the latest version.

What most people know of XML is the basic document structure, which is just hierarchical tags like its popular cousin HTML. Lesser known are the document type definition (DTD) directives, which can be specified in-line or externally. One such directive is the ENTITY directive, which looks like this:

<!ENTITY copyright "(c) FooBar LLC 2012" >

This entity can be placed in an XML document like so:


And the XML parser will dynamically replace the content, resulting in something like this:

<foo>(c) FooBar LLC 2012</foo>

Now here's where it gets interesting: Entities can be defined using external sources. These sources are specified as URIs. If we want to include the contents of a file on the system, we can do so as follows:

<!ENTITY xxe SYSTEM "file:///var/www/mydata.xml" >

This will replace any instance of "&xxe;" with the contents of /var/www/mydata.xml. If we had control over this entity or could define our own, we could define this entity as being the contents of /etc/passwd or some other such file. We can also use HTTP URIs, which allows us to use the XML parser as a sort of proxy, retrieving data from any HTTP resource to which the system running the XML parse can reach. Internal resources which may be otherwise inaccessible may now be within reach.

It's possible to use this functionality as a jury-rigged port scanner, to discover internal content. It may even be possible to exploit internal resources, given that an exploit can be delivered through a URL. For instance:

<!ENTITY uhoh SYSTEM ";drop+table+important_things;--" >


If you'd like to try XXE attacks, go get the latest version of XMLmao.

Latest SpiderLabs Blogs

Welcome to Adventures in Cybersecurity: The Defender Series

I’m happy to say I’m done chasing Microsoft certifications (AZ104/AZ500/SC100), and as a result, I’ve had the time to put some effort into a blog series that hopefully will entertain and inform you...

Read More

Trustwave SpiderLabs: Insights and Solutions to Defend Educational Institutions Against Cyber Threats

Security teams responsible for defending educational institutions at higher education and primary school levels often find themselves facing harsh lessons from threat actors who exploit the numerous...

Read More

Breakdown of Tycoon Phishing-as-a-Service System

Just weeks after Trustwave SpiderLabs reported on the Greatness phishing-as-a-service (PaaS) framework, SpiderLabs’ Email Security team is tracking another PaaS called Tycoon Group.

Read More