Comprehensive security framework for agentic AI applications โ 8-layer defense-in-depth.
Project description
๐ก๏ธ AgentArmor
Comprehensive open-source security framework for agentic AI applications.
AgentArmor provides 8-layer defense-in-depth security for AI agents, covering every point in the data flow where data is at rest, in transit, or in use. Built to address the OWASP Top 10 for Agentic Applications (2026).
What's New in v0.2.0
- ๐ OpenClaw Identity Guard โ Encrypts OpenClaw agent identity files (SOUL.md, MEMORY.md, etc.) with AES-256-GCM + BLAKE3 integrity. Protects against host-level compromise.
- ๐ MCP Server Scanner โ Scans MCP servers for security risks before connecting: dangerous tool detection, rug-pull detection, transport security analysis, and risk scoring.
- ๐ฆ New
mcpoptional dependency group fastapi,uvicorn, andhttpxpromoted to core dependencies
Why AgentArmor?
Every existing security tool is a point solution โ output validators, prompt injection scanners, or policy engines in isolation. AgentArmor is the first unified framework that secures the entire agentic architecture end-to-end.
The 8 Security Layers
| Layer | Name | What It Protects |
|---|---|---|
| L1 | Ingestion | Input scanning, prompt injection detection, source verification |
| L2 | Storage | Encryption at rest (AES-256-GCM), data classification, integrity (BLAKE3) |
| L3 | Context | Instruction-data separation, canary tokens, prompt hardening |
| L4 | Planning | Action plan validation, risk scoring, chain depth limits |
| L5 | Execution | Rate limiting, network egress control, human approval gates |
| L6 | Output | PII redaction (Presidio), DLP, sensitivity filtering |
| L7 | Inter-Agent | Mutual auth (HMAC), trust scoring, delegation depth control |
| L8 | Identity | Agent identity, JIT permissions, credential rotation |
Quick Start
Install
# Using uv (recommended)
uv add agentarmor-core
# With all optional features
uv add "agentarmor-core[all]"
# With MCP server scanning support
uv add "agentarmor-core[mcp]"
# Available extras: proxy, pii, otel, mcp, all, dev
# For development
git clone https://github.com/Agastya910/agentarmor.git
cd agentarmor
uv sync --all-extras --dev
Basic Usage
import asyncio
from agentarmor import AgentArmor, ArmorConfig
async def main():
armor = AgentArmor()
# Register your agent
identity, token = armor.l8_identity.register_agent(
agent_id="my-agent",
permissions={"read.*", "search.*"},
)
# Intercept tool calls
result = await armor.intercept(
action="read.file",
params={"path": "/data/notes.txt"},
agent_id="my-agent",
input_data="Read the file please",
)
print(f"Safe: {result.is_safe}")
print(f"Verdict: {result.final_verdict.value}")
asyncio.run(main())
Use as Decorator
@armor.shield(action="database.query")
async def query_database(sql: str) -> dict:
return db.execute(sql)
Proxy Server Mode
agentarmor serve --config agentarmor.yaml --port 8400
curl -X POST http://localhost:8400/v1/intercept \
-H "Content-Type: application/json" \
-d '{"action": "read.file", "agent_id": "my-agent", "input_data": "Hello"}'
Integrations
OpenClaw Identity Guard (New in v0.2.0)
Protects OpenClaw agent identity files (SOUL.md, MEMORY.md, USER.md) from host-level theft by encrypting them at rest.
from agentarmor import OpenClawGuard
guard = OpenClawGuard(identity_dir="~/.openclaw")
# Audit โ see what's at risk (read-only, no changes)
report = guard.scan()
print(report["risk_level"]) # "high" if plaintext files found
print(report["plaintext_files"]) # ["SOUL.md", "MEMORY.md", ...]
# Encrypt โ AES-256-GCM + BLAKE3 integrity
enc_report = guard.encrypt_identity_files()
print(enc_report.summary())
# SOUL.md โ SOUL.md.armor (plaintext deleted)
# Decrypt โ restore for debugging
dec_report = guard.decrypt_identity_files()
MCP Server Scanner (New in v0.2.0)
Scans MCP servers for security risks before your agent connects.
from agentarmor import MCPGuard, MCPScanReport
from agentarmor.integrations.mcp import RiskLevel
guard = MCPGuard()
# Scan a live server
report = guard.scan_server("http://localhost:8000")
print(report.summary())
# Risk level: HIGH (HTTP, no auth detected)
# Scan a tool manifest offline
report = guard.scan_tool_manifest([
{"name": "exec_command", "description": "Execute shell commands"},
{"name": "search_web", "description": "Search the web safely"},
])
assert report.risk_level == RiskLevel.CRITICAL # exec_command flagged!
print(report.dangerous_tools) # [ToolRisk(tool_name='exec_command', ...)]
print(report.rug_pull_indicators) # Detects "safe" description + dangerous name
LangChain
from agentarmor.integrations.langchain import AgentArmorCallback
callback = AgentArmorCallback(armor=armor)
agent.invoke({"input": "..."}, config={"callbacks": [callback]})
OpenAI
from agentarmor.integrations.openai import secure_openai_client
client = secure_openai_client(OpenAI(), armor=armor)
๐ Full integration guide: docs/integrations.md
Red Team Testing
from agentarmor.redteam import RedTeamSuite
suite = RedTeamSuite(armor=armor)
results = await suite.run_all()
suite.print_report(results)
CLI Commands
| Command | Description |
|---|---|
agentarmor init |
Generate a config file |
agentarmor validate <config> |
Validate configuration |
agentarmor scan -t "text" |
Scan text for threats |
agentarmor serve |
Start proxy server |
agentarmor keygen |
Generate encryption key |
Custom Security Policies
# policies/my_agent.yaml
version: "1.0"
name: "database_agent"
agent_type: "database"
risk_level: "high"
global_denied_actions:
- "database.drop"
- "database.truncate"
require_human_approval_for:
- "database.delete"
rules:
- name: "limit_transfer_amount"
action_pattern: "transfer.*"
conditions:
- field: "params.amount"
operator: ">"
value: "1000"
verdict: "escalate"
priority: 100
Architecture
Agent Runtime (LangChain / CrewAI / OpenAI SDK / MCP)
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AgentArmor Pipeline โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ L8: Identity & IAM โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโค โ
โ โ L1: Data Ingestion โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโค โ
โ โ L2: Memory/Storage โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโค โ
โ โ L3: Context Assembly โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโค โ
โ โ L4: Plan Validation โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโค โ
โ โ L5: Action Execution โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโค โ
โ โ L7: Inter-Agent Sec โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ L6: Output Filter (post) โ
โ Audit Logger (cross-cut) โ
โ Policy Engine (cross-cut) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
External Tools / APIs / LLMs
OWASP ASI Coverage
| OWASP ASI Risk | AgentArmor Layer(s) |
|---|---|
| ASI01: Goal Hijacking | L1 (injection), L3 (prompt hardening) |
| ASI02: Tool Misuse | L4 (planning), L5 (execution), Policy Engine |
| ASI03: Identity Abuse | L8 (identity), L5 (JIT perms), OpenClaw Guard |
| ASI04: Supply Chain | L1 (source verify), MCP Scanner |
| ASI05: Code Execution | L5 (sandbox), L4 (risk scoring) |
| ASI06: Memory Poisoning | L2 (integrity), L3 (canary tokens) |
| ASI07: Inter-Agent | L7 (mutual auth, trust scoring) |
| ASI08: Cascading Failures | L4 (chain depth), L5 (rate limits) |
| ASI09: Human Trust | L6 (output filter), Audit Logger |
| ASI10: Rogue Agents | L8 (credential rotation), L7 (trust decay) |
Documentation
| Doc | Description |
|---|---|
| Quick Start | Installation and first steps |
| Architecture | 8-layer pipeline design and data flow |
| Integrations | OpenClaw, MCP Scanner, LangChain, OpenAI |
| Policy Language | YAML policy reference and examples |
| Threat Model | OWASP ASI attack vectors and defenses |
| Use Cases | Financial, coding, RAG, multi-agent examples |
| Publishing | PyPI & GitHub release guide |
Contributing
See CONTRIBUTING.md for guidelines.
License
Apache 2.0. Free for commercial and open-source use.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentarmor_core-0.2.0.tar.gz.
File metadata
- Download URL: agentarmor_core-0.2.0.tar.gz
- Upload date:
- Size: 240.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abfd3dadcc576f508db5ee37284acd9b2d79780b8f24667af42754c93a7711d1
|
|
| MD5 |
4c12ff1fd81fb2602cf514f52e41b331
|
|
| BLAKE2b-256 |
3a6065dc9c4cee5ba36641ca06b3e8901a0354243e43a7c9b9bc576b256a0e14
|
File details
Details for the file agentarmor_core-0.2.0-py3-none-any.whl.
File metadata
- Download URL: agentarmor_core-0.2.0-py3-none-any.whl
- Upload date:
- Size: 51.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f0aa516abc39d45424656475920848fc47527aac9a7784e4063fb0ce18ca199
|
|
| MD5 |
58fe588a218c0c582a16833fe1a1b0c6
|
|
| BLAKE2b-256 |
4b4127b39c08c12dd90315a4d7ec9287ad591d165b42a629e41d9fee6d10b481
|