Skip to main content
Glama
aegis-action-firewall

aegis-action-firewall

Aegis Action Firewall (aegis-action-firewall)

Zero-Trust Execution Control Plane for AI Agents — Formal Z3 SMT Policy Verification, Sealed Host Brokers, Bidirectional DLP, Biba Taint Tracking & SHA-256 HITL Audit Console.

AI agents connected to SQL databases, REST APIs, and external MCP servers face four existential security failures: hidden DDL/CTE mutations inside SELECT queries, SQL tautologies (WHERE 1=1), Server-Side Request Forgery (169.254.169.254 / IPv6-mapped loopback bypasses), and second-order prompt injections causing untrusted inputs to trigger privileged state changes. aegis-action-firewall places an unbypassable formal SMT boundary between the agent and every host credential or mutation.


1. Four-Plane Zero-Trust Architecture

+-------------------------------------------------------------------------+
| PLANE 1: AGENT BOUNDARY (Zero-Free-Text Pydantic v2 Contracts / MCP)    |
|   SqlActionIntent | HttpActionIntent | McpReadIntent (extra="forbid")   |
+------------------------------------+------------------------------------+
                                     |
                                     v
+-------------------------------------------------------------------------+
| PLANE 2: DETERMINISTIC PARSERS & BIDIRECTIONAL DLP                      |
|   * sqlglot Full Subtree AST  (CTE writes, DDL, PRAGMA, tautologies)    |
|   * Anti-SSRF HTTP Validator  (HTTPS, userinfo @, IPv6-mapped IPv4)     |
|   * Bidirectional DLP         (Outbound secrets/Luhn | Inbound taint)   |
+------------------------------------+------------------------------------+
                                     |
                                     v
+-------------------------------------------------------------------------+
| PLANE 3: FORMAL ARBITRATION & TAMPER-EVIDENT AUDIT                      |
|   * Two-Phase Z3 SMT Solver   (assert_and_track + unsat_core() < 5 ms)  |
|   * SHA-256 WAL Ledger        (prev_hash -> event_hash + session_epochs)|
|   * Host Capability Signer    (HMAC-SHA256 bound to session, ver, hash) |
+-------------------+---------------------------------+-------------------+
                    | COMMIT                          | PENDING_APPROVAL
                    v                                 v
+-----------------------------------+   +---------------------------------+
| PLANE 4A: SEALED HOST BROKERS     |   | PLANE 4B: HITL APPROVAL CONSOLE |
|   * SqlHostBroker (fetchmany)     |   |   * FastAPI + X-Aegis-Admin-Token|
|   * HttpHostBroker (HostVault auth|   |   * Atomic APPROVED -> EXECUTED |
|     zero redirects, scrubbed errs)|   |   * Constant-time hash verification|
+-----------------------------------+   +---------------------------------+

Related MCP server: governed-mcp

Live Zero-Trust Audit & HITL Console

HITL Queue & Biba Taint Isolation (TAINTED (BIBA))

Aegis Action Firewall HITL Queue and Biba Taint Sessions

SHA-256 Audit Ledger & Formal Z3 Verdicts (CHAIN VERIFIED)

Aegis Action Firewall SHA-256 Audit Ledger

Interactive Red-Team Sandbox (1-Click Offline Simulation)

Aegis Action Firewall Red-Team Sandbox


2. Formal Z3 Invariants & Red-Team Guarantees

Domain

Z3 Rule Code (unsat_core())

Mathematical Constraint / Guarantee

Verdict on Violation

Outbound Secrets

RULE_DLP_NO_SECRETS

Not(outbound_secret_detected) (sk-, ghp_, AKIA, JWT, PEM, Shannon entropy >= 4.5) — cannot be bypassed even by HITL

QUARANTINE

Destructive Tier

RULE_NO_DESTRUCTIVE_TIER

action_tier < 4 (blocks DROP, TRUNCATE, ALTER, ATTACH DATABASE, PRAGMA, and nested CTE writes like WITH d AS (DELETE ...))

DENY

SQL Single & No DDL

