Skip to content

Ingress PEP Gateway (WAF, Pure BFF & Virtual Patching)

The Aegis Gate PEP (Policy Enforcement Point) gateway is the frontline sovereign shield of the Aegis ecosystem (apps/gate-proxy). Deployed in-line or integrated as an external authorization subrequest (ForwardAuth), it scrutinizes every inbound packet before it reaches the internal application network, delivering a deterministic security verdict in under 1.5 milliseconds.


πŸ›οΈ Ingress PEP Architecture Diagram

[ Inbound HTTP/HTTPS Request ]
β”‚
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Edge Reverse Proxy / Load Balancer β”‚
β”‚ (Traefik v3 Dokploy / Nginx / Caddy / Envoy) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
ForwardAuth Mode β”‚ Transparent Reverse
(Subrequest /_aegis/verify) Proxy Mode (:8000)
β”‚
β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ AEGIS GATE PEP β€” INSPECTION PIPELINE β”‚
β”‚ β”‚
β”‚ 1. Pure BFF Token Handler (/api/auth/*) β”‚
β”‚ ↳ OIDC PKCE Resolution + AES-256-GCM Sealed Session Cookies β”‚
β”‚ β”‚
β”‚ 2. Recursive Canonicalization & Normalization Engine β”‚
β”‚ ↳ Multi-layer URL/Hex/Unicode decoding, null-byte stripping β”‚
β”‚ β”‚
β”‚ 3. RFC 413 Volumetric Body Cap β”‚
β”‚ ↳ Immediate truncation at 32 KB (Anti-DDoS & Buffer Overflow) β”‚
β”‚ β”‚
β”‚ 4. Shannon Information Entropy Engine (H) β”‚
β”‚ ↳ Mathematical detection of shellcodes, binaries & high-H tokens β”‚
β”‚ β”‚
β”‚ 5. Hardened WAF Rule Registry (OWASP CRS) β”‚
β”‚ ↳ Scanners (Nikto, Nuclei), SQLi, XSS, RCE, LFI, SSRF, CMS Probes β”‚
β”‚ β”‚
β”‚ 6. Dynamic Zero-Day Virtual Patching β”‚
β”‚ ↳ Upstream CVE neutralization (e.g., PHP2Shell, JNDI Injections) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β–Ό β–Ό
[ VERDICT : BLOCK ] [ VERDICT : ALLOW ]
β€’ Immediate HTTP 403 / 413 β€’ HTTP 200 Forwarded
β€’ Real-time JSON telemetry β€’ Verified X-Aegis Headers
β€’ Streamed to TimescaleDB β€’ Relayed to Upstream Apps

πŸ›‘οΈ The 6 Pillars of the Inspection Pipeline

1. Pure BFF Architecture (Backend-for-Frontend)

Aegis completely eliminates token-theft vulnerabilities resulting from malicious script execution (XSS):

  • No access token (access_token, id_token, or refresh_token) is ever stored in the browser (neither in localStorage, sessionStorage, nor in JavaScript memory).
  • The apps/gate-proxy/src/bff module intercepts /api/auth/* routes, negotiates standardized OIDC with PKCE (RFC 7636) verification, and issues an encrypted AES-256-GCM, HttpOnly, SameSite=Strict, Secure session cookie to the browser.
  • Upstream of internal microservices, Aegis Gate decrypts the session and injects certified identity headers (X-Aegis-User-Id, X-Aegis-User-Role, X-Aegis-Tenant-Id).

2. Multi-Encoding Canonicalization & Anti-Obfuscation (Lock #2)

Attackers frequently use nested obfuscation to evade pattern-matching filters (multi-encoding %252e%252e%252f, null bytes %00, mixed UTF-8 sequences, HTML entities, and Base64 wrappers).

  • Recursive 3-Pass Decoding: The engine recursively canonicalizes all URI paths, query strings, headers, and bodies until reaching a stable, raw representation.
  • Entity & Escape Normalization: Strips null bytes, decodes named, decimal, and hex HTML entities (", '), and resolves Hex/Unicode escapes (\x.., \u...., %u....).
  • Path Sanitization: Strictly normalizes path separators (/./, //, Windows \) prior to directory traversal inspection.
  • Automatic Base64 Ingestion: Suspect base64 segments (>= 16 alphanumeric characters with valid padding) are decoded on the fly and inspected as primary payloads.

3. Volumetric Rate-Limiting & Automated Auto-Jail (Lock #3)

Aegis Gate protects upstreams against brute-force attacks and high-speed fuzzing:

  • Sliding-Window Volumetric Limiter: Enforces a strict budget of 60 requests per 10 seconds per client IP, returning HTTP 429 Too Many Requests with a compliant Retry-After: 10 header.
  • 15-Minute Automated Auto-Jail: Any unauthenticated IP accumulating 3 critical offenses (risk_score >= 90) within 5 minutes is automatically quarantined in the persistent blacklist for 15 minutes (AUTO_JAIL_TEMPORARY_QUARANTINE), synced to the Go Control Plane and visible in the Cockpit.

4. HTTP Protocol Hardening & RFC 413 / 431 Defense (Lock #4)

  • Header Budgets (HTTP 431): Requests exceeding 8 KB total header size, 4 KB for an individual header, or containing over 64 headers are blocked with HTTP 431 Request Header Fields Too Large.
  • Volumetric Body Cap (HTTP 413): Enforces a strict cut-off on the incoming request body size (configurable via AEGIS_MAX_PAYLOAD_BYTES, defaulting to 32 KB), halts transfer immediately with HTTP 413 Payload Too Large, and defends against compression bombs.
  • Multipart RFC Validation: Validates multipart/form-data boundary formatting, bounds nested boundary recursion depth (<= 3), and blocks executable upload extensions (.php, .phtml, .phar, .sh).

5. Shannon Entropy Engine

  • Computing Shannon entropy $H(X) = -\sum P(x) \log_2 P(x)$ quantifies information density across URI segments and request bodies.
  • Any string exhibiting an entropy value greater than 3.85 over a significant character length instantly indicates an injected compiled binary, base64-obfuscated shellcode, or cryptographic key exfiltration attempt.

5. Hardened WAF Filtering & Pentest Tool Interception

Aegis blocks destructive cyberattack vectors at the root:

  • Offensive scanners: Automated reconnaissance tools blocked on the very first packet (Nikto, SQLmap, Nuclei, Gobuster, Dirbuster, Nmap, Acunetix, WPScan, Hydra, etc.).
  • SQL Injections (SQLi) : Detection of time-based blind SQLi (benchmark(), pg_sleep()), UNION SELECT, and schema enumeration (information_schema).
  • Path Traversal & LFI: Neutralization of sensitive file reads (/etc/passwd, /etc/shadow, .env, .git/config, wp-config.php).
  • Remote Code Execution (RCE) : Interception of command injection attempts (; cat, | id, $(whoami), /bin/sh).
  • Cross-Site Scripting (XSS) : Strict filtering of executable HTML elements and DOM event triggers (<script>, onerror=, onload=, javascript:).

6. Dynamic Zero-Day Virtual Patching

When a critical vulnerability emerges in an underlying framework or runtime (such as the PHP2Shell CVE-2026-33044 flaw or Log4j JNDI injection), Aegis Gate instantly applies a proxy-level virtual patch. Target services are shielded on the spot, without requiring system downtime or urgent source code rollouts.


βš™οΈ Operational Modes

Aegis Gate integrates seamlessly with any modern cloud architecture:

Mode A: External Authorizer (ForwardAuth)

The primary edge proxy (e.g., Traefik v3 in Dokploy or Nginx) maintains TLS termination with Let’s Encrypt and calls Aegis on its /_aegis/verify endpoint:

  • The subrequest forwards client metadata headers (X-Forwarded-Uri, X-Forwarded-Method, X-Forwarded-For).
  • Aegis assesses the request in 0.4 ms. If safe, it returns HTTP 200 OK with validation headers, and Traefik forwards the request to the upstream container.
  • If a threat is detected, Aegis immediately returns HTTP 403 Forbidden or HTTP 413, aborting the request before it can touch the protected workload.

Mode B: Transparent Reverse Proxy (Edge Gateway)

Aegis Gate listens directly on port 8000 (or behind an L4 cloud load balancer). It performs in-line inspection and proxies clean traffic to configured upstreams (BACKEND_URL, WEB_URL, or AEGIS_UPSTREAM_ROUTING).


πŸ“‘ Audit Telemetry & Real-Time Correlation

Every security inspection generates structured JSON telemetry dispatched to the Go/TimescaleDB backend:

{
"tenant_id": "00000000-0000-0000-0000-000000000001",
"client_ip": "185.220.101.5",
"user_agent": "Mozilla/5.0 (Nikto/2.1.6)",
"http_method": "GET",
"request_uri": "/admin/wp-config.php.bak",
"decision": "BLOCK",
"http_status_returned": 403,
"latency_ms": 0.8,
"threat_type": "PENTEST_SCANNER_DETECTED",
"severity": "CRITICAL",
"risk_score": 96,
"entropy": 4.12,
"metadata": {
"engine": "Aegis Gate PEP (OWASP CRS)",
"rule_triggered": "ScannerSignatureRule",
"virtual_patch_active": true
}
}

The incident is visualized instantaneously in the SOC Triage Kanban for impact triage and automated IP quarantine.


πŸ“š In-Depth Articles & Technical References

To learn more about the theoretical foundations and production learnings behind Aegis Gate PEP, explore our research articles on AIVO: