feat(security): Integrate ModSecurity WAF with OWASP CRS - #381
Merged
Conversation
Add a defense-in-depth Web Application Firewall layer in front of the Node.js API using nginx + ModSecurity + OWASP Core Rule Set (CRS v3/v4) in anomaly scoring mode. - nginx.conf: Reverse proxy with per-endpoint body-size limits, WAF wiring, WebSocket upgrade mapping, gzip compression, and JSON error pages (Deen-Bridge#254) - websocket.conf: Dedicated WebSocket / Socket.io upgrade proxy (Deen-Bridge#252) - caching.conf: Static asset Cache-Control / Expires / ETag headers (Deen-Bridge#255) - modsecurity.conf: ModSecurity core config — engine, body inspection, audit logging, CRS inclusion, anomaly scoring (Deen-Bridge#256) - waf-rules.conf: Custom defense-in-depth rules (JSON validation, request smuggling, null bytes, scanner detection, URI length) (Deen-Bridge#256) - waf-exclusions.conf: Scoped false-positive exclusions for health checks, WebSocket handshakes, and multipart uploads, plus tuning examples for HTML/PHP/SQL false positives (Deen-Bridge#256) - README.md: Full setup guide covering installation, verification, anomaly scoring mode, and false-positive tuning workflow 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@khaylebfortune Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a defense-in-depth Web Application Firewall (WAF) layer in front of the Node.js API using nginx + ModSecurity + OWASP Core Rule Set (CRS v3/v4) in anomaly scoring mode.
This closes #252, closes #254, closes #255, closes #256.
What this PR adds
Files created
nginx/nginx.confnginx/websocket.confnginx/caching.confnginx/modsecurity.confnginx/waf-rules.confnginx/waf-exclusions.confnginx/README.mdArchitecture
Key design decisions
tx.anomaly_scorerather than blocking individually. Only requests exceeding the threshold (default: 5) are rejected with 403. This is the recommended CRS operational mode.SecRequestBodyLimitmatches nginx: Both set to 50 MB for/api/uploadsso the WAF never rejects a request that nginx would accept.Custom WAF rules (waf-rules.conf)
application/jsonrequestsFalse-positive exclusions (waf-exclusions.conf)
/health,/health/*/socket.io/multipart/form-dataCommented tuning examples are included for HTML-rich JSON (941xxx), PHP-injection noise (932xxx), and SQL keywords in search (942xxx).
Testing
Deployment notes
owasp/modsecurity-crs)/etc/nginx/modsecurity/crs/SecRuleEngine DetectionOnlymode, tune, then flip toSecRuleEngine OnSee
nginx/README.mdfor the full installation and verification guide.🤖 Generated with Codebuff
Co-Authored-By: Codebuff noreply@codebuff.com