Skip to content

ctl:ruleRemoveTargetByTag does not support regex in ModSecurity v3.x #2432

Open

Description

@martinhsv

Issue #588 was raised against ModSecurity v2.9.x. In those versions ctl:ruleRemoveTargetByTag does support regular expressions, but the raised issue noted that some regex metacharacters cause difficulties.

This new issue is being created to separately track the different state of affairs in v3.x.

In particular, ctl:ruleRemoveTargetByTag works correctly when specifying regular text. It does not, however, have any support at all for regex.

This appears to have been intentional in the initial implementation of the v3.x code, so any regex functionality implemented for ctl:ruleRemoveTargetByTag now may be considered an enhancement rather a bug fix.

It's unclear how widely useful regular expressions are for this particular ctl action, but this issue at least allows the matter to be considered for 3.1 (or later) implementation.

Activity

  1. self-assigned this
    on Oct 22, 2020
  2. added this to the v3.1.0 milestone on Oct 22, 2020
  3. theMiddleBlue commented on Aug 9, 2023

    @theMiddleBlue

    Rule exclusion on API that usually has JSON body it's a pain on v3 without this feature.

    A nested JSON body is hard to exclude. Something like:

    {
       "foo": [
          {"bar": "1"},
          {"bar": "1 or 1=1--"}
          ...
       ]
    }

    It makes a lot of users remove the whole ruleset or turn off the request body access instead of removing a long, long list of:

    ARGS:json.foo.array_0.bar
    ARGS:json.foo.array_1.bar
    etc...

  4. fardarter commented on Mar 1, 2024

    @fardarter

    I would also like this feature

  5. fzipi commented on Oct 12, 2026

    @fzipi
    Collaborator

    Revisiting this one. Same mechanism as #911: in 3.x the ctl:ruleRemoveTargetByTag target is compared with the variable's full name by exact string equality (src/rule_with_operator.cc, the m_ruleRemoveTargetByTag lookups), so ARGS:/^json\.foo\./ can never match. The fix proposed on #911, parsing the ctl target with the same variable parser SecRuleUpdateTargetById uses, covers ById and ByTag at once.

    Suggest tracking both under #911 and closing this one as a duplicate once that lands.

  6. added
    duplicateOps. Somebody else already hit that bump
    needs decisionTriage done; a maintainer needs to make the final call
    on Oct 12, 2026
  7. fzipi commented on Oct 12, 2026

    @fzipi
    Collaborator

    Follow-up: open PR #3526 implements regex targets for ctl:ruleRemoveTargetById and ctl:ruleRemoveTargetByTag in 3.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.xRelated to ModSecurity version 3.xduplicateOps. Somebody else already hit that bumpenhancementneeds decisionTriage done; a maintainer needs to make the final callpr available

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions