Skip to main content
Glama
nandhakumar-murugan

OpenAgentShield

๐Ÿ›ก๏ธ OpenAgentShield โ€” Zero-Trust Security Gateway for Autonomous AI Agents

The Open-Source Security Firewall & AST Sandbox for AI Agent Tool Calls and Model Context Protocol (MCP) Middleware.
Engineered by KGiSL Campus Solvers โ€ข Lead Maintainer: Nandhakumar M (Google Student Ambassador, B.E. CSE Cyber Security)

Python 3.10+ License Test Suite Security Standards


๐ŸŒ The Global Real-World Challenge

Autonomous AI agents (Claude Code, Google Antigravity, Cursor, AutoGPT, Windsurf) are rapidly gaining write and shell execution powers on developer workstations, cloud infrastructure, and connected hardware (e.g. Android ADB devices).

However, indirect prompt injection, malicious supply chains, and LLM hallucinations can lead to disastrous real-world outcomes:

  • Catastrophic System Deletion: AI executing rm -rf / or recursive deletions.

  • Shell Command Injections: Chained shell payloads (; reboot, | sh, && rm) escaping caller arguments (e.g. Google Artemis Issue #55).

  • Credential Exfiltration: Leaking .env API keys, SSH private keys, or GitHub personal access tokens back into public LLM completions or logs.

OpenAgentShield acts as a high-performance, transparent proxy firewall between AI agents and underlying system tools, intercepting every invocation in micro-seconds to enforce zero-trust security policies.


Related MCP server: SentinelGate

๐Ÿ—๏ธ Architecture Overview

      [ Autonomous AI Agent / MCP Client ]
         (Claude Code / Antigravity / Cursor)
                         โ”‚
                         โ–ผ
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ”‚        OpenAgentShield Core       โ”‚
        โ”‚  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€  โ”‚
        โ”‚  1. AST Shell Guard & Injection  โ”‚
        โ”‚  2. Secret & PII Redaction       โ”‚
        โ”‚  3. Sensitive File Boundaries    โ”‚
        โ”‚  4. Cryptographic Audit Hasher   โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚
                 [ Action Verdict ]
        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
        โ–ผ                โ–ผ                โ–ผ
   [๐Ÿ›‘ BLOCK]       [๐Ÿ”’ REDACT]      [โœ… ALLOW]
Denied & Logged    Sanitized & Run   Safe Execution

โœจ Core Defense Modules

1. ๐Ÿ›‘ Shell AST & Command Injection Guard

  • Tokenizes shell invocations and detects dangerous system binaries (mkfs, dd, fdisk, reboot, shutdown).

  • Mitigates subshell chaining (;, &&, |, `, $()).

  • Validates Android package names against strict reverse-domain grammar (^[A-Za-z][A-Za-z0-9_]*(\.[A-Za-z][A-Za-z0-9_]*)+$), eliminating ADB injection vectors.

2. ๐Ÿ” Zero-Leak Secret Sanitizer

  • Scans input/output payloads for Google Cloud API keys, OpenAI keys, Anthropic keys, GitHub tokens (ghp_, github_pat_), AWS credentials, and RSA private keys.

  • Automatically substitutes detected tokens with zero-knowledge markers (e.g. [REDACTED:GOOGLE_API_KEY]) before payloads touch logging or external agents.

3. ๐Ÿ“‚ Sensitive File System Boundary

  • Blocks unauthorized reads and edits to .env, .aws/credentials, /etc/passwd, /etc/shadow, and id_rsa keys.

4. โšก MCP Middleware Decorator

  • Provides @interceptor.protect_tool to wrap any Model Context Protocol (MCP) server tool asynchronously with zero latency overhead.


๐Ÿš€ Quickstart & Interactive Simulation

1. Install Dependencies

pip install -r requirements.txt

2. Run the Interactive Attack & Defense Simulation

python app.py

Executes live inspection across 6 representative real-world attack scenarios (CVE-style destructive rm, shell chaining, ADB injection, credential exfiltration, and sensitive file reading).


๐Ÿ’ป Python Usage Example

from agent_shield import AgentFirewall, ActionVerdict

# Initialize zero-trust firewall
firewall = AgentFirewall()

# Inspect an agent tool invocation before running it
result = firewall.inspect_tool_call(
    tool_name="run_command",
    arguments={"CommandLine": "echo 'Hello'; reboot"}
)

if result.verdict == ActionVerdict.BLOCK:
    print(f"Attack Blocked! Reasons: {result.reasons}")
else:
    print("Action approved for execution.")

Protecting Model Context Protocol (MCP) Tools

from agent_shield import MCPInterceptor

interceptor = MCPInterceptor()

@interceptor.protect_tool("execute_command")
async def execute_command(CommandLine: str):
    # This function will NEVER run if CommandLine contains dangerous or malicious syntax
    return os.system(CommandLine)

๐Ÿงช Verification & Automated Tests

OpenAgentShield maintains 100% test pass rates across all security assertion vectors:

pytest tests/test_firewall.py

Output:

tests/test_firewall.py ......... [100%]
============================== 9 passed in 0.14s ==============================

๐Ÿค Global Contributor Roadmap

We welcome student developers and security researchers worldwide:

  • eBPF Kernel Sandboxing: Linux kernel level process confinement for agent bash subshells.

  • Real-Time Web Dashboard: FastAPI + React telemetry dashboard with live agent risk visualizer.

  • LangChain / CrewAI Middleware: Drop-in callbacks for popular Python agent frameworks.

  • Adversarial Benchmark Dataset: 100+ standardized red-teaming test cases for LLM agent jailbreaks.

Part of the KGiSL Campus Solvers open-source ecosystem. Built with โค๏ธ in Coimbatore, India for the global developer community.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    Not graded
    maintenance
    A transparent proxy and execution firewall that intercepts and audits AI agent tool calls against configurable security policies before forwarding them to downstream MCP servers. It provides safe execution environments with features like data redaction, anti-loop protection, and unified alert dispatching.
    -
  • A
    license
    Not graded
    quality
    A
    maintenance
    Open-source MCP proxy that enforces security policies, content scanning, and audit logging between AI agents and tool servers
    25
    AGPL 3.0
  • A
    license
    Not graded
    quality
    D
    maintenance
    A defensive gateway and firewall for AI agents using MCP servers, scanning tool calls, responses, and manifests for prompt injection, secrets, dangerous commands, and drift before allowing execution.
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Security scanner and runtime proxy for MCP servers. Catches tool poisoning, prompt injection, and rug-pull attacks (silent tool description changes) before they reach your AI agent. Includes a static scanner and a runtime stdio proxy.
    59 npm
    MIT