Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Feature Request: Wildcard/pattern support in ctl:ruleRemoveTargetById (v3)

Aperta
#3,505 7 commenti 2 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
cpp
Ambito
security

Direzione di ricerca

Inizia leggendo src/actions/ctl/rule_remove_target_by_id.cc e src/rule_with_operator.cc, concentrandoti su init(), getFinalVars e sul ciclo di valutazione. Verifica come viene usato Utils::Regex e come lo stato della transazione memorizza le esclusioni. Il lavoro è completato quando i target letterali continuano a funzionare, i pattern validi corrispondono ai nomi delle variabili a runtime, le espressioni regolari non valide falliscono durante la configurazione e i limiti di ReDoS indicati sono affrontati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

3.x

Hi team! This is my first ask/contribution to ModSecurity. I'm hoping to help improve false positive management for folks using CRS — please let me know if I can clarify anything or adjust this proposal.

Is your feature request related to a problem? Please describe.

Currently, ctl:ruleRemoveTargetById only allows excluding a Core Rule Set (CRS) rule from inspecting a literal, exact variable name (e.g., ARGS:json.JobDescription). It does not support wildcards or regular expressions.

This creates a significant pain point for modern APIs accepting JSON arrays or GraphQL payloads, where keys are dynamic:

  • Payload: [{"JobDescription": "..."}, {"JobDescription": "..."}, ...]
  • Variables: ARGS:json.0.JobDescription, ARGS:json.1.JobDescription, …

Excluding these requires listing every possible index, which is impractical and leads to users disabling rules entirely or losing protection for the whole endpoint via path exclusions.

Note: This request is related to the legacy v2 PR #3121 and Issue #911, but focuses specifically on a v3 implementation.

Describe the solution you'd like

Extend ctl:ruleRemoveTargetById to accept a pattern (regex) that matches variable names, mirroring the existing regex support in SecRuleUpdateTargetById, but enabling runtime/URI-scoped use.

Example Syntax:

SecRule REQUEST_URI "@beginsWith /api/jobs" \
    "id:100100,phase:1,pass,nolog,ctl:ruleRemoveTargetById=932125;ARGS:/^json\.\d+\.JobDescription$/"

Expected Behavior: When the target rule inspects variables, any variable whose name matches the compiled pattern is excluded. Literal targets must continue to work unchanged. Invalid regex should fail at config load.

Describe alternatives you've considered

  1. Path/method exclusion: Loses protection for the entire endpoint.
  2. SecRuleUpdateTargetById: Applies globally at configure-time, which is risky if other endpoints share the same JSON structure.

Technical Feasibility & Security Considerations (v3)

The change is feasible in v3 with localized edits, as the engine already utilizes Utils::Regex (PCRE2) for variable matching.

  • src/actions/ctl/rule_remove_target_by_id.cc: In init(), detect the COLLECTION:/.../ pattern. If it's a regex, compile via Utils::Regex and push to the transaction state.
  • src/rule_with_operator.cc: In getFinalVars and the evaluate loop, check exclusions against regex targets using m_regex->searchAll(varName).size() > 0.

ReDoS Mitigations Risks:
Because the variable name (e.g., JSON key) is user-controlled, strict limits are required to prevent ReDoS via the ctl evaluation:

  1. Subject Length Limit: Cap the evaluated string (variable name) at 256 characters. If exceeded, skip the regex match (fail closed/evaluate the rule).
  2. Match Limits: Utilize pcre2_set_match_limit() for this specific code path.
  3. Compile-time validation: Reject known ReDoS patterns at config load.
Lingua principale
C++
Stelle
9.8k
Fork
1.8k
Merge medio
2h 46m
PR unite (30g)
1

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di owasp-modsecurity/ModSecurity

Tutte le issue di owasp-modsecurity/ModSecurity

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.