Skip to content

Latest commit

 

History

History
165 lines (124 loc) · 11.3 KB

README.md

File metadata and controls

165 lines (124 loc) · 11.3 KB

MirageGate

CI Go 1.22+ Zero Dependencies License: MIT

Zero-LLM cost-asymmetry tarpit & cryptographic human-handoff attribution proxy for hybrid human+agentic attackers.

Modern offensive operations increasingly operate as a human + agentic relay: an autonomous reasoning agent probes APIs, tampers with auth tokens, parses errors, and hunts for undocumented routes—then hands off its best "discoveries" to a human operator (often on a completely different IP, VPN exit, or client) for manual verification and exploitation.

Conventional edge defenses miss the structural economics of this workflow:

  • Blunt 403/404 responses subsidize offensive agents, letting them prune dead ends in a single turn and move on cheaply.
  • LLM-powered honeypots burn defender inference tokens and add latency, inverting the cost asymmetry.
  • Prompt-injection traps ("ignore previous instructions...") are brittle and increasingly ignored by frontier reasoning models.

MirageGate is a zero-LLM, zero-external-dependency Go L7 reverse proxy that lets legitimate traffic pass straight to your upstream untouched while shunting provably adversarial sessions into a deterministic, OpenAPI-shaped "near-miss" labyrinth—burning attacker API tokens/context at $0.00 defender LLM cost and embedding HMAC-SHA256 cryptographic breadcrumbs that provably link the later manual human handoff back to the originating recon agent.

MirageGate Architecture and Handoff Attribution Flow


How It Works

                             [ Inbound HTTP/HTTPS Request ]
                                            │
                                            ▼
                 ┌────────────────────────────────────────────────────┐
                 │  Stage 0 & 1: Bypass Path Guard + Pre-Gate         │
                 │  Cryptographic Breadcrumb Inspector (~2µs)         │
                 │  • Shadow Routes, API Keys, Honey-JWTs,            │
                 │    X-Tenant-Scope, ?cursor=                        │
                 │  • Cross-IP / Cross-UA reuse ─▶ CRITICAL HANDOFF   │
                 │    ATTRIBUTION ALERT (stateless + stateful HMAC)   │
                 └──────────────────────────┬─────────────────────────┘
                                            │
                    ┌───────────────────────┴───────────────────────┐
                    │ Clean / Bypassed                              │ Adversarial Trigger
                    ▼                                               ▼
      ┌──────────────────────────────┐               ┌────────────────────────────────────────┐
      │ Stage 2: Safe Activation Gate│               │ Stage 3: Deterministic Near-Miss       │
      │ • Hard bypass FIRST:         │               │          Procedural Labyrinth          │
      │   CIDRs, /healthz, auth hdr  │               │ • OpenAPI 3.x YAML/JSON schema-shaped  │
      │ • Provable triggers ONLY:    │               │ • Seeded via HMAC-SHA256 + ChaCha8     │
      │   Canary routes, alg:none &  │               │ • Depth 0→4+: 410/422 hints → shards → │
      │   tampered JWT, scoped GQL   │               │   Honey-JWT, API key & Vault URL       │
      │   introspection, WAF, IDOR   │               │ • Zero MirageGate banners / zero LLMs  │
      └──────────────┬───────────────┘               └───────────────────┬────────────────────┘
                     │                                                   │
                     ▼                                                   ▼
       [ Real Upstream Service ]                       [ Economics · ECS JSONL · Live Console ]
       (Native L7 Reverse Proxy,                       (Loopback :8081 UI + Zero-CDN Offline
        0.0% Legit Collateral)                          Dark-Mode HTML Incident Report)

For the full threat model, cryptographic wire layout, and state machine specification, see docs/ARCHITECTURE.md.


Cryptographic Breadcrumb Surfaces

Every synthetic artifact emitted inside the mirage encodes a 24-byte authenticated binary envelope (Version | Kind | SessionID(64-bit) | IssuedAt(32-bit) | Depth | TriggerFlags | HMAC-SHA256[:8]) using domain-separated subkeys derived from MIRAGEGATE_SECRET:

Artifact Kind Format-Preserving Wire Shape Where Verified
shadow_route /v2-internal/ops-<32-char-b64url> · /v2-internal/vault/export-<token> Request URL path segments
api_key mg_live_<32-char-b64url> (prefix configurable) Authorization: Bearer, X-API-Key
honey_jwt Standard RFC 7519 HS256 JWT carrying watermark in jti + kid Authorization: Bearer eyJ...
tenant_scope org_<32-char-b64url> X-Tenant-Scope header
cursor cur_<32-char-b64url> ?cursor= / ?page_token=

Because the envelope is self-authenticating, any horizontally scaled MirageGate edge node (even after a restart with zero Redis/database) can verify a breadcrumb in constant time and recover the originating SessionID, IssuedAt, Depth, and TriggerFlags—while stateful enrichment adds exact IP/User-Agent divergence proofs (198.51.100.42 / AutoRecon-Agent → 203.0.113.88 / curl/8.7.1) and exact time-to-handoff (Δt).


