Description
Describe the bug
A seclang_parser used for loading rules in ModSecurity uses global variables.
Due to that I was able to create a simple test proving that loading rules by different rule sets at the same time with multiple threads causes some random issues
https://github.com/SpiderLabs/ModSecurity/pull/2535/files
Logs and dumps
For trying to load the same rule SecAction "id:900000,phase:1,pass,nolog,setvar:tx.paranoia_level=1"
multiple times I get different errors:
Examples:
'Rules error. File: <>. Line: 1. Column: 88. Expecting an action, got: SecAction "id:900000,phase:1,pass,nolog,setvar:tx.paranoia_level=1"'
'Rules error. File: <>. Line: 1. Column: 27. syntax error, unexpected Phase '
'Rules error. File: <>. Line: 1. Column: 1. syntax error, unexpected "," '
To Reproduce
Steps to reproduce the behavior:
Download the branch from my forked repository: https://github.com/iosetek/ModSecurity/tree/load_rule_multiple_threads
Build the project, enter test
directory and run ./unit_tests
The example output looks like this:
Executing thread tests.
Test: 'Test 1 thread' succeeded.
Test: 'Test 3 overlapping load rule threads' failed.
thread [0] returned: ''
thread [1] returned: 'Rules error. File: <<reference missing or not informed>>. Line: 1. Column: 88. Expecting an action, got: SecAction "id:900000,phase:1,pass,nolog,setvar:tx.paranoia_level=1"'
thread [2] returned: ''
Test: 'Test 3 non overlapping load rule threads (delay between)' succeeded.
Expected behavior
The expected behaviour is for loading rules to be thread safe so the failing test from my fork would work.