Trustwave Unveils New Offerings to Maximize Value of Microsoft Security Investments. Learn More

Trustwave Unveils New Offerings to Maximize Value of Microsoft Security Investments. Learn More

Services
Capture
Managed Detection & Response

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

twi-managed-portal-color
Co-Managed SOC (SIEM)

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

twi-briefcase-color-svg
Advisory & Diagnostics

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

tw-laptop-data
Penetration Testing

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

twi-database-color-svg
Database Security

Prevent unauthorized access and exceed compliance requirements.

twi-email-color-svg
Email Security

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

tw-officer
Digital Forensics & Incident Response

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

tw-network
Firewall & Technology Management

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

Solutions
BY TOPIC
Offensive Security
Solutions to maximize your security ROI
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
Partners
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:

<foo>&copyright;</foo>

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 "http://10.1.1.152/foo.php?id=1;drop+table+important_things;--" >

Ouch.

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

Latest SpiderLabs Blogs

Clockwork Blue: Automating Security Defenses with SOAR and AI

It’s impractical to operate security operations alone, using manual human processes. Finding opportunities to automate SecOps is an underlying foundation of Zero Trust and an essential architecture...

Read More

Professional Services Sector Under Attack - Trustwave SpiderLabs Report 2024

Recent research by Trustwave SpiderLabs, detailed in their newly published report "2024 Professional Services Threat Landscape: Trustwave Threat Intelligence Briefing and Mitigation Strategies,"...

Read More

Atlas Oil: The Consequences of a Ransomware Attack

Overview Atlas Oil, a major player in the oil and fuel distribution industry, fell victim to a ransomware attack orchestrated by the Black Basta group. This attack not only compromised sensitive...

Read More