SentinelSec

Official Stable

Pure Rust ModSecurity-compatible WAF with full OWASP CRS support - no C dependencies required.

Version: 0.2.0 Author: Sentinel Core Team License: Apache-2.0 Protocol: vv2 View Source

Quick Install

Cargo
cargo install sentinel-agent-sentinelsec

Protocol v2 Features

As of v0.2.0, the SentinelSec agent supports protocol v2 with:

  • Capability negotiation: Reports supported features during handshake
  • Health reporting: Exposes health status for monitoring
  • Metrics export: Counter metrics for requests processed/blocked/allowed
  • gRPC transport: Optional high-performance gRPC transport via --grpc-address
  • Lifecycle hooks: Graceful shutdown and drain handling

Overview

SentinelSec is a pure Rust ModSecurity-compatible WAF agent for Sentinel. It provides full OWASP Core Rule Set (CRS) support with zero C dependencies - no libmodsecurity installation required.

Note: CRS compatibility depends on the sentinel-modsec engine, a pure Rust reimplementation of libmodsecurity. If you encounter unsupported SecLang features, please file an issue.

Features

  • Full OWASP CRS Compatibility: Parse and execute 800+ CRS rules
  • Pure Rust Implementation: No libmodsecurity or C dependencies
  • Built-in SQLi/XSS Detection: Native @detectSQLi and @detectXSS operators
  • SecLang Support: Load standard ModSecurity rule files
  • Request Body Inspection: JSON, form data, XML, and all content types
  • Response Body Inspection: Detect data leakage (opt-in)
  • Block or Detect-Only Mode: Monitor before blocking
  • Zero Installation Hassle: Just cargo install, no system dependencies

Performance: 10-30x Faster than C++

SentinelSec uses the sentinel-modsec engine, a pure Rust implementation that outperforms the C++ libmodsecurity by 10-30x.

30x
Faster
Clean requests
18x
Faster
Attack detection
6.2M
Requests/sec
vs 207K for libmodsec
BenchmarkSentinelSec (Rust)libmodsecurity (C++)Speedup
Clean request161 ns4,831 ns30x faster
SQLi detection295 ns5,545 ns19x faster
Body processing1.24 µs12.93 µs10x faster
Rule parsing2.75 µs10.07 µs3.6x faster

Why is Rust faster?

  • Zero-copy parsing with Cow<str>
  • PHF (Perfect Hash Functions) for O(1) operator lookup
  • Lazy regex compilation - defer to first use
  • Aho-Corasick for multi-pattern matching
  • No FFI overhead or cross-language memory allocation

Benchmarks measured with Criterion on the sentinel-modsec library. Measured on Apple M2 Pro, single core. Run cargo bench in the sentinel-modsec repo to reproduce.

See full benchmarks for details.

Comparison

FeatureSentinelSecModSecWAF
Detection Rules800+ CRS rules800+ CRS rules285 rules
SecLang SupportYesYesNo
@detectSQLi/@detectXSSYes (pure Rust)Yes (C lib)No
DependenciesPure Rustlibmodsecurity (C)Pure Rust
Performance6.2M req/s207K req/s(varies)
Binary Size~10MB~50MB~5MB
Installationcargo installRequires libmodsecuritycargo install

Installation

The easiest way to install this agent is via the Sentinel bundle command:

# Install just this agent
sentinel bundle install sentinelsec

# Or install all available agents
sentinel bundle install --all

The bundle command automatically downloads the correct binary for your platform and places it in ~/.sentinel/agents/.

Using Cargo

cargo install sentinel-agent-sentinelsec

Configuration

Command Line

sentinel-sentinelsec-agent \
  --socket /var/run/sentinel/sentinelsec.sock \
  --rules /etc/modsecurity/crs/crs-setup.conf \
  --rules "/etc/modsecurity/crs/rules/*.conf"

Environment Variables

OptionEnv VarDescriptionDefault
--socketAGENT_SOCKETUnix socket path/tmp/sentinel-sentinelsec.sock
--grpc-addressAGENT_GRPC_ADDRESSgRPC listen address (e.g., 0.0.0.0:50051)-
--rulesSENTINELSEC_RULESRule file paths (glob patterns)-
--block-modeSENTINELSEC_BLOCK_MODEBlock (true) or detect-onlytrue
--exclude-pathsSENTINELSEC_EXCLUDE_PATHSPaths to exclude-
--body-inspectionSENTINELSEC_BODY_INSPECTIONEnable body inspectiontrue
--max-body-sizeSENTINELSEC_MAX_BODY_SIZEMax body size to inspect1048576 (1MB)
--response-inspectionSENTINELSEC_RESPONSE_INSPECTIONEnable response inspectionfalse
--verbose, -vSENTINELSEC_VERBOSEEnable debug loggingfalse

Sentinel Configuration

agent "sentinelsec" {
    socket "/var/run/sentinel/sentinelsec.sock"
    timeout 100ms
    events ["request_headers" "request_body_chunk" "response_body_chunk"]
}

route {
    match { path-prefix "/" }
    agents ["sentinelsec"]
    upstream "backend"
}

OWASP CRS Setup

Download CRS

# Clone the CRS repository
sudo mkdir -p /etc/modsecurity
sudo git clone https://github.com/coreruleset/coreruleset /etc/modsecurity/crs

# Copy example configuration
sudo cp /etc/modsecurity/crs/crs-setup.conf.example /etc/modsecurity/crs/crs-setup.conf

Run with CRS

sentinel-sentinelsec-agent \
  --socket /var/run/sentinel/sentinelsec.sock \
  --rules /etc/modsecurity/crs/crs-setup.conf \
  --rules "/etc/modsecurity/crs/rules/*.conf"

Paranoia Levels

Configure in /etc/modsecurity/crs/crs-setup.conf:

SecAction "id:900000,phase:1,pass,t:none,nolog,setvar:tx.blocking_paranoia_level=1"
LevelDescriptionUse Case
1Standard protection, minimal false positivesProduction
2Elevated protection, some false positivesSecurity-sensitive apps
3High protection, moderate false positivesStaging/testing
4Maximum protection, high false positivesSecurity research

Response Headers

HeaderDescription
X-WAF-Blockedtrue if request was blocked
X-WAF-RuleRule ID that triggered the block
X-WAF-MessageDetection message
X-WAF-DetectedDetection message (detect-only mode)

CRS Rule Categories

File PatternProtection
REQUEST-913-*Scanner detection
REQUEST-920-*Protocol enforcement
REQUEST-930-*Local file inclusion (LFI)
REQUEST-931-*Remote file inclusion (RFI)
REQUEST-932-*Remote code execution (RCE)
REQUEST-941-*Cross-site scripting (XSS)
REQUEST-942-*SQL injection
REQUEST-943-*Session fixation
REQUEST-944-*Java attacks
RESPONSE-950-*Data leakage

When to Use SentinelSec

Use SentinelSec when:

  • You want full CRS compatibility without C dependencies
  • You need easy deployment (cargo install)
  • You want built-in SQLi/XSS detection
  • You’re running in environments where installing libmodsecurity is difficult

Use ModSec agent when:

  • You need maximum compatibility with existing ModSecurity deployments
  • You have complex custom rules that require libmodsecurity-specific features

Use WAF agent when:

  • You want minimal overhead (~5MB binary)
  • Basic attack detection is sufficient
  • You don’t need SecLang rule files
AgentIntegration
ModSecC-based libmodsecurity (maximum compatibility)
WAFPure Rust, 285 native rules (no SecLang)
AI GatewayAI-specific security controls
AuthCombine with authentication