3

I have a Debian Jessie box, Apache 2.4 and default mod_security enabled with base rules activated. When I try to implement a Google reCAPTCHA solution in a PHP code, modsecurity blocks page with returning reCAPTCHA variables. As I see, a modsecurity SQL injection protection rule blocks my site with reCAPTCHA. Is there a simple way to make modsecurity base SQL injection rule let Google reCAPTCHA work fine? Can I somehow exclude/whitelist a variable from modsecurity rules to check?

Relevant Apache error log entry:

[Thu May 05 20:31:17.407153 2016] [:error] [pid 3604] [client 199.67.203.142] ModSecurity: Access denied with code 403 (phase 2). Pattern match "(?i:(\\\\!\\\\=|\\\\&\\\\&|\\\\|\\\\||>>|<<|>=|<=|<>|<=>|xor|rlike
|regexp|isnull)|(?:not\\\\s+between\\\\s+0\\\\s+and)|(?:is\\\\s+null)|(like\\\\s+null)|(?:(?:^|\\\\W)in[+\\\\s]*\\\\([\\\\s\\\\d\\"]+[^()]*\\\\))|(?:xor|<>|rlike(?:\\\\s+binary)?)|(?:regexp\\\\s+binary))" at ARG
S:g-recaptcha-response. [file "/usr/share/modsecurity-crs/activated_rules/modsecurity_crs_41_sql_injection_attacks.conf"] [line "70"] [id "981319"] [rev "2"] [msg "SQL Injection Attack: SQL Operator Detected"] [
data "Matched Data: XOr found within ARGS:g-recaptcha-response: 03AHJ_VuuKzOoRV1ncHa31GhztRb7FuB6sFfWtJqRbgw71veDabEm-V1Xkm4Rfh2hsjodBH7Y_S1D0XomTniOoLr9hNKKXlcxAestey_bIW8pZUSHF9N5PGOGagrbdeliSOnCe3Ff-qRRsvrBAh
8lw19hGfOlYMwdYkONJNaiq5KQgELQQxqa9suxdKLscNLvmRBsrJaZc8NNxtZBYMgcuf7_MR0fJRdItiXFs-ttqxvnCUUCWH8bbnXdbfoFBaeuH2j-JHxpNnbTLz6NCVZHSMMFzJ_45GgYUajzeLBmn8u74qdOgIQDRRUSDc4ySnAxozESwb94_RY4o7FhpQu3ebytd2mGcmHPte-cn
MH2VSmsOLCQOVXKvytwC2w8c3JRiFCYTdpMJ0TrDSwlw5b9P4uOhjENJJRRDxRhaUnRktOb0KBJdaevwjYzFJVXVmfuTv..."] [hostname "mzhostname.com"] [uri "/test/test2_load.php"] [unique_id "VyuRdcM4N88AAA4U-PgAAAAB"]

1 Answer 1

2

Add the following to your Apache config after you load the /usr/share/modsecurity-crs/activated_rules/modsecurity_crs_41_sql_injection_attacks.conf file:

SecRuleUpdateTargetById 981319 !ARGS:'g-recaptcha-response'

Note you may need to whitelist this argument from other rules similarly.

2
  • Thanks, works like a charm. Is there a simple way to whitelist this argument from all rules?
    – JackD
    May 5, 2016 at 20:37
  • Sadly no - you need to do it rule by rule :-( May 5, 2016 at 21:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .