Skip to content

Commit 1e6184b

Browse files
committed
Fix meta-actions not being applied in the chain starter rule if multiMatch is enabled
Fixes #2867.
1 parent 5b709d9 commit 1e6184b

File tree

2 files changed

+99
-1
lines changed

2 files changed

+99
-1
lines changed

Diff for: 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
}

Diff for: test/test-cases/regression/auditlog.json

+98
Original file line numberDiff line numberDiff line change
@@ -318,5 +318,103 @@
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\" SecRule REQUEST_METHOD \"@streq GET\" \"t:none\"",
362+
"SecAuditEngine RelevantOnly",
363+
"SecAuditLogParts ABCFHZ",
364+
"SecAuditLog /tmp/test/modsec_audit_multimatch_3.log",
365+
"SecAuditLogDirMode 0766",
366+
"SecAuditLogFileMode 0666",
367+
"SecAuditLogType Serial",
368+
"SecAuditLogRelevantStatus \"^(?:5|4(?!04))\""
369+
]
370+
},
371+
{
372+
"enabled": 1,
373+
"version_min": 300000,
374+
"version_max": 0,
375+
"title": "auditlog : rule chain, multiMatch data, match only after intermediate transform",
376+
"client": {
377+
"ip": "200.249.12.31",
378+
"port": 2313
379+
},
380+
"server": {
381+
"ip": "200.249.12.31",
382+
"port": 80
383+
},
384+
"request": {
385+
"headers": {
386+
"Host": "www.modsecurity.org",
387+
"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)",
388+
"Accept": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,*\/*;q=0.8",
389+
"Accept-Language": "en-us,en;q=0.5",
390+
"Accept-Encoding": "gzip,deflate",
391+
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
392+
"Keep-Alive": "300",
393+
"Connection": "keep-alive",
394+
"Pragma": "no-cache",
395+
"Cache-Control": "no-cache"
396+
},
397+
"uri": "\/test.pl?param1=test&param2=%20tEst2",
398+
"method": "GET",
399+
"http_version": 1.1,
400+
"body": ""
401+
},
402+
"expected": {
403+
"audit_log": "\\[msg \"testmsg\"\\] \\[data \"testdata\"\\] \\[severity \"7\"\\] \\[ver \"\"\\] \\[maturity \"0\"\\] \\[accuracy \"0\"\\] \\[tag \"testtag1\"\\] \\[tag \"testtag2\"\\]",
404+
"error_log": "",
405+
"http_code": 403
406+
},
407+
"rules": [
408+
"SecRuleEngine On",
409+
"SecDefaultAction \"phase:1,nolog,auditlog,deny,status:403\"",
410+
"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\" SecRule REQUEST_METHOD \"@streq GET\" \"t:none\"",
411+
"SecAuditEngine RelevantOnly",
412+
"SecAuditLogParts ABCFHZ",
413+
"SecAuditLog /tmp/test/modsec_audit_multimatch_4.log",
414+
"SecAuditLogDirMode 0766",
415+
"SecAuditLogFileMode 0666",
416+
"SecAuditLogType Serial",
417+
"SecAuditLogRelevantStatus \"^(?:5|4(?!04))\""
418+
]
321419
}
322420
]

0 commit comments

Comments
 (0)