Skip to content

RouteWardenHigh-Performance Traefik Middleware

Stop sensitive file leaks (.env, .git, backups), neutralize path-evasion attacks, whitelist IPs, and serve custom error/captcha responses before requests reach your backend.

RouteWarden Logo

What is RouteWarden? ​

RouteWarden is an ultra-fast, zero-dependency Traefik middleware plugin built in pure Go. It acts as an in-line security shield deployed at your edge router or ingress controller, safeguarding downstream microservices and web applications from reconnaissance probing, accidental sensitive data exposure, and path evasion attacks.

Every internet-connected IP is continuously bombarded by automated crawlers, Shodan/Censys scanners, and credential-harvesting bots searching for .env files, .git credential databases, database backups, admin consoles, and leaked cloud credentials. RouteWarden intercepts and neutralizes these probing attempts at the Traefik proxy layer before they ever hit your upstream containers or touch your backend logs.


Request Inspection Lifecycle ​

RouteWarden evaluates every inbound HTTP request across four deterministic security stages:

Stage 1
IP / CIDR Whitelisting
Evaluates origin IP against allowedIps via socket RemoteAddr, X-Forwarded-For, or X-Real-IP. Trusted VPN/office IPs bypass checks immediately.
Stage 2
Anti-Evasion Normalization
Unescapes double URL encoding (%252e%252e), strips semicolon matrix parameters (/;param/.env), normalizes IIS backslashes (\), and scrubs null bytes.
Stage 3
Dual Match Engine
Matches against safe overrides (allowPatterns) before testing built-in sensitive dictionaries (.env, .git, backups, configs) and custom pathPatterns.
Stage 4
Multi-Action Response
Emits custom JSON, branded HTML, redirect honeypots, silent TCP drops, interactive Cloudflare Turnstile / hCaptcha challenges, or active defense Gzip Bombs.

Common Attack Vectors Blocked Out-of-the-Box ​

Without requiring any custom regex rules, RouteWarden's enableDefaultPatterns: true guards against the most critical OWASP information disclosure vulnerabilities:

🔐 Environment & Secrets

Blocks /.env, /.env.local, /.env.production, /.aws/credentials, and /.ssh/id_rsa.

📁 Version Control Repos

Prevents source code leakage via /.git/config, /.git/HEAD, /.svn/entries, and /.hg/.

💾 Database Dumps & Backups

Catches accidental exposure of /dump.sql, /db.bak, /backup.tar.gz, and /site.zip.

⚙️ Configuration & Diagnostics

