CVE-2024-3400: PAN-OS Command Injection Vulnerability in GlobalProtect Gateway. Learn More

CVE-2024-3400: PAN-OS Command Injection Vulnerability in GlobalProtect Gateway. 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.

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

CVE-2014-0050: Exploit with Boundaries, Loops without Boundaries

In this article I will discuss CVE-2014-0050: Apache Commons FileUpload and Apache Tomcat Denial-of-Service in detail. The article reviews the vulnerability's technical aspects in depth and includes recommendations that can help administrators defend from future exploitation of this security issue.

How do we know about this vulnerability?

About five days ago, Mark Thomas, a Project Management Committee Member and Committer in the Apache Tomcat project, sent an email about the accidentally leaked vulnerability (CVE-2014-0050) which allows attackers to take down your Tomcat-deployed web sites and web services. "This issue was reported responsibly to the Apache Software Foundation via JPCERT but an error in addressing an e-mail led to the unintended early disclosure of this issue," Thomas said in his email.

An hour prior to sending the email, Thomas populated the Apache Commons FileUpload project SVN with code fixes. The most significant difference I detected was in the "MultipartStream" class code of the package:


The fixed code has an extra "if" condition (line number 330) that validates the length of the multipart boundary to be shorter than 4091 characters, raising an exception if that's not the case. The calculation is as follows:

boundary.length > bufSize – 1 – BOUNDARY_PREFIX.length = 4096 – 1 – 4 = 4091

Note: parts of the code were copied into the org.apache.tomcat.util.http.fileupload package in Apache Tomcat, causing it to be affected.

What is Multipart?

Multipart is often used in HTTP for the purpose of uploading files (more details can be found in RFC 2046). When your application needs to send a file to the server that has binary data, or data that might interfere with the structure of the HTTP message, it is possible to use a multipart content-type and setup a magic line to separate between values. This magic line is the boundary value and should be random enough that it doesn't appear in the actual content sent.

Note the complexity of the boundary value in the following example of a file upload request generated by Google Chrome. Such complexity reduces the chances of the boundary appearing in the binary blob of the file being uploaded, so the different parts of the message can be easily detected even by the human eye:


Creating the exploit

So let's get Apache Tomcat installed and try to send more than 4091 characters in the boundary field to the Apache Tomcat Manager application. Such a request might look like this:


I submitted the above request four times (one for each CPU) and this was the result:


The Tomcat process reached 100 percent CPU usage, and remained at levels higher than 95 percent CPU until I stopped the service.

Why is this happening?

When you are writing loops, check your boundaries. When you are writing endless loops, check your boundaries even more carefully.

While parsing the multipart message, the following "for" loop is used by the MultipartStream class:


The innocent-looking "for" loop above is an endless loop. It is "family related" to the famous "while(true)" loop. The developer's intention was to exit this loop either by raising an exception (line 1003) or by returning a value (line 1014), unfortunately when the boundary is longer than 4091 characters (as explained earlier) and the body is longer than 4096 characters (so it can potentially contain the boundary), neither would ever occur.

The Irony

I have to say a few words about the Irony. We can safely say that this bug is all about a field read from the request which the programmer failed to validate its permitted boundaries. However, the field's name is Boundary.

How to tell if you are vulnerable?

1) You are using Apache Tomcat 7.0-7.0.50 or 8.0-8.0.1 and your code utilizes Servlet 3.0 specifications (for example, "request.getPart" or "request.getParts" methods)

2) You are using Apache Commons FileUpload < 1.3.1

To be honest, these libraries are so commonly used that you might not even know that your site is vulnerable.

I wrote a small Ruby proof-of-concept exploit to help administrators try and recreate the Denial-of-Service state on QA and staging environments. This can help administrators and developers understand if a certain URL is vulnerable to the attack (but needs to be tested on all URLs).

The tool can also assist white-hat security professionals that are required to confirm the vulnerability throughout an engagement.

Download CVE-2014-0050


Defend yourself

Trustwave Spiderlabs research team recommends taking the following actions:

A) Once available, update your software to one of the following versions:

    1. Apache Commons FileUpload 1.3.1
    2. Apache Tomcat 7.0.51
    3. Apache Tomcat 8.0.2

B) You may choose to apply the appropriate patch:

  1. Apache Commons FileUpload:
  2. Apache Tomcat 8:
  3. Apache Tomcat 7:


ModSecurity Commercial Rule Set

The ModSecurity commercial rule set was updated and protects against the attack.



It is possible to add the following user defined rule in block mode to detect and mitigate the attack:

SecRule REQUEST_HEADERS:Content-Type "@rx .{4000}"

For more information on how to create user-defined rules, please refer to

Note: Due to the low chances of a false detection (false positive) and the simplicity of the exploit, we highly recommend setting this rule to BLOCK and disabling simulation mode for this rule if you are concerned about Denial-of-Service (and suspect that your site is using one of the affected technologies).

Latest SpiderLabs Blogs

EDR – The Multi-Tool of Security Defenses

This is Part 8 in my ongoing project to cover 30 cybersecurity topics in 30 weekly blog posts. The full series can be found here.

Read More

The Invisible Battleground: Essentials of EASM

Know your enemy – inside and out. External Attack Surface Management tools are an effective way to understand externally facing threats and help plan cyber defenses accordingly. Let’s discuss what...

Read More

Fake Dialog Boxes to Make Malware More Convincing

Let’s explore how SpiderLabs created and incorporated user prompts, specifically Windows dialog boxes into its malware loader to make it more convincing to phishing targets during a Red Team...

Read More