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

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

HOWTO: ModSecurity Exception Handling - Updating the Rule ID Target List

Expand / Collapse

This article applies to:

  • ModSecurity


  • How can I address false positives?
  • How do I set up exception handling?


There are many methods of implementing Exception Handling in ModSecurity to address false positive alerts.  This article outlines an approach which will dynamically modify the variable TARGET listing of a rule ID without editing the SecRule directly.  This is achieved by using the ctl:ruleRemoveTargetById action.

For example, consider the following ModSecurity alert message:


[Sun Jun 30 13:45:43 2013] [error] [client] ModSecurity: Access denied with code 403 (phase 2). 
Pattern match "(^[\"'
\\xc2\\xb4\\xe2\\x80\\x99\\xe2\\x80\\x98;]+|[\\"'\xc2\xb4\xe2\x80\x99\xe2\x80\x98;]+$)" at ARGS:DocCopyList. [file "/etc/modsecurity/activated_rules/modsecurity_crs_41_sql_injection_attacks.conf"] [line "66"] 
[id "981318"][rev "2"] [msg "SQL Injection Attack: Common Injection Testing Detected"] [data "Matched Data: \xb4 found within ARGS:DocCopyList: \xd9\x8a\xd8\xb4\xd9\x8a\xd8\xb4\xd8\xb3\xd9\x8a\xd8\xb4"]
[severity "CRITICAL"] [ver "OWASP_CRS/2.2.7"] [maturity "9"] [accuracy "8"]
[tag "OWASP_TOP_10/A1"] [tag "OWASP_AppSensor/CIE1"] [tag "PCI/6.5.2"]
[hostname ""] [uri "/DMS-V2/doc_out/doc_out_new.php"] [unique_id "UdAMV8CoCzwAAHRHMhYAAAAB"]


If this alert is deemed a false positive then you need to modify the rules.  

Rather than disabling this rule globally, or for the URL, we can instead modify the TARGET list to remove inspection of the ARGS:DocCopyList parameter by adding the following new rule it to a modsecurity_crs_00_custom.conf file:

SecRule REQUEST_FILENAME "@streq /DMS-V2/doc_out/doc_out_new.php" "id:1,phase:1,t:none,nolog,pass,ctl:ruleRemoveTargetById=981318;ARGS:DocCopyList"

This rule would conditionally remove inspection of ARGS:DocCopyList for rule ID 981318 for the current transaction if the client was requesting that webpage.  Make sure that the modsecurity_crs_00_custom.conf file is activated in the web server configurations so that it is called up BEFORE the normal ModSecurity rules.


For general information about ModSecurity see the Reference Manual (one source for this manual is in the Related Links section below).

To contact Trustwave about this article or to request support:

Rate this Article:

Related Articles

Related Links

Add Your Comments

Comment submission is disabled for anonymous users.
Please send feedback to Trustwave Technical Support or the Webmaster