Certificate-gated execution for LLM agent systems. Every side effect gets a cryptographic certificate. Every capability is scoped and time-limited. Every move is logged to a tamper-evident trace.
Zero dependencies. Python 3.10+ stdlib only. 2,060 lines. 103 tests.
Most multi-agent LLM setups have a gap: the LLM decides to run a command, and subprocess.run executes it. There's no enforcement layer between intent and action.
Permission systems are binary (allow/deny) with no provenance tracking, no audit trail, and no per-agent capability scoping. When you're running multiple AI models in parallel — Claude, GPT, open-source — each with tool access, this gap becomes a security incident waiting to happen.
This kernel fills that gap. It was built for and battle-tested in a production multi-model orchestration system where three LLM backends share a workspace with file locking, event bus coordination, and concurrent tool execution.
| Threat | How |
|---|---|
| Prompt injection to execution | Taint tracking — TAINTED inputs can't reach exec without approval |
| Unauthorized commands | Capability tokens with command allowlists and denylists |
| Cross-agent privilege escalation | Per-agent scoped tokens with independent constraints |
| Credential leakage | Output scanning and redaction before publishing |
| Expired/stale authorization | Token TTL with runner-side re-validation |
| Audit evasion | Merkle-chained trace — tamper-evident execution log |
| URL-based attacks | IP literal, punycode, credential-in-URL, redirect chain validation |
| Header injection | Dangerous headers blocked (Host, Transfer-Encoding, etc.) |
| Taint laundering | TAINTED can never become TRUSTED through transforms |
| Unbounded execution | Execution budget per token — blocks after N uses |
| Workspace escape | Path constraints on working directory |
from agent_security_kernel import (
Prov, pv, TAINTED, TRUSTED,
ToolSpec, CapabilityToken, CapabilityEntry,
enforce_policy, PolicyError, now_rfc3339,
)
# Define your tool
tool = ToolSpec(name="my_cli", capability_scope="exec", args_schema_id="SCHEMA.RUN_SHELL.v1")
# Mint a scoped capability token
token = CapabilityToken(
agent_id="my-agent",
session_id="session-001",
max_executions=100,
capabilities=[
CapabilityEntry(
tool="my_cli", scope="exec",
args_schema="SCHEMA.RUN_SHELL.v1",
constraints={"command_denylist_regex": [r"\brm\b", r"\bmkfs\b"]},
),
],
)
# Gate execution
ts = now_rfc3339()
try:
cert = enforce_policy(
tool=tool,
intent_pv=pv("run command", Prov("user", "chat:1", TAINTED, ts)),
args_pv={"command": pv("echo hello", Prov("policy_kernel", "config", TRUSTED, ts))},
policy_rule_id="POLICY.MY_CLI.V1",
requires_human_approval=True,
capability_token=token,
)
print(f"Approved: {cert['cert_id'][:20]}...")
# NOW run subprocess
except PolicyError as e:
print(f"Blocked: {e.fail_type}")
# Do NOT run subprocess +-------------------+
LLM Intent ---->| enforce_policy() |----> TOOL_CALL_CERT.v1
| (policy kernel) |
+-------------------+
| |
[PASS] [FAIL]
| |
subprocess OBSTRUCTION.v1
.run() (logged, not executed)
|
Merkle Trace
(append-only)
Key components:
enforce_policy()— The single gate. Validates provenance, checks capability token, enforces constraints, mints certificate.CapabilityToken— Scoped, time-limited, budget-limited authorization. Per-agent, per-tool.Prov/pv()— Provenance tags. Every value carries its origin (user/web/email/file/system/cli_output) and taint state (TRUSTED/TAINTED).MerkleTrace— Append-only log of all moves. Tamper-evident via hash chaining.ToolSpec— Declares a tool's name, capability scope, and schema.
Every field that can influence an action carries a Prov tag:
pv("echo hello", Prov(
source="policy_kernel", # where it came from
ref="config:startup", # traceable reference
taint=TRUSTED, # TRUSTED or TAINTED
captured_at="2026-...", # when
))Rules:
TAINTEDinputs from web/email/file cannot reachexecscope without human approval- Transforms can never upgrade
TAINTEDtoTRUSTED(enforced bymint_taint_flow_cert) - CLI outputs are always tagged
TAINTED— downstream agents must treat them accordingly
token = CapabilityToken(
agent_id="codex-bridge",
session_id="bridge-codex-20260407",
max_executions=1000, # budget: blocks after N uses
expires_at="2026-04-08T...", # TTL: blocks after expiry
capabilities=[
CapabilityEntry(
tool="bridge_cli_exec",
scope="exec",
args_schema="SCHEMA.BRIDGE_CLI_EXEC.v1",
constraints={
"command_allowlist": ["codex exec", "cat"],
"command_denylist_regex": [r"\brm\b"],
"prompt_denylist_regex": [r"\brm\s+-rf\s+/"],
"allowed_paths": ["/home/user/project"],
},
),
],
)tool_runner.execute_http_fetch()— Full HTTP pipeline with URL sanitization, redirect validation, domain allowlisting, header injection blocking, and capability token enforcement.
pip install agent-security-kernelOr from source:
git clone https://github.com/1r0nw1ll/agent-security-kernel.git
cd agent-security-kernel
pip install -e .pip install -e ".[dev]"
pytest103 tests covering policy enforcement, taint flow, capability constraints, URL bypass classes, and regression scenarios.
This kernel was built for a real multi-agent research system running:
- 3 concurrent LLM backends (Claude, GPT/Codex, open-source) sharing a single workspace
- File-level resource locking via event bus to prevent write conflicts
- Cert-gated tool execution on every bridge command — no tool call runs without a valid certificate
- Automated security audit (12 guardrail E2E tests + 14 kernel self-tests) running daily
The system handles parallel agent sessions with disjoint file scopes, broadcast coordination for git commits, and stale-lock detection for crashed sessions.
- Zero dependencies — stdlib only, auditable in an afternoon
- Single gate — one function (
enforce_policy) between intent and action, no exceptions - Taint is permanent — TAINTED can never become TRUSTED through any transform
- Budget-limited — every token has a max execution count, not just a TTL
- Append-only audit — Merkle-chained trace log, tamper-evident by construction
MIT