RULE_SQL_SINGLE_NO_DDL

Implies(SQL, And(statement_count == 1, Not(is_ddl))) — stops stacked queries (SELECT 1; DELETE ...)

DENY

SQL Allowlist

RULE_SQL_TABLE_ALLOWED

Implies(SQL, table_allowed == True) — resolves real tables across JOIN and subqueries while isolating CTE aliases

DENY

SQL Safe WHERE

RULE_SQL_SAFE_WHERE

Implies(And(SQL, requires_where), And(has_where, Not(tautology_where))) — catches 1=1, WHERE 1, NOT FALSE, 2>1, id=id, OR <tautology>

DENY

SQL Row Bounds

RULE_SQL_ROW_LIMIT

Implies(And(SQL, tier == 1), And(row_limit > 0, row_limit <= max_select_rows)) — rejects unbounded SELECT

DENY

HTTP Anti-SSRF

RULE_HTTP_ALLOWLIST_NO_SSRF

Implies(HTTP, And(domain_allowed, is_https, Not(is_private_ip))) — rejects @ userinfo, HTTP redirects, and IPv6-mapped IPv4 (::ffff:127.0.0.1)

DENY

HTTP Payload Cap

RULE_HTTP_MAX_BYTES

Implies(HTTP, payload_bytes <= max_payload_bytes) + strips agent Authorization, Cookie, Host, X-Forwarded-For headers

DENY

Epoch Blast Radius

RULE_EPOCH_WRITE_BUDGET

Implies(tier >= 2, writes_in_epoch < max_writes_per_epoch)

DENY

Biba Integrity Guard

RULE_BIBA_TAINT_REQUIRES_APPROVAL

Implies(And(tainted_input, Not(human_approved)), tier == 1) — taint persists across approvals; atomic single-use HITL execution

PENDING_APPROVAL

HITL Risk Escalation

RULE_HITL_ESCALATION_REQUIRED

Implies(And(Or(pii_detected, risk_score >= 70, tier == 3), Not(human_approved)), False) — constant-time SHA-256 check on frozen intent

PENDING_APPROVAL


3. 30-Second Quickstart (Interactive Demo & Red-Team Sandbox)

Run the offline demo environment (synthetic in-memory vault + httpx.MockTransport + SQLite WAL demo ledger — zero live credentials or external network traffic):

# 1. Install editable package and dependencies
pip install -e .

# 2. Optional: seed/reset the 6 reproducible demo scenarios explicitly
python scripts/seed_demo.py --reset

# 3. Launch the Audit & HITL Web Console in Demo Mode (auto-seeds if needed)
python -m aegis_firewall.console_api --demo --host 127.0.0.1 --port 8000
  1. Copy the ephemeral X-Aegis-Admin-Token printed once on startup.

  2. Open http://127.0.0.1:8000, paste the token into the top bar, and click Connect.

  3. Inspect the CHAIN VERIFIED SHA-256 indicator, trigger one-click attacks in the Red-Team Sandbox tab, and approve or reject frozen intents in Pending Approvals (HITL).

