Home > Ask the Software Quality Experts > Application Security Questions & Answers > XML security: Preventing XML bombs
Ask The Software Quality Expert: Questions & Answers
EMAIL THIS

XML security: Preventing XML bombs

Rami Jaamour EXPERT RESPONSE FROM: Rami Jaamour

Pose a Question
Other Software Quality Categories
Meet all Software Quality Experts
Become an Expert for this site


Software quality news and advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


>
QUESTION POSED ON: 22 February 2006
What is an XML bomb and how do I protect my Web service against it?

>
EXPERT RESPONSE
An XML bomb is a dangerous XML message that can be crafted by a malicious user. It could be sent by a service consumer (a client) as a request message to a Web service provider (a server) in order to cause a denial-of-service DoS attack. An XML bomb exploits Document Type Definition (DTD) processing functionality in XML parsers -- the software that parses an XML message -- by causing them to process an exponentially growing amount of data. A DoS attack could certainly be mounted by sending a message that is large in size to the service if the service is not configured to reject such messages. However, an XML bomb is actually a small XML message that is created in a way that makes the XML content grow only as it gets processed by the XML parser. Here is an example of an XML bomb:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE SOAP-ENV:Envelope [
  <!ELEMENT SOAP-ENV:Envelope ANY>
  <!ATTLIST SOAP-ENV:Envelope entityReference CDATA #IMPLIED>
  <!ENTITY x0 "foo">
  <!ENTITY x1 "&x0;&x0;" >
  <!ENTITY x2 "&x1;&x1;" >
  ...
  <!ENTITY x98 "&x97;&x97;" >
  <!ENTITY x99 "&x98;&x98;" >
] >
<SOAP:Envelope entityReference="&x99;" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
 <SOAP:Body>
  <keyword xmlns="urn:parasoft:ws:store">foo</keyword>
 </SOAP:Body>
</SOAP:Envelope>
When a Web service receives such a message, and if the XML parser has DTD processing enabled, then it will cause the server to expand the entity reference x99;. This reference is defined in the DTD section which comes with the message (highlighted in red) to be equal to &x98; repeated twice, which is in turn defined as &x97; repeated twice and so on all the way to x0. In other words:

x0 = "foo"
x1 = "foofoo"
x2 = "foofoofoofoo"
…
x99 = "foofoofoofoofoo…foo" or "foo" repeated
      299 = 633825300114114700748351602688
As the service expands the value of x, the size of the string containing the concatenated words "foo" reaches exponential levels, which causes it to quickly consume the server memory that is allocated to the application. Such exhaustion of the server resources causes a DoS, as other legitimate requests would not be processed while the server is busy concatenating useless "foo" strings.

To protect against such attacks, be sure to either use known commercial or open-source SOAP stacks that disallows DTDs, such as Apache Axis, or that ship as part of application server frameworks, such as .NET, WebLogic, WebSphere, etc. You can also disable DTD parsing in your XML parser. Certainly, adopting standards-based packages is often more secure than implementing things on your own.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Application Security
Top tools for testing Web application security
How to prevent HTTP response splitting
PCI DSS compliance: WAF, code review or both?
Application security careers have bright future
How to prevent anti-DNS pinning attacks
Open source application security testing tools
Java application security features and measures
Web application security testing basics
Password recovery with .NET 2.O using C#
Free load and performance testing tools

Software security testing and techniques
Recipe for successful Web application security testing
Software quality needs to be a continuous process
Cloud computing's effect on application security
Web Security Testing Cookbook sample recipe
Ajax website security: Don't trust the client
PCI compliance falls short of assuring website security
Be aware of SOA application security issues
Browser security a concern for website development
Static analysis at the end of the SDLC doesn't work
Website security improved, but more can be done

Web services security
Web security: Web services an overlooked entry point for attacks
Why are Web services more vulnerable than Web apps?
Ajax's effect on Web services security

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Software Quality - Software Maintenance, Software Requirements, Software Standards
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2006 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts