Download the PHP package ados-labs/enterprise-security-shield without Composer
On this page you can find all versions of the php package ados-labs/enterprise-security-shield. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ados-labs/enterprise-security-shield
More information about ados-labs/enterprise-security-shield
Files in ados-labs/enterprise-security-shield
Package enterprise-security-shield
Short Description Enterprise Security Shield - WAF, Honeypot, Scanner Detection, Rate Limiting, Resilience Patterns with Admin Panel Integration
License MIT
Informations about the package enterprise-security-shield
Enterprise Security Shield
Enterprise-Grade Web Application Firewall (WAF) for PHP 8.1+
A complete security solution with ML-based threat detection, bot verification, anomaly detection, and resilience patterns trained on real attack data.
Features
Core Security
| Feature | Description |
|---|---|
| Online Learning ML | TRUE Machine Learning that learns continuously from security events |
| ML Threat Classifier | Naive Bayes classifier pre-trained on 662 real security events |
| XSS Detection | Multi-layer detection with HTML entity decode loop |
| SQL Injection Detection | Pattern + behavioral analysis |
| Anomaly Detection | Z-Score + IQR statistical analysis |
| Bot Verification | DNS + IP range verification for 30+ bots |
| Honeypot System | 69 trap endpoints to catch scanners |
| GeoIP Blocking | Country-level restrictions via MaxMind |
| Rate Limiting | 4 algorithms: sliding window, token bucket, leaky bucket, fixed |
Enterprise Security (NEW)
| Feature | Description |
|---|---|
| Request Smuggling Detection | CL.TE, TE.CL, TE.TE attack detection |
| WebSocket Protection | CSWSH detection, origin validation, connection limits |
| JWT Security Validation | alg:none attacks, algorithm confusion, header injection |
| GraphQL Protection | Query depth/complexity limits, batching abuse, introspection control |
| DDoS Layer 7 | Slowloris, RUDY, HTTP flood detection |
| HTTP/2 Protection | CONTINUATION flood, Rapid Reset (CVE-2023-44487) |
| API Rate Limiting | Per-endpoint, per-API-key, tier-based limits |
| Threat Intelligence | Auto-updating feeds (FireHOL, Emerging Threats, Abuse.ch) |
Resilience Patterns
| Pattern | Description |
|---|---|
| Circuit Breaker | Fail fast when dependency is down |
| Retry Policy | Exponential backoff with jitter |
| Fallback Chain | Try providers in order until success |
| Bulkhead | Limit concurrent executions |
Observability
| Component | Format |
|---|---|
| Tracing | OpenTelemetry-compatible, W3C traceparent |
| Metrics | Prometheus text format |
| Health Checks | JSON + HTTP status for Kubernetes |
Installation
Requirements
- PHP 8.1+ (uses enums, readonly properties, named arguments)
- ext-json (required)
Optional Extensions
| Extension | Required For |
|---|---|
| ext-redis | RedisStorage (recommended for production) |
| ext-pdo | DatabaseStorage |
| ext-curl | Notifications, GeoIP |
Optional Dependencies
| Package | Required For |
|---|---|
| geoip2/geoip2 | GeoIP blocking (MaxMind) |
Quick Start
Minimal Setup (No Redis Required)
Production Setup (Redis)
SecurityMiddleware with ML
The SecurityMiddleware automatically integrates ML-based threat detection alongside pattern-based scoring.
How ML Scoring Works:
- Pattern-based scoring (ThreatPatterns) runs first
- ML analyzer classifies the request
- ML score is weighted at 40% and added to pattern score
- If ML confidence >= 85% with BAN decision → immediate block
- Total score checked against threshold for auto-ban
TRUE Machine Learning (Online Learning)
The WAF includes a true online learning system that continuously improves from security events.
How It Works
- Initial Knowledge: Pre-trained on 662 real security events (starting weights)
- Continuous Learning: Every security event (ban, honeypot hit, SQLi block) trains the model
- Concept Drift: Decay factor (0.995) ensures older patterns lose relevance over time
- Persistence: Learned weights stored in Redis, survives restarts
Learning Status
| Status | Samples | Behavior |
|---|---|---|
warming_up |
< 50 | Uses initial weights only |
learning |
50-500 | Blends initial + learned weights |
mature |
> 500 | Primarily uses learned weights |
Usage (Online Learning Classifier)
Auto-Learning Integration
The SecurityMiddleware automatically learns from every security event:
Static ML Threat Classifier
For deterministic classification (useful alongside online learning):
Training Data
- 662 security events from production logs
- 188 confirmed attack patterns
- Categories: SCANNER, IOT_EXPLOIT, CREDENTIAL_THEFT, CMS_PROBE, BRUTE_FORCE, LEGITIMATE
Features Detected
Usage
Bot Verification
Verifies legitimate bots (Googlebot, Bingbot, etc.) via DNS reverse lookup and IP range verification.
Supported Bots
| Category | Bots |
|---|---|
| Search Engines | Googlebot, Bingbot, YandexBot, Baiduspider, DuckDuckBot |
| Social Media | FacebookBot, Twitterbot, LinkedInBot, Pinterest |
| AI Crawlers | GPTBot, ClaudeBot, CCBot, PerplexityBot |
| SEO Tools | AhrefsBot, SemrushBot, MJ12bot |
| Monitoring | UptimeRobot, Pingdom, DatadogBot |
| Messaging | Slackbot, TelegramBot, DiscordBot |
Usage
DNS Verification
For search engine bots, the service performs reverse DNS lookup:
gethostbyaddr('66.249.66.1')→crawl-66-249-66-1.googlebot.com- Verify domain ends with
.googlebot.comor.google.com - Forward lookup confirms IP matches
Anomaly Detection
Statistical anomaly detection using Z-Score and IQR (Interquartile Range) analysis.
Metrics Analyzed
| Metric | Baseline | Detection Method |
|---|---|---|
| Requests/minute | 15.2 | Z-Score > 3σ |
| 404 errors/session | 2.1 | IQR outlier |
| Unique paths/session | 8.7 | Z-Score |
| Path depth | 3.2 | IQR outlier |
| Session duration | 180s | Anomaly if < 10s |
Usage
XSS Detection
Multi-layer XSS detection with recursive HTML entity decoding.
Detection Patterns
<script>tags and event handlersjavascript:URLs- SVG/XML payloads
- Encoded attacks (HTML entities, URL encoding, Unicode)
Usage
SQL Injection Detection
Pattern-based SQLi detection with behavioral analysis.
Detection Patterns
- UNION-based injection
- Boolean-based blind injection
- Time-based blind injection
- Error-based injection
- Stacked queries
Usage
Rate Limiting
Four algorithms for different use cases.
Algorithms
| Algorithm | Best For | How It Works |
|---|---|---|
| Sliding Window | API rate limits | Counts requests in moving time window |
| Token Bucket | Burst-tolerant limits | Tokens refill over time, bursts allowed |
| Leaky Bucket | Smooth rate limiting | Requests "leak" at constant rate |
| Fixed Window | Simple limits | Counts per calendar minute/hour |
Usage
Honeypot System
69 trap endpoints to catch scanners.
Trap Endpoints
Usage
Resilience Patterns
Circuit Breaker
Retry Policy
Storage Backends
| Backend | Use Case | Performance | Persistence |
|---|---|---|---|
| NullStorage | Testing | ~0.001ms | No |
| DatabaseStorage | Production (no Redis) | ~1-5ms | Yes |
| RedisStorage | Production (recommended) | ~0.05ms | Yes |
Security: Fail-Open vs Fail-Closed
By default, RedisStorage uses fail-open behavior:
- On Redis failure, returns "not banned" / score = 0
- Prioritizes availability over security
- Site stays online during outage
For high-security applications (banking, government), implement fail-closed:
Notifications
Health Checks
Admin Panel Integration
The package includes admin panel views for WordPress-style integration.
Views Included
dashboard.php- Security overview with chartsevents.php- Security events log with filtersips.php- IP ban/whitelist managementconfig.php- WAF configuration presets
CSS/JS Assets (CSP A+ Compliant)
All assets use external files (no inline CSS/JS):
Testing
File Structure
Enterprise Security Features
Request Smuggling Detection
Detects HTTP Request Smuggling attacks that exploit discrepancies between front-end and back-end servers.
Detected Attack Types:
- CL.TE (Front-end uses Content-Length, back-end uses Transfer-Encoding)
- TE.CL (Front-end uses Transfer-Encoding, back-end uses Content-Length)
- TE.TE (Both use Transfer-Encoding but parse obfuscation differently)
WebSocket Protection
Validates WebSocket upgrade requests and detects Cross-Site WebSocket Hijacking (CSWSH).
JWT Security Validation
Validates JWT tokens for common attack patterns. Does NOT verify signatures - use with a JWT library.
Detected Attacks:
ALG_NONE_ATTACK- Algorithm set to "none" (bypass signature)ALG_CONFUSION- RS256→HS256 confusion (use public key as HMAC secret)HEADER_INJECTION- Malicious jku/x5u/jwk headersSUSPICIOUS_CLAIMS- Admin role escalation attempts
GraphQL Protection
Protects against GraphQL-specific DoS and abuse patterns.
Detected Attacks:
DEPTH_ATTACK- Query depth exceeds limitCOMPLEXITY_ATTACK- Query too expensiveBATCH_ABUSE- Too many operations in batchINTROSPECTION_BLOCKED- Schema discovery attemptALIAS_ABUSE- Excessive aliases (amplification)
DDoS Layer 7 Protection
Detects application-layer DDoS attacks. Works best with server metrics.
Detected Attacks:
HTTP_FLOOD- Excessive request rateSLOWLORIS- Slow HTTP headersRUDY- Slow POST body (R-U-Dead-Yet)CONNECTION_FLOOD- Too many concurrent connectionsRESOURCE_EXHAUSTION- Expensive endpoint abuse
HTTP/2 Protection
Detects HTTP/2 protocol-specific attacks. Requires server metrics for full detection.
Detected Attacks:
CONTINUATION_FLOOD- CVE-2024-27983RAPID_RESET- CVE-2023-44487HPACK_BOMB- Header compression abuseSETTINGS_FLOOD- Excessive SETTINGS frames
API Rate Limiting
Advanced rate limiting with per-endpoint, per-API-key, and tier-based limits.
Threat Intelligence Feeds
Auto-updating threat intelligence from public feeds.
Included Feeds:
- FireHOL Level 1 (high confidence malicious IPs)
- Emerging Threats Compromised IPs
- Abuse.ch Feodo Tracker (botnet C&C)
- Spamhaus DROP (Do Not Route Or Peer)
- Tor Exit Nodes (disabled by default)
SecurityShield Integration
All enterprise features are integrated into the main SecurityShield class:
What This WAF Actually Does
Attack Detection & Blocking
| Attack Type | Detection Method | Real-Time Blocking |
|---|---|---|
| SQL Injection | Tokenizer-based analysis (not just regex), detects UNION, boolean, stacked queries | Yes |
| XSS Attacks | Multi-pass HTML entity decoding, DOM analysis, event handler detection | Yes |
| Request Smuggling | CL.TE, TE.CL, TE.TE header analysis | Yes |
| Path Traversal | Pattern + normalization bypass detection | Yes |
| Command Injection | Shell metacharacter and command pattern detection | Yes |
| GraphQL Abuse | Query depth, complexity, batching limits | Yes |
| JWT Attacks | alg:none, algorithm confusion, header injection | Yes |
Machine Learning (Real, Not Marketing)
| Component | Implementation | Verification |
|---|---|---|
| Naive Bayes Classifier | src/ML/ThreatClassifier.php - 800+ lines |
Probabilistic classification with feature extraction |
| Online Learning | src/ML/OnlineLearningClassifier.php |
Incremental training, concept drift handling |
| Anomaly Detection | src/ML/AnomalyDetector.php |
Z-Score + IQR statistical analysis |
| Training Data | 662 real security events, 188 attack patterns | Pre-trained weights included |
DDoS Protection (Layer 7)
| Attack | Detection | How It Works |
|---|---|---|
| HTTP Flood | Request rate analysis | Atomic rate limiting with Redis Lua scripts |
| Slowloris | Header receive timing | Detects slow header transmission |
| RUDY | Body receive timing | Detects slow POST body attacks |
| HTTP/2 Rapid Reset | RST_STREAM counting | CVE-2023-44487 detection |
Rate Limiting (4 Algorithms)
All use atomic operations (Lua scripts) to prevent race conditions:
- Sliding Window (most accurate)
- Token Bucket (burst-tolerant)
- Leaky Bucket (smooth enforcement)
- Fixed Window (simple)
Architecture: Where This WAF Fits
Use BOTH layers for complete protection.
Known Limitations
- Fail-Open Default - Allows traffic during Redis outage (configurable to fail-closed)
- DNS Timeout - Bot verification can block up to 30s on slow DNS (timeout configurable)
- No L3/L4 Protection - Cannot stop volumetric network floods (use edge WAF)
- No Third-Party Audit - Not penetration tested by external security firm
- ML Warm-Up - Online learning needs ~50 samples before improving
Transparency
This project is honest about what it does and doesn't do:
- No penetration test - We haven't paid for a third-party security audit
- Defense in depth - Use alongside Cloudflare/AWS WAF, not instead of
- Open source - All code is inspectable, no black boxes
- Security audit included - See
docs/SECURITY-AUDIT.mdfor known vulnerabilities we've documented ourselves
License
MIT License - see LICENSE
Credits
- Initial ML model trained on security events from real production environments
- Online Learning Classifier uses Naive Bayes with Laplace smoothing
- Concept drift handling via exponential decay (0.995 factor)
- Feature extraction from 40+ attack patterns across 11 threat categories
All versions of enterprise-security-shield with dependencies
ext-json Version *