Trustwave's 2024 Retail Report Series Highlights Alarming E-Commerce Threats and Growing Fraud Against Retailers. Learn More

Trustwave's 2024 Retail Report Series Highlights Alarming E-Commerce Threats and Growing Fraud Against Retailers. Learn More

Services
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.

Solutions
BY TOPIC
Microsoft Security
Unlock the full power of Microsoft Security
Offensive Security
Solutions to maximize your security ROI
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

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.

ABOUT TRUSTWAVE

Trustwave is a globally recognized cybersecurity leader that reduces cyber risk and fortifies organizations against disruptive and damaging cyber threats. Our comprehensive offensive and defensive cybersecurity portfolio detects what others cannot, responds with greater speed and effectiveness, optimizes client investment, and improves security resilience. Learn more about us.

Latest Intelligence

Discover how our specialists can tailor a security program to fit the needs of
your organization.

Request a Demo