ruleRemoveTargetById, ruleRemoveTargetByTag: Nginx + modsecurity-nginx connector unexpected behaviour
Hi, I'm using the latest v3/master with nginx and the ModSecurity-nginx connector. I'm trying to fix a false positive in a few cookies by removing the rule 942450 from REQUEST_COOKIES:
ctl:ruleRemoveTargetById=942450;REQUEST_COOKIES
but nothing happens. I've tried the same with apache2 + ModSecurity and it works well.
The same behaviour with ctl:ruleRemoveTargetByTag
I've placed some debug messages in rule.cc and I've seen that line 488: if (args == *key) will never be true if I use ctl:ruleRemoveTargetById=942450;REQUEST_COOKIES because *key values are allways like REQUEST_COOKIES:cookie_name and args has the value REQUEST_COOKIES (from ctl:ruleRemoveTargetById).
My debug logs
[9] TESTING_DEBUG -> KEY: REQUEST_COOKIES:cookie_name1 ARGS -> REQUEST_COOKIES
[9] TESTING_DEBUG -> KEY: REQUEST_COOKIES:cookie_name2 ARGS -> REQUEST_COOKIES
[9] TESTING_DEBUG -> KEY: REQUEST_COOKIES:cookie_name3 ARGS -> REQUEST_COOKIES
[9] TESTING_DEBUG -> KEY: REQUEST_COOKIES:cookie_name4 ARGS -> REQUEST_COOKIES
[9] TESTING_DEBUG -> KEY: REQUEST_COOKIES:cookie_name5 ARGS -> REQUEST_COOKIES
rule.cc
for (auto &i : trans->m_ruleRemoveTargetById) {
int id = i.first;
std::string args = i.second;
if (m_ruleId != id) {
continue;
}
trans->debug(9, "TESTING_DEBUG -> KEY: " + *key + " ARGS -> " + args);
if (args == *key) {
trans->debug(9, "Variable: " + *key +
" was excluded by ruleRemoteTargetById...");
ignoreVariable = true;
break;
}
}
Any hints?
Hi @averges,
Thank you for the bug report. Fixed at: 337216fd871c2e4321153a4b0885fdc64170073a