(Note: Sandbox endpoints /api/sandbox/* fail closed with 403 Forbidden whenever --demo / enable_sandbox=True is not active.)


4. Production Deployment & Verification

Host Configuration

  1. Policies (config/policies.yaml): Declare sql.allowed_tables, sql.writable_tables, sql.sensitive_tables, http.allowed_domains, http.sensitive_endpoints, and hitl.risk_threshold.

  2. Sealed Host Vault (.secrets/vault.json): Copy .secrets/vault.example.json (git-ignored) to store hmac_master_key (>= 16 chars), SQL DSNs, and upstream API tokens solely on the host process:

{
  "hmac_master_key": "replace-with-32-byte-random-hex-secret",
  "sql_connections": {
    "app_db": { "backend": "sqlite", "dsn": "./data/app_runtime.db" }
  },
  "http_services": {
    "crm": {
      "base_url": "https://api.crm.example.com",
      "auth_header": "Authorization",
      "auth_scheme": "Bearer",
      "token": "replace-with-host-crm-api-token"
    }
  }
}
  1. Environment Variables:

    • AEGIS_CONSOLE_TOKEN: Static admin token protecting /api/* (X-Aegis-Admin-Token).

    • AEGIS_POLICIES_PATH, AEGIS_VAULT_PATH, AEGIS_LEDGER_PATH (legacy AEGIS_FIREWALL_* aliases also supported).

    • MAIL_TRIAGE_LEDGER_PATH (optional): Path to aegis-mail-triage SQLite ledger opened strictly in ?mode=ro read-only mode to unify mail and action events inside /api/events.

Agent MCP Client Config (stdio)

Copy mcp_config.example.json directly into Claude Desktop, Cursor, or Antigravity IDE:

{
  "mcpServers": {
    "aegis-action-firewall": {
      "command": "python",
      "args": ["-m", "aegis_firewall.mcp_server"],
      "env": {
        "AEGIS_POLICIES_PATH": "./config/policies.yaml",
        "AEGIS_VAULT_PATH": "./.secrets/vault.json",
        "AEGIS_LEDGER_PATH": "./data/aegis_firewall.db"
      }
    }
  }
}

Security Audit & Test Verification

pytest -v

Available Tools

5 tools
http_request_safeC

Validate HTTPS allowlist/anti-SSRF, scan outbound DLP, evaluate Z3, and execute HTTP.

Inputs: url (required), method (required), service_id (required), session_id (required), +4 more. Returns: object

list_pending_approvalsB

Return queued HITL PENDING_APPROVAL entries cleanly without secrets or DSNs.

Inputs: session_id. Returns: object

mint_signed_context_tokenB

Sign a short-lived Ed25519 X-Aegis-Context-Token (ttl_sec <= 60) for Vault lease checkout.

Inputs: actor_id (required), trace_id (required), tenant_id (required), scopes, +3 more. Returns: object

sql_execute_safeC

Parse SQL AST, scan outbound DLP, evaluate Z3 policy invariants, and execute safely.

Inputs: query (required), session_id (required), connection_id (required), params, +2 more. Returns: object

verify_ledger_integrityA

Audit full SHA-256 chain continuity across aegis_audit_events.

Inputs: no named parameters. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool targets a clearly distinct operation: SQL execution, HTTP execution, approval listing, ledger verification, and token minting. The two execution tools are separated by protocol (SQL vs HTTPS) with no overlap, and the auxiliary tools cover disjoint concerns. An agent can select unambiguously based on intent.

    Naming Consistency3/5

    Three tools follow a verb_noun pattern (list_pending_approvals, verify_ledger_integrity, mint_signed_context_token), while sql_execute_safe and http_request_safe use a resource_verb_suffix pattern. The split is readable and semantically meaningful, but it is not a single predictable convention.

    Tool Count5/5

    Five tools is tightly scoped for an action-firewall with HITL approval, audit integrity, and token minting responsibilities. Each tool corresponds to a distinct capability with no redundancy. Nothing feels padded or missing at the count level.

    Completeness3/5

    The surface covers governed execution, approval inspection, audit verification, and token minting, but list_pending_approvals has no companion to approve or reject queued requests, creating a dead end in the HITL workflow. Policy inspection or ledger event querying are also absent, though these are secondary.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides a secure, policy-driven read-only gateway that exposes multiple databases to AI tools via MCP, with governed select, search, and aggregate operations and no free-form SQL.
      Apache 2.0
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to query a read-only data surface through typed tools, enforcing caller-specific row access, field masking, and withheld-row disclosure so they can retrieve entitled information without writes or silent data leakage.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI assistants and LLM agents to query operational databases through a read-only MCP gateway with table whitelisting, automatic row limits, sensitive-data masking, and audit logging.
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables secure runtime mediation of tool requests from MCP-connected AI agents, enforcing least-privilege policies, validating intent and inputs, detecting multi-step attacks and information leaks, and supporting explainable decisions, audit trails, and human approval for sensitive actions.
      MIT