Skip to content
This page was generated and translated with the assistance of AI. If you spot any inaccuracies, feel free to help improve it. Edit on GitHub

Rule Engine

PRX-WAF uses a declarative, YAML-based rule engine to detect and block web attacks. Rules describe what to inspect, how to match, and what action to take. The engine evaluates every incoming request against all enabled rules across 16 sequential detection phases.

How Rules Work

Each rule consists of four key components:

  1. Field -- Which part of the request to inspect (path, query, body, headers, etc.)
  2. Operator -- How to match the value (regex, contains, detect_sqli, etc.)
  3. Value -- The pattern or threshold to match against
  4. Action -- What to do when the rule matches (block, log, allow)
yaml
- id: "CUSTOM-001"
  name: "Block admin path from external IPs"
  category: "access-control"
  severity: "high"
  field: "path"
  operator: "regex"
  value: "(?i)^/admin"
  action: "block"

Rule Sources

PRX-WAF ships with 398 rules across four categories:

SourceFilesRulesDescription
OWASP CRS21310OWASP ModSecurity Core Rule Set v4 (converted to YAML)
ModSecurity446Community rules for IP reputation, DoS, data leakage
CVE Patches739Targeted virtual patches for Log4Shell, Spring4Shell, MOVEit, etc.
Custom13Example templates for application-specific rules

Additionally, PRX-WAF includes 10+ built-in detection checkers compiled into the binary:

  • SQL injection (libinjection + regex)
  • Cross-site scripting (libinjection + regex)
  • Remote code execution / command injection
  • Local/remote file inclusion
  • Server-side request forgery (SSRF)
  • Path/directory traversal
  • Scanner detection (Nmap, Nikto, etc.)
  • Bot detection (malicious bots, AI crawlers, headless browsers)
  • Protocol violation detection
  • Sensitive word detection (Aho-Corasick multi-pattern matching)

Rule Formats

PRX-WAF supports three rule file formats:

FormatExtensionDescription
YAML.yaml, .ymlNative PRX-WAF format (recommended)
ModSecurity.confSecRule directives (basic subset: ARGS, REQUEST_HEADERS, REQUEST_URI, REQUEST_BODY)
JSON.jsonJSON array of rule objects

See YAML Syntax for the complete schema reference.

Paranoia Levels

Each rule declares a paranoia level (1-4) that controls how aggressively it matches. Higher levels catch more attacks but increase false positive risk.

LevelNameDescriptionFalse Positive Risk
1DefaultHigh-confidence rules, production-safeVery low
2RecommendedBroader coverage, minor FP riskLow
3AggressiveExtensive heuristics, requires tuningModerate
4MaximumEverything, including speculative patternsHigh

TIP

Start with paranoia level 1 in production. Monitor logs, tune exclusions, then gradually enable higher levels.

Hot-Reload

PRX-WAF watches the rules/ directory for file changes and automatically reloads rules when a file is created, modified, or deleted. Changes take effect within the configured debounce window (default: 500ms).

You can also trigger a reload manually:

bash
# Via CLI
prx-waf rules reload

# Via SIGHUP (Unix only)
kill -HUP $(pgrep prx-waf)

Rule reloads are atomic -- the old rule set continues to serve traffic until the new set is fully compiled and ready.

Directory Layout

rules/
├── owasp-crs/          # OWASP CRS v4 (21 files, 310 rules)
│   ├── sqli.yaml       # SQL injection (CRS 942xxx)
│   ├── xss.yaml        # Cross-site scripting (CRS 941xxx)
│   ├── rce.yaml        # Remote code execution (CRS 932xxx)
│   └── ...
├── modsecurity/        # ModSecurity community rules
├── cve-patches/        # CVE virtual patches (Log4Shell, Spring4Shell, etc.)
├── custom/             # Your application-specific rules
└── tools/              # Rule validation and sync utilities

Next Steps

Released under the Apache-2.0 License.