Guards server manifests like /config.yaml, /app.ini, /phpinfo.php, and Spring /actuator/*.


Anti-Evasion Capabilities ​

Attackers frequently encode paths or use reverse-proxy edge cases to evade simple string-matching rules. RouteWarden eliminates these evasion vectors before matching:

Evasion TechniqueRaw Attacker PayloadRouteWarden Normalized CandidateProtection Action
Double URL Encoding/%252e%252e/%252eenv/.env🛡️ Blocked
Semicolon Matrix Traversal/public;param=1/..;param=2/.env/.env🛡️ Blocked
Windows / IIS Backslash/static\..\.git\config/.git/config🛡️ Blocked
Null Byte Injection/.env%00.png/.env🛡️ Blocked
Dot-Segment Traversal/images/../.aws/credentials/.aws/credentials🛡️ Blocked

Flexible Response Engines ​

When a sensitive route is intercepted, you decide how Traefik responds to the client:

  • json: Return clean JSON payloads with customizable status codes (e.g. 403 Forbidden or 404 Not Found) and custom error messages.
  • html: Render branded warning or company error pages with embedded styling.
  • text: Emit lightweight plain-text error messages.
  • xml: Output standard XML formatted error bodies (<Error><Status>403</Status>...</Error>) for SOAP and enterprise services.
  • captcha: Present human verification challenges using Cloudflare Turnstile, hCaptcha, or Google reCAPTCHA without needing any backend captcha server.
  • redirect: Silently deflect attackers to an external honeypot, logging sink, or warning site.
  • silentDrop: Close the TCP connection immediately without emitting any response payload to confuse automated port scanners.
  • gzipBomb (alias: bomb): Stream compressed zero-byte blocks that expand ~1000× (e.g. 10 MB expands to ~10 GB in client RAM) with negligible server bandwidth, forcing memory exhaustion (OOM) on vulnerability crawlers (nikto, gobuster, dirsearch).
  • tarpit: Reverse Slowloris defense that trickles individual bytes at slow intervals to tie up scanner socket pools and concurrency workers for minutes.
  • fakeSuccess (alias: decoy): Return realistic synthetic honeypot data (.env credentials, mock Spring Actuator metrics, dummy git/HEAD, fake wp-login) to fool attackers and log early warning telemetry.
  • rateLimitChallenge (alias: ratelimit): Issue an HTTP 429 Too Many Requests with a compliant Retry-After header to force automated scrapers to back off.
  • proxy (alias: mirror): Transparently reverse-proxy probing traffic to an internal forensics/canary container without tipping off the attacker with a 302 redirect.
  • infiniteStream (alias: garbagestream): Stream endless chunks of pseudo-random data to fill client disks and crash parsing buffers.
Active Defense

💣 Gzip Bomb Mode (Bot Counter-Offensive)

Tired of vulnerability scanners filling your logs? When an unauthorized bot scans for .env, .git, or wp-login.php, RouteWarden can return an enticing 200 OK response with Content-Encoding: gzip. The tiny wire stream expands ~1000x in the crawler's memory (10 MB expands to ~10 GB), triggering an immediate Out-Of-Memory (OOM) crash in scanning tools like dirsearch, nikto, or Python-based scrapers without consuming server resources.

response: { mode: "gzipBomb", statusCode: 200, gzipBombMB: 10 }
⚠️Caution with Search Engines: Never attach gzipBomb globally or to legitimate content URLs. Standard web browsers and legitimate search engine spiders (Googlebot, Bingbot) decompress gzip streams automatically. Only target high-confidence malicious probe endpoints (e.g. /.env, /.git, wp-login.php) and ensure enableDefaultAllowPatterns: true remains active so /robots.txt and /sitemap.xml are never bombed.

60-Second Quickstart ​

Get RouteWarden running on your Traefik instance in under a minute:

yaml
# dynamic_conf.yml
http:
  middlewares:
    global-warden:
      plugin:
        routewarden:
          enabled: true
          enableDefaultPatterns: true
          # Optional custom regex patterns to guard
          pathPatterns:
            - '(?i)^/admin(/.*)?$'
            - '(?i)^/api/internal(/.*)?$'
          # Safe exceptions (always allowed)
          allowPatterns:
            - '(?i)^/api/internal/health$'
            - '(?i)^/robots\.txt$'
          # Whitelisted VPN or office IPs
          allowedIps:
            - "10.0.0.0/8"
            - "192.168.1.100"
          # Response configuration
          response:
            mode: json
            statusCode: 404
            body: '{"error":"Not Found","message":"The requested resource does not exist"}'

  routers:
    app-router:
      rule: "Host(`example.com`)"
      entryPoints:
        - web
      middlewares:
        - global-warden
      service: app-service
toml
# dynamic_conf.toml
[http.routers.app-router]
  rule = "Host(`example.com`)"
  entryPoints = ["web"]
  middlewares = ["global-warden"]
  service = "app-service"

[http.middlewares.global-warden.plugin.routewarden]
  enabled = true
  enableDefaultPatterns = true
  pathPatterns = ["(?i)^/admin(/.*)?$", "(?i)^/api/internal(/.*)?$"]
  allowPatterns = ["(?i)^/api/internal/health$", "(?i)^/robots\\.txt$"]
  allowedIps = ["10.0.0.0/8", "192.168.1.100"]

[http.middlewares.global-warden.plugin.routewarden.response]
  mode = "json"
  statusCode = 404
  body = '{"error":"Not Found","message":"The requested resource does not exist"}'
bash
# Docker Compose Labels / CLI equivalent
- "traefik.http.middlewares.global-warden.plugin.routewarden.enabled=true"
- "traefik.http.middlewares.global-warden.plugin.routewarden.enableDefaultPatterns=true"
- "traefik.http.middlewares.global-warden.plugin.routewarden.pathPatterns=(?i)^/admin(/.*)?$,(?i)^/api/internal(/.*)?$"
- "traefik.http.middlewares.global-warden.plugin.routewarden.allowPatterns=(?i)^/api/internal/health$,(?i)^/robots\\.txt$"
- "traefik.http.middlewares.global-warden.plugin.routewarden.allowedIps=10.0.0.0/8,192.168.1.100"
- "traefik.http.middlewares.global-warden.plugin.routewarden.response.mode=json"
- "traefik.http.middlewares.global-warden.plugin.routewarden.response.statusCode=404"
- 'traefik.http.middlewares.global-warden.plugin.routewarden.response.body={"error":"Not Found","message":"The requested resource does not exist"}'

Production Case Studies ​

Real-world deployment patterns demonstrating how engineering teams and self-hosters protect their applications using RouteWarden:

📸 Immich Photo Sharing

Public photo/album sharing while strictly cloaking administrative, login, and user management APIs under a 404.

💳 Zero-Trust Webhooks

Lock down Stripe/GitHub payment webhook ingress using official provider IP CIDRs and silent TCP drops.

📊 Metrics & Actuator Cloaking

Shield Prometheus /metrics and Spring Boot /actuator from public scanners while keeping internal scrapers active.

📝 WordPress & CMS Shield

Defeat brute-force and XML-RPC attacks on wp-login.php using interactive Cloudflare Turnstile / hCaptcha challenges.

🔐 Password Vaults (Bitwarden)

Allow public mobile password sync while restricting /admin strictly to WireGuard or Tailscale subnets.

💣 Honeypots & Active Gzip Bomb

Crash scanning bots with gzipBomb decompression traps, reset TCP connections with silentDrop, and cloak staging preview clusters.


Ready to Explore? ​

Released under the MIT License.