Feature Request: Wildcard/pattern support in ctl:ruleRemoveTargetById (v3)
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
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
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
- Path/method exclusion: Loses protection for the entire endpoint.
- 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: Ininit(), detect theCOLLECTION:/.../pattern. If it's a regex, compile viaUtils::Regexand push to the transaction state.src/rule_with_operator.cc: IngetFinalVarsand the evaluate loop, check exclusions against regex targets usingm_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:
- Subject Length Limit: Cap the evaluated string (variable name) at 256 characters. If exceeded, skip the regex match (fail closed/evaluate the rule).
- Match Limits: Utilize
pcre2_set_match_limit()for this specific code path. - 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
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di owasp-modsecurity/ModSecurity
-
2.x Platform - IIS
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
owasp-modsecurity/ModSecurity#3623 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
2.x Platform - IIS
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
owasp-modsecurity/ModSecurity#3621 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
2.x Platform - IIS
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
owasp-modsecurity/ModSecurity#3619 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
2.x Platform - IIS
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
owasp-modsecurity/ModSecurity#3612 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
3.x
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
owasp-modsecurity/ModSecurity#3580 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di owasp-modsecurity/ModSecurity
Issue simili
-
Difficoltà 2/5 Mezza giornata Idoneità per principianti 84/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
ROCm/rocm-libraries#12703 ·
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
isl-org/Open3D#7585 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Feature request
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
qbittorrent/qBittorrent#24975 ·
I maintainer di solito rispondono entro 3 giorni