Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7553621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:06:38+00:00 2026-05-30T11:06:38+00:00

I am using mod_security 2.6.3, and I would like to be able to execute

  • 0

I am using mod_security 2.6.3, and I would like to be able to execute a shell script based on a rule-severity level. I am using the core rule set (CRS), which sets the severity level to 2 (for ‘critical’) when an attack is detected.

I would like to execute my script whenever the severity is high enough.

I tried to use the SecDefaultAction setting, such as:

SecDefaultAction "phase:2,log,deny,status:403,exec:/path/to/my/script"

But since the ‘exec’ action is a “non-disruptive” one, it always get executed, whether a critical rule or a non-critical rule is trigerred.

I could go through each critical SecRule and add “exec” next to it, but that would be tedious (and repetitive, and ugly).

I thought I could do something like:

SecRule ENV:SEVERITY "@lt 4" "exec:/path/to/my/script"

But somehow it never gets executed, probably because the critical rules have a block or deny statement which stops rule processing (since considered disruptive).

I also tried using the CRS anomaly score feature, like this:

SecRule TX:ANOMALY_SCORE "@ge 4" "exec:/path/to/my/script"

But it still does not get processed.
Any idea on how I could do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:06:40+00:00Added an answer on May 30, 2026 at 11:06 am

    You could use the HIGHEST_SEVERITY variable to test it, such as:

    SecRule HIGHEST_SEVERITY "@le 5" "nolog,pass,exec:/path/to/your/script"
    

    Note the nolog,pass additional parameters that will preserve the original log message from the rule that changed the severity level.

    Also, I suggest that you place this condition early in your .conf file (e.g. just after your SecDefaultAction line) to ensure it gets included in all contexts.

    Another way of doing it would be to use a custom HTTP response status code in your SecDefaultAction (for instance, 418 “I’m a teapot”) and trigger your condition based on it, in the logging phase (once the default action has been processed):

    # On error, log then deny request with "418 I'm a teapot":
    SecDefaultAction "phase:2,log,deny,status:418"
    
    # On HTTP response status code 418, execute your script:
    SecRule RESPONSE_STATUS "^418$" "phase:5,nolog,pass,exec:/path/to/your/script"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using mod_security with the latest core rules. It triggers on all my pages
I am using mod_rewrite to put a category name in the URL, like locahost/categoryName
Using mod_rewrite I'd (ideally) like to capture a spacific ID from a URL in
Using mod_rewrite, what RewriteRule(s) would make the following two examples function properly? Example #1
I'm having difficulty with a php script using copy() on a shared remote host.
I'm using mod_rewrite to redirect on URLs like: mysite.com/123 RewriteEngine On RewriteRule ^([0-9]+)$ /n/index.php?id=$1
I am using mod_perl for my web application. Currently, I plan to use a
I am using mod-wsgi with django, and in django I use pylucene to do
I'm using Mod Rewrite for IIS 7.0 from iis.net and want to redirect requests:
I'm using mod_rewrite to map my old directory structure to a new one. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.