fix(lexer): rejection of '@' in ctl:ruleRemoveTarget actions (#3565)#3589
Merged
airween merged 13 commits intoJun 28, 2026
Merged
Conversation
…mic delimiter lookup and updating regex scanner pattern
…curity into Jitterx69/fix/issue-3565-ctl-removerule-xpath
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes SecLang lexing/parsing for ctl:ruleRemove* actions so targets containing XPath-relevant characters (notably @) are accepted, and expands regression coverage to validate both the corrected behavior and improved parser error reporting.
Changes:
- Expands the Flex
REMOVE_RULE_BYmacro to allow@,=,(,), and'inctl:ruleRemove*action payloads. - Makes
ctlaction initializers parse payloads by locating=instead of using hardcoded offsets, improving robustness and error messages. - Adds regression tests for both valid cases (special characters in variable targets) and invalid syntax cases (ensuring parser errors are correctly reported).
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/test-cases/regression/action-ctl_rule_remove_target_by_tag.json | Adds regression cases for syntax validation and for @, =, (, ), ' in ruleRemoveTargetByTag targets. |
| test/test-cases/regression/action-ctl_rule_remove_target_by_id.json | Adds regression cases for syntax validation and for @, =, (, ), ' in ruleRemoveTargetById targets. |
| test/test-cases/regression/action-ctl_rule_remove_by_tag.json | Adds a regression case ensuring malformed ctl:ruleRemoveByTag syntax is rejected with the expected parser error. |
| test/test-cases/regression/action-ctl_rule_remove_by_id.json | Adds a regression case ensuring malformed ctl:ruleRemoveById syntax is rejected with the expected parser error. |
| src/parser/seclang-scanner.ll | Updates the lexer character class used for ctl:ruleRemove* tokens so @ and related XPath characters are accepted. |
| src/actions/ctl/rule_remove_target_by_tag.cc | Switches payload parsing to split on = and improves invalid TAG;VARIABLE error formatting. |
| src/actions/ctl/rule_remove_target_by_id.cc | Switches payload parsing to split on = and improves invalid ID;VARIABLE error formatting. |
| src/actions/ctl/rule_remove_by_tag.cc | Switches payload parsing to split on = and adds a defensive error for missing =. |
| src/actions/ctl/rule_remove_by_id.cc | Switches payload parsing to split on = and adds a defensive error for missing =. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
This was referenced Jul 1, 2026
Merged
EsadCetiner
pushed a commit
to EsadCetiner/coreruleset
that referenced
this pull request
Jul 3, 2026
…coreruleset#4690) main ships XML attribute inspection (XML://@*) unconditionally, with no ctl:ruleRemoveTargetByTag/ById opt-out gate and no '@' character in any ctl:ruleRemoveTarget* target anywhere in the ruleset. The libmodsecurity 3.0.16 requirement from owasp-modsecurity/ModSecurity#3589 (lexer rejecting '@' in ctl:ruleRemoveTarget* actions) only applies to the LTS branches, which implement this feature behind a runtime opt-in/opt-out gate using that exact ctl syntax. main has no such gate, so the note doesn't reflect what actually shipped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



what
This is the modified version of #3566.
why
There I asked the author to add tests the excellent parser error checking in the code. I also asked him to fix Copilot suggestions.
This PR based on his one, but added these changes. I kept him commits.
references
#3566 is the original PR.