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

ModSecurity 2: Explicit Normalisation Options

One of the things I realy dislike in ModSecurity 1.x is that its anti-evasion features are implicit. A series of transformations is always performed on input data and always in the same order. This is somewhat convenient because it saves you from having to think about the evasion issues. This approach - implicit normalisation - is not foolproof (no surprises there). First, there are occassions where you need some other (sometimes peculiar) transformation to take place before you look at data. Second, the context in which input data is used *is* important. It is not always appropriate to perform a particular transformation - you might even be helping the attackers avoid detection (or prevention).

That's why, when I set to design ModSecurity 2.x, I came up with a flexible solution that allows one to configure normalisation features correctly in every possible sitation. The new capabilities do not come for free: ModSecurity 2.x is a better tool but it is also more difficult to use. Enough about that, let's discuss the improvements.

There are 19 normalisation functions documented in the ModSecurity 2.x reference manual. They are:

  1. lowercase
  2. replaceNulls
  3. removeNulls
  4. compressWhitespace
  5. removeWhitespace
  6. replaceComments
  7. urlDecode
  8. urlEncode
  9. urlDecodeUni
  10. base64Encode
  11. base64Decode
  12. md5
  13. sha1
  14. hexDecode
  15. hexEncode
  16. htmlEntityDecode
  17. escapeSeqDecode
  18. normalisePath
  19. normalisePathWin

The names of most are self-explanatory. (For the others refer to the manual.) By default ModSecurity 2.x will perform lowercase, replaceNulls and compressWhitespace on input data. If you need something else you will have to reconfigure this setting using the new action "t". As before you can use SecDefaultAction to set the defaults for all rules that follow:

 SecDefaultAction log,auditlog,deny,status:403,phase:2,t:lowercase,t:replaceNulls,t:compressWhitespace

The above is an example of a default configuration. You can also have a per-rule setting, either by changing the normalisation options completely, or by adding or removing from the default configuration. Here's an example where "compressWhitespace" is removed and "replaceComments" added.

 SecRule ARGS keyword t:-compressWhitespace,t:replaceComments

To completely replace the configured normalisation functions simly use the special name "none".

 SecRule ARGS keyword t:none,t:normalisePathWin

And if the built-in normalisation functions are not enough for you there is good news - ModSecurity 2.x has an API that allows you to add a new normalisation function without having to touch its source code. (There are examples of this in the distribution.)

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