Skip to content

Configuration and CLI Reference

Evan Newman edited this page Nov 30, 2026 · 1 revision

Configuration and CLI reference


CLI subcommands (cmd/miragegate/main.go)

Exit codes: 0 success, 1 runtime error, 2 missing or unknown subcommand.

miragegate serve [flags]

Starts the Layer 7 reverse proxy (ReadHeaderTimeout: 5s, IdleTimeout: 60s, MaxHeaderBytes: 64 KiB, graceful SIGINT/SIGTERM shutdown) and optional Admin Web Console.

Flag Default Description
--config <path> (built-in defaults) YAML or JSON configuration file
--proxy-listen <addr> :8080 Reverse proxy listen address
--admin-listen <addr> 127.0.0.1:8081 Admin Web Console listen address (warns if non-loopback; "" disables)
--upstream <url> http://127.0.0.1:9000 Real upstream HTTP/HTTPS base URL
--ecs-out <path> (none) Append ECS v8.11.0 JSONL handoff alerts

miragegate demo [flags]

Runs a self-contained 3-actor live simulation (real mock upstream + MirageGate proxy + legitimate user + autonomous recon agent + cross-IP human curl handoff).

Flag Default Description
--turns <int> 36 Autonomous recon turns (values < 6 reset to 36)
--openapi <path> examples/openapi_saas.yaml (or built-in default) OpenAPI 3.x YAML/JSON schema
--ecs-out <path> (none) Write ECS JSONL handoff alerts
--html <path> (none) Write standalone zero-CDN HTML incident report
--keep-alive false Keep the Admin Web Console serving after demo finishes
--admin-listen <addr> 127.0.0.1:8081 Console bind address for --keep-alive
--secret <str> demo secret Override master secret for demo session

miragegate inspect [flags] <artifact>

Statelessly verifies and decodes any shadow route, API key, Honey-JWT, tenant scope, cursor, or raw 32-char token offline. Refuses to run with an ephemeral secret.

Flag Default Description
--config <path> (none) Optional config file (crypto.* settings)
--secret-file <path> (none) Read master secret from file (preferred over --secret)
--secret <str> (env MIRAGEGATE_SECRET) Inline master secret (prints stderr process-list warning)
--api-key-prefix <str> mg_live_ Override expected API key prefix
--json false Print pretty-printed watermark.Breadcrumb JSON

miragegate bench [flags]

Runs the 4-cohort benchmark (legitimate_users, scripted_canary_scanners, autonomous_recon_agents, hybrid_agent_human_handoffs), validating 0.0% legitimate FPR, 100.0% handoff recall, $0.00 defender LLM spend, and ~60 µs/req defender CPU.

  • --sessions <int> (default 10) — sessions per cohort
  • --turns <int> (default 30) — turns per autonomous recon agent session

miragegate version / help

Prints version metadata (-v, --version) or usage (-h, --help).


Configuration schema (examples/miragegate.yaml, internal/config/config.go)

Configuration files support YAML 1.2 subset or JSON and are unmarshaled via yamlmini.UnmarshalStrict—any unknown key fails fast at startup so security-setting typos cannot silently degrade protection.

server:
  proxy_listen: ":8080"
  admin_listen: "127.0.0.1:8081"
  upstream: "http://127.0.0.1:9000"    # Required http:// or https:// URL
  trusted_proxies: []                  # CIDR list; auto-propagated to gate.trusted_proxies
  read_timeout_ms: 10000
  write_timeout_ms: 15000

crypto:
  secret: ""                           # Optional inline secret (>= 16 B); prefer secret_env
  secret_env: "MIRAGEGATE_SECRET"
  api_key_prefix: "mg_live_"
  jwt_issuer: "auth.internal.acme-cloud.local"
  jwt_audience: "acme-internal-api"

schema:
  openapi_path: "examples/openapi_saas.yaml"
  internal_domain: "internal.acme-cloud.local"

gate:
  trusted_proxies: []
  bypass_cidrs: []
  bypass_paths: ["/healthz", "/readyz", "/metrics", "/static/"]
  bypass_header: ""                    # Example config sets "X-Internal-Gateway-Verified"
  bypass_header_value: ""
  canary_routes:
    - "/.env"
    - "/.git/config"
    - "/admin/debug"
    - "/actuator/env"
    - "/debug/pprof"
    - "/swagger-internal.json"
    - "/api/v1/internal/tokens"
    - "/api/v1/admin/config"
  graphql_paths: ["/graphql", "/gql", "/api/graphql"]
  waf_shunt_header: "X-Mirage-Shunt"
  waf_shunt_value: ""                  # Empty disables opt-in WAF shunt
  detect_tampered_jwt: true
  detect_graphql_introspection: true
  idor_velocity_threshold: 6
  idor_window_seconds: 30

labyrinth:
  max_depth: 6                         # Clamped 1..255 (vault loop requires >= 4)
  min_latency_ms: 8
  max_latency_ms: 35                   # Clamped <= 30000 and >= min_latency_ms
  records_per_page: 12                 # Clamped 1..100
  session_ttl_minutes: 120             # >= 1
  attacker_model_name: "Frontier Reasoning ($3/$15 per 1M)"
  attacker_input_usd_per_1m: 3.00
  attacker_output_usd_per_1m: 15.00
  attacker_system_prompt_tokens: 1800
  attacker_reasoning_tokens_per_turn: 420
  attacker_context_cap_tokens: 128000

telemetry:
  ecs_output_path: ""
  max_events_in_memory: 2000           # Clamped 50..20000

Supported OpenAPI 3.x and YAML subsets

  • OpenAPI 3.x (internal/schema/openapi.go, max 10 MiB): Reads YAML or JSON extracting info.title, info.version, paths keys (deriving resource nouns while ignoring {params}, api, and vX segments), operation parameters[].name, and components.schemas.<Name>.properties field names. Missing sections fall back cleanly to schema.DefaultModel. ($ref resolution and explicit response-schema examples are on the roadmap.)
  • YAML 1.2 subset (internal/yamlmini/yamlmini.go, max 10 MiB, max nesting depth 64): Supports JSON passthrough, indentation-based block mappings/sequences, sequence-of-mappings (- key: val), single/double quoted strings, inline flow lists/maps ([...], {...}), booleans, null/~, integers/floats, # comments, and ---/... markers. Does not implement YAML anchors/aliases, multi-line block scalars (|/>), or custom tags.

Loopback Admin Web Console HTTP API (internal/report/console.go)

Every endpoint enforces loopback Host header validation (localhost, 127.0.0.1, ::1, or empty; else 403 Forbidden), X-Content-Type-Options: nosniff, X-Frame-Options: DENY, Referrer-Policy: no-referrer, Cache-Control: no-store, and strict Content-Security-Policy:

Method & Path Request / Query Response
GET / — Zero-CDN dark-mode operations UI polling /api/snapshot every 2s (pure DOM APIs, zero innerHTML)
GET /api/snapshot — 200 JSON session.Snapshot
POST /api/verify JSON {"artifact": "..."} (<= 16 KiB, application/json) 200 {"valid":true,"breadcrumb":{...}}, 422 invalid artifact, 400/413/415/503 on input/codec error
GET /api/report.html Optional ?download=1 Standalone zero-CDN dark-mode HTML incident report (caps at latest 200 alerts, 200 sessions, 100 transcript rows; inline SVG downsampled to <= 64 points)
GET /api/alerts.jsonl Optional ?download=1 application/x-ndjson stream of ECS v8.11.0 handoff alerts