Skip to content

Commit 12add9a

Browse files
committed
Fix meta-actions not being applied if multiMatch is enabled in the chain starter rule
Meta-actions can only be used in non-chained rules or in the chain starter rule of a rule chain. The m_chainedRuleParent member of the RuleWithActions class is NULL only if the rule is not chained or if it is the chain starter rule of a rule chain. Fixes #2867.
1 parent 5b709d9 commit 12add9a

File tree

2 files changed

+101
-1
lines changed

2 files changed

+101
-1
lines changed

src/rule_with_actions.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void RuleWithActions::executeActionsIndependentOfChainedRuleResult(Transaction *
219219
}
220220
}
221221

222-
if (m_containsMultiMatchAction && !m_isChained) {
222+
if (m_containsMultiMatchAction && m_chainedRuleParent == nullptr) {
223223
if (m_severity) {
224224
m_severity->evaluate(this, trans, ruleMessage);
225225
}

test/test-cases/regression/auditlog.json

+100
Original file line numberDiff line numberDiff line change
@@ -318,5 +318,105 @@
318318
"SecAuditLogType Serial",
319319
"SecAuditLogRelevantStatus \"^(?:5|4(?!04))\""
320320
]
321+
},
322+
{
323+
"enabled": 1,
324+
"version_min": 300000,
325+
"version_max": 0,
326+
"title": "auditlog : rule chain, multiMatch data, match after last transform",
327+
"client": {
328+
"ip": "200.249.12.31",
329+
"port": 2313
330+
},
331+
"server": {
332+
"ip": "200.249.12.31",
333+
"port": 80
334+
},
335+
"request": {
336+
"headers": {
337+
"Host": "www.modsecurity.org",
338+
"User-Agent": "Mozilla\/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko\/20091102 Firefox\/3.5.5 (.NET CLR 3.5.30729)",
339+
"Accept": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,*\/*;q=0.8",
340+
"Accept-Language": "en-us,en;q=0.5",
341+
"Accept-Encoding": "gzip,deflate",
342+
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
343+
"Keep-Alive": "300",
344+
"Connection": "keep-alive",
345+
"Pragma": "no-cache",
346+
"Cache-Control": "no-cache"
347+
},
348+
"uri": "\/test.pl?param1=test&param2=tEst2",
349+
"method": "GET",
350+
"http_version": 1.1,
351+
"body": ""
352+
},
353+
"expected": {
354+
"audit_log": "\\[msg \"testmsg\"\\] \\[data \"testdata\"\\] \\[severity \"7\"\\] \\[ver \"\"\\] \\[maturity \"0\"\\] \\[accuracy \"0\"\\] \\[tag \"testtag1\"\\] \\[tag \"testtag2\"\\]",
355+
"error_log": "",
356+
"http_code": 403
357+
},
358+
"rules": [
359+
"SecRuleEngine On",
360+
"SecDefaultAction \"phase:1,nolog,auditlog,deny,status:403\"",
361+
"SecRule ARGS \"@contains test2\" \"id:1559,phase:1,multiMatch,block,log,t:none,t:urlDecode,t:lowercase,msg:'testmsg',logdata:'testdata',severity:'DEBUG',tag:'testtag1',tag:'testtag2',chain\"",
362+
"SecRule REQUEST_METHOD \"@streq GET\" \"t:none\"",
363+
"SecAuditEngine RelevantOnly",
364+
"SecAuditLogParts ABCFHZ",
365+
"SecAuditLog /tmp/test/modsec_audit_multimatch_3.log",
366+
"SecAuditLogDirMode 0766",
367+
"SecAuditLogFileMode 0666",
368+
"SecAuditLogType Serial",
369+
"SecAuditLogRelevantStatus \"^(?:5|4(?!04))\""
370+
]
371+
},
372+
{
373+
"enabled": 1,
374+
"version_min": 300000,
375+
"version_max": 0,
376+
"title": "auditlog : rule chain, multiMatch data, match only after intermediate transform",
377+
"client": {
378+
"ip": "200.249.12.31",
379+
"port": 2313
380+
},
381+
"server": {
382+
"ip": "200.249.12.31",
383+
"port": 80
384+
},
385+
"request": {
386+
"headers": {
387+
"Host": "www.modsecurity.org",
388+
"User-Agent": "Mozilla\/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko\/20091102 Firefox\/3.5.5 (.NET CLR 3.5.30729)",
389+
"Accept": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,*\/*;q=0.8",
390+
"Accept-Language": "en-us,en;q=0.5",
391+
"Accept-Encoding": "gzip,deflate",
392+
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
393+
"Keep-Alive": "300",
394+
"Connection": "keep-alive",
395+
"Pragma": "no-cache",
396+
"Cache-Control": "no-cache"
397+
},
398+
"uri": "\/test.pl?param1=test&param2=%20tEst2",
399+
"method": "GET",
400+
"http_version": 1.1,
401+
"body": ""
402+
},
403+
"expected": {
404+
"audit_log": "\\[msg \"testmsg\"\\] \\[data \"testdata\"\\] \\[severity \"7\"\\] \\[ver \"\"\\] \\[maturity \"0\"\\] \\[accuracy \"0\"\\] \\[tag \"testtag1\"\\] \\[tag \"testtag2\"\\]",
405+
"error_log": "",
406+
"http_code": 403
407+
},
408+
"rules": [
409+
"SecRuleEngine On",
410+
"SecDefaultAction \"phase:1,nolog,auditlog,deny,status:403\"",
411+
"SecRule ARGS \"@streq tEst2\" \"id:1560,phase:1,multiMatch,block,log,t:none,t:trim,t:lowercase,msg:'testmsg',logdata:'testdata',severity:'DEBUG',tag:'testtag1',tag:'testtag2',chain\"",
412+
"SecRule REQUEST_METHOD \"@streq GET\" \"t:none\"",
413+
"SecAuditEngine RelevantOnly",
414+
"SecAuditLogParts ABCFHZ",
415+
"SecAuditLog /tmp/test/modsec_audit_multimatch_4.log",
416+
"SecAuditLogDirMode 0766",
417+
"SecAuditLogFileMode 0666",
418+
"SecAuditLogType Serial",
419+
"SecAuditLogRelevantStatus \"^(?:5|4(?!04))\""
420+
]
321421
}
322422
]

0 commit comments

Comments
 (0)