Quickstart

Requires Go 1.22+ (zero external dependencies; builds cleanly offline).

# Build single static binary
go build -o ./bin/miragegate ./cmd/miragegate

# 1. Run the self-contained 3-actor live demo (Legit User + 36-turn Recon Agent + Cross-IP Human Handoff)
./bin/miragegate demo --turns 36 \
  --ecs-out out/handoff_alerts.ecs.jsonl \
  --html out/handoff_report.html

# 2. Same demo, keeping the zero-CDN live Admin Web Console open on http://127.0.0.1:8081
./bin/miragegate demo --turns 36 --keep-alive

# 3. Run the reproducible 4-cohort cost-asymmetry & attribution recall benchmark
./bin/miragegate bench --sessions 10 --turns 30

# 4. Run MirageGate as a live L7 reverse proxy in front of your upstream API
export MIRAGEGATE_SECRET="$(openssl rand -hex 32)"
./bin/miragegate serve --config examples/miragegate.yaml

# 5. Offline cryptographic verification of any captured honey-artifact
MIRAGEGATE_SECRET="miragegate-demo-master-secret-v1-do-not-use-in-prod" \
  ./bin/miragegate inspect "<shadow-route-or-honey-jwt-or-api-key>"

CLI Commands

Command Purpose
miragegate demo Runs a real mock upstream + MirageGate proxy + 3 live actors (legitimate user, 36-turn autonomous recon agent, cross-IP manual curl handoff), printing attribution alerts and cost telemetry; optionally exports --ecs-out, --html, or stays live via --keep-alive.
miragegate serve Starts the L7 reverse proxy (--proxy-listen) and loopback live Admin Web Console (--admin-listen) with optional --config, --upstream, and live --ecs-out SIEM writer.
miragegate inspect <artifact> Verifies and decodes any MirageGate shadow route, honey API key, Honey-JWT, tenant scope, or pagination cursor offline (--json supported; reads MIRAGEGATE_SECRET or --secret-file).
miragegate bench Evaluates Legitimate Collateral FPR, Handoff Attribution Recall, Defender µs/req, and Cost Asymmetry Multiplier across 4 traffic cohorts.

Reproducible Benchmark Results

Run ./bin/miragegate bench --sessions 10 --turns 30 to reproduce locally:

Traffic Cohort Sessions Mirage Turns Handoff Alerts Defender CPU / req Est. Attacker Spend Cost Asymmetry
legitimate_users 10 0 0 ~122 µs (full upstream proxy) $0.0000 n/a
scripted_canary_scanners 10 10 0 ~16 µs $0.0119 >50,000,000x
autonomous_recon_agents 10 300 0 ~60 µs $2.3720 >95,000,000x
hybrid_agent_human_handoffs 10 310 10 ~60 µs $2.5307 >98,000,000x

Summary: Legitimate Collateral FPR 0.0% · Handoff Attribution Recall 100.0% · Defender LLM Spend $0.00 · Defender Labyrinth Latency ~60 µs/turn


Security & Hardening Highlights

  • Zero External Dependencies: Pure Go standard library (go.mod has zero require directives), minimizing supply-chain attack surface.
  • Anti-Spoofing Client IP Resolution: X-Forwarded-For (walked right-to-left) and X-Real-IP are ignored by default and honored only when r.RemoteAddr matches explicitly configured server.trusted_proxies.
  • Zero-Collateral Safe Activation Gate: Hard bypass rules (bypass_paths, bypass_cidrs, bypass_header) run first; control headers are stripped before reaching upstream; GraphQL introspection checks are strictly scoped to configured GraphQL paths with JSON unicode decoding (\u005f) and zero false positives on __typename.
  • Bounded Memory & CPU: Strict scan bounds on pre-gate HMAC verification, 64 KiB header limits, bounded session/IDOR/alert ring buffers, and 0600 permissions on exported ECS alerts and HTML reports.
  • Hardened Loopback Console: Binds to 127.0.0.1:8081 by default, enforces strict Content-Security-Policy + loopback Host DNS-rebinding checks, zero external CDNs, and zero innerHTML.

Development & Verification

gofmt -l .
go vet ./...
go test -race -v ./...

Complementary Defense Suite

MirageGate pairs naturally with OodaTap:

  • OodaTap — Passive encrypted network telemetry engine detecting outbound/lateral offensive OODA loops inside your network without decrypting TLS.
  • MirageGate — Active zero-LLM L7 edge tarpit & cryptographic human-handoff attribution proxy engaging inbound agentic recon before exploitation begins.

Roadmap

  • Optional Caddy / Envoy HTTP filter module wrapper around internal/proxy
  • Configurable custom shadow-route prefix pools for deeper domain blending
  • Built-in Webhook / Slack / PagerDuty alert sink alongside ECS JSONL
  • OpenAPI response-schema example synthesis for GraphQL & gRPC-Gateway surfaces

Security & License