Prompt
How to build an OWASP CRS rule set for a production site
Latest observation
Building an OWASP CRS (Core Rule Set) for a production site is mostly about starting with the default rules, tuning carefully, and avoiding false positives before enforcing blocking. The CRS is designed to work with engines like ModSecurity or Coraza, and the production rollout process matters as much as the rules themselves.
1) Start with the right baseline
Use the official OWASP CRS release, not a heavily modified fork.
Typical setup:
- Web server / reverse proxy: Nginx, Apache, IIS, or a WAF appliance
- WAF engine: ModSecurity v3 or compatible
- OWASP CRS: latest stable release
- TLS termination point: ideally before the WAF or on the same layer you control
2) Use a phased deployment
Do not begin in blocking mode.
Phase 1: Detection only
Set the CRS to log-only mode first:
- Review what gets flagged
- Measure false positives
- Identify legitimate application behavior that looks suspicious
In ModSecurity/CRS this is usually done by:
- Running in DetectionOnly
- Keeping audit logs enabled
- Sending logs to a SIEM or log analysis tool
Phase 2: Tune exclusions
Add exclusions for known-good traffic:
- Specific URL paths
- Specific parameters
- Specific request headers
- Specific cookies
- File upload endpoints
- API routes with unusual JSON structures
Phase 3: Gradual blocking
Once confident:
- Enable blocking for high-confidence rules
- Leave noisy areas in detection-only or with targeted exclusions
- Monitor continuously after each change
3) Use CRS configuration, not rule edits
Best practice:
- Do not edit vendor CRS rules directly
- Put your customizations in separate config files
This makes upgrades easier.
Common customization methods:
- Rule exclusions by ID
- Exclusions by tag
- Exclusions by target variable
- Per-location or per-application overrides
4) Understand anomaly scoring
CRS commonly uses anomaly scoring rather than immediate blocking.
Typical idea:
- Each suspicious rule contributes a score
- If total score exceeds a threshold, the request is blocked
Example approach:
- Start with default paranoia level and thresholds
- Raise thresholds temporarily if you have many false positives
- Lower them later as you tune the app
Key points:
- Paranoia level 1 is usually the most practical starting point
- Higher paranoia levels increase coverage but also false positives
- Separate thresholds for inbound and outbound if needed
5) Build exclusions carefully
The safest exclusions are the most specific.
Prefer:
- Excluding a single parameter on a single endpoint
- Excluding one rule for one path
Avoid:
- Disabling broad rule groups globally
- Disabling whole paranoia levels unless necessary
- Blanket exclusions for all requests
Examples of common exclusions:
- Search fields that accept special characters
- Rich-text editor inputs
- GraphQL endpoints
- JSON APIs with nested structures
- File upload routes
6) Collect production traffic and test before enforcement
Before blocking:
- Replay real traffic in staging
- Run functional tests against the WAF
- Test logins, checkout, uploads, APIs, and admin flows
- Validate mobile apps and third-party integrations
Use:
- Synthetic tests
- Regression tests
- A test user account
- Safe attack simulations to verify protection
7) Tune around your application behavior
Common false-positive sources:
- Base64-encoded payloads
- JWTs
- XML/JSON blobs
- Search or filter inputs
- Markdown or HTML content fields
- Long query strings
- Nested API parameters
- International characters / Unicode-heavy content
If your app uses these, tune the relevant rules or endpoints instead of disabling whole protections.
8) Enable logging and alerting
A production WAF needs observability.
Log:
- Rule ID
- Request path
- Matched parameter
- Anomaly score
- Client IP
- User agent
- Transaction ID
Send logs to:
- SIEM
- Centralized logging platform
- Alerting system for repeated high-severity hits
Track:
- Top blocked endpoints
- Top triggering rule IDs
- False positive rate
- Attack trends over time
9) Keep the CRS updated
OWASP CRS is actively maintained.
Operational best practices:
- Subscribe to release notes
- Test updates in staging
- Review new rules and changed defaults
- Re-run your exclusion tests after each upgrade
10) Use a secure deployment pattern
A good production pattern is:
- Deploy CRS in detection mode
- Baseline normal traffic
- Add narrow exclusions
- Enable blocking for high-confidence attacks
- Monitor and iterate
- Re-test after application changes
11) Example rollout checklist
Here’s a practical checklist:
- Install latest stable OWASP CRS
- Enable audit logging
- Run in detection-only mode
- Collect 1–2 weeks of traffic
- Identify false positives
- Add narrow exclusions
- Test critical app flows
- Enable blocking with thresholds
- Alert on repeated attacks
- Review logs weekly
- Update CRS regularly
12) Example tuning strategy
A simple strategy for a production site:
- Start with PL1
- Keep blocking off initially
- Review logs for the busiest endpoints
- Add exclusions for:
- login
- search
- uploads
- APIs
- admin dashboards
- Enable blocking only when false positives are low
- Consider PL2 only after stable operation
13) Things to avoid
- Don’t disable the whole CRS because of a few false positives
- Don’t deploy blocking mode on day one
- Don’t modify upstream rules directly
- Don’t rely on the WAF alone for security
- Don’t forget application-level validation and auth controls
14) A practical architecture note
CRS is most effective when combined with:
- Secure application coding
- Strong authentication and authorization
- Rate limiting
- Bot detection
- CSP and secure headers
- Vulnerability management
- Input validation and output encoding
If you want, I can also give you:
- a sample ModSecurity + OWASP CRS production configuration,
- a tuning/exclusion workflow, or
- a Nginx/Apache example.