Skip to content

Commit d5ab204

Browse files
feat: add request body inspection support
Add the ability to inspect request bodies for attacks, enabling detection of SQL injection, XSS, command injection, and other attacks in POST/PUT request payloads. - Add --body-inspection flag (enabled by default) - Add --max-body-size flag (default 1MB) to limit memory usage - Implement on_request_body_chunk handler with chunk accumulation - Support all content types (decoded as UTF-8 lossy) - Add body inspection tests for SQLi, XSS, and command injection - Update README with new options and Sentinel config example 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 66c95c7 commit d5ab204

File tree

3 files changed

+298
-23
lines changed

3 files changed

+298
-23
lines changed

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ async-trait = "0.1"
2929
# Pattern matching
3030
regex = "1.10"
3131

32+
# Base64 decoding for body chunks
33+
base64 = "0.22"
34+
3235
# Serialization
3336
serde = { version = "1.0", features = ["derive"] }
3437
serde_json = "1.0"

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Web Application Firewall agent for [Sentinel](https://github.com/raskell-io/sent
99
- **Path Traversal** - Directory traversal, encoded attacks
1010
- **Command Injection** - Shell commands, pipe injection
1111
- **Protocol Attacks** - Request smuggling, scanner detection
12+
- **Request Body Inspection** - JSON, form data, and all content types
1213
- **Paranoia levels** (1-4) for tuning sensitivity
1314
- **Detect-only mode** for monitoring without blocking
1415

@@ -47,6 +48,8 @@ sentinel-waf-agent --socket /var/run/sentinel/waf.sock --paranoia-level 1
4748
| `--protocol` | `WAF_PROTOCOL` | Enable protocol attack detection | `true` |
4849
| `--block-mode` | `WAF_BLOCK_MODE` | Block (true) or detect-only (false) | `true` |
4950
| `--exclude-paths` | `WAF_EXCLUDE_PATHS` | Paths to exclude (comma-separated) | - |
51+
| `--body-inspection` | `WAF_BODY_INSPECTION` | Enable request body inspection | `true` |
52+
| `--max-body-size` | `WAF_MAX_BODY_SIZE` | Maximum body size to inspect (bytes) | `1048576` (1MB) |
5053
| `--verbose` | `WAF_VERBOSE` | Enable debug logging | `false` |
5154

5255
## Paranoia Levels
@@ -98,7 +101,7 @@ agents {
98101
transport "unix_socket" {
99102
path "/var/run/sentinel/waf.sock"
100103
}
101-
events ["request_headers"]
104+
events ["request_headers", "request_body_chunk"]
102105
timeout-ms 50
103106
failure-mode "open"
104107
}
@@ -157,7 +160,7 @@ This agent provides a subset of ModSecurity's OWASP CRS functionality:
157160
| Path Traversal | ✓ | ✓ |
158161
| Command Injection | ✓ | ✓ |
159162
| Full CRS Ruleset | Partial | ✓ |
160-
| Body Inspection | - | ✓ |
163+
| Body Inspection | | ✓ |
161164
| Custom Rules | - | ✓ |
162165
| Dependencies | Pure Rust | libmodsecurity |
163166
| Installation | `cargo install` | Complex |

0 commit comments

Comments
 (0)