Skip to content

ctl:ruleRemoveTargetById does not support the regex form ARGS:/.../ (SecRuleUpdateTargetById does) #717

Open

Description

@zimmerle

ctl:ruleRemoveTargetById=123;ARGS:/^id_/" should be resolved to every ARGS item that starts by id_. As listed on manual: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#args

Apparently such thing does not happens when ARGS is used with "ctl:ruleRemoveTargetById"

Activity

  1. odesk2dot2by commented on Jul 14, 2015

    @odesk2dot2by

    Very interesting, did you solved problems? I am also in such situation. It is not logical. Why this don't work?

  2. fzipi commented on Nov 8, 2016

    @fzipi
    Collaborator

    I can confirm this for other variables, e.g. REQUEST_COOKIES.

  3. davidjrh commented on Aug 22, 2017

    @davidjrh

    Having the same issue here.

  4. self-assigned this
    on Aug 22, 2017
  5. added
    2.xRelated to ModSecurity version 2.x
    waiting for v3New feature in v2 that is not yet available in v3. Therefore, not yet released.
    on Nov 14, 2018
  6. added this to the v3.0.4 milestone on Nov 14, 2018
  7. welljsjs commented on Sep 27, 2020

    @welljsjs

    Facing the same issue - is there any update on this, did this ever receive some more attention?

  8. kwaazaar commented on Nov 9, 2020

    @kwaazaar

    Not a regex, but I have this line:

    SecRuleUpdateTargetById 942100 !ARGS:Password
    

    But the request is blocked with the message:

    "Matched Data: novc found within ARGS:Password: Test123!@#"
    

    Isn't this the simplest of all rule updates? Am I misunderstanding how this is supposed to work?

  9. martinhsv commented on Nov 9, 2020

    @martinhsv
    Contributor

    Hi @kwaazaar ,

    It sounds like your use case is a duplicate of
    #2251

    That bug was fixed early in 2020 (but after v3.0.4).

    If you do not wish to update to more recent code at this time, the workaround is to use the regex equivalent:
    SecRuleUpdateTargetById "!ARGS:/Password/"

  10. fzipi commented on Oct 12, 2026

    @fzipi
    Collaborator

    Revisiting this one. Still valid in v3. ctl:ruleRemoveTargetById compares the removed target against the variable's full name with a case-insensitive exact string match (src/rule_with_operator.cc, the m_ruleRemoveTargetById lookups), so ARGS:/^id_/ never matches anything. The config-time SecRuleUpdateTargetById goes through the variable parser and does support the regex form, which is why the workaround in the thread works.

    Proposal: parse the ctl:ruleRemoveTargetById target with the same variable parser so the two directives agree.

  11. added
    3.xRelated to ModSecurity version 3.x
    on Oct 12, 2026
  12. changed the title [-]Support regular expression in ARGS selection while using ctl:ruleRemoveTargetById[/-] [+]ctl:ruleRemoveTargetById does not support the regex form ARGS:/.../ (SecRuleUpdateTargetById does)[/+] on Oct 12, 2026
  13. fzipi commented on Oct 12, 2026

    @fzipi
    Collaborator

    Duplicate of #911, which has the more recent discussion and a concrete proposal. Suggest closing this one in favour of #911.

  14. added
    duplicateOps. Somebody else already hit that bump
    needs decisionTriage done; a maintainer needs to make the final call
    on Oct 12, 2026
  15. 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

2.xRelated to ModSecurity version 2.x3.xRelated to ModSecurity version 3.xTBF by libmodsecduplicateOps. Somebody else already hit that bumpenhancementneeds decisionTriage done; a maintainer needs to make the final callpr availablewaiting for v3New feature in v2 that is not yet available in v3. Therefore, not yet released.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions