100% Free Open-Source Security Gateway•MIT / Apache-2.0

Give Every AI Agent a Security Guard.

AgentGuard is a self-hosted AI agent security gateway. It deterministically enforces spending caps, detects adversarial prompt injection, restricts high-privilege tools, and protects commerce checkouts like Razorpay and PayPal before payment operations execute.

Terminal • Quickstart
$ git clone https://github.com/altafpasha/agentguard
$ cd agentguard && docker compose up -d
Core Capabilities

Security Built Specifically for Agentic Workflows

Every capability is backed by real, deterministic implementation in Fastify, PostgreSQL, and TypeScript.

Deterministic Spending Limits

Apply deterministic limits to every agent action. Single-tx spending caps ($50 max), rolling daily budget caps ($200), currency allowlists (INR, USD, EUR, GBP), and recipient denylists.

Deterministic Deny-by-Default

Prompt Injection Defense

Inspect untrusted text for adversarial prompt injection, jailbreaks, delimiter hijacking, and system prompt leaks before agents call tools or downstream APIs.

Dual-Phase Heuristic Scanner

Human-in-the-Loop Review

High-value transactions trigger an authoritative HOLD state. Actions are locked with an immutable cryptographic digest until an operator issues a single-use token.

Dual-Key Escrow Execution

Least Privilege Tool Whitelisting

Restrict agent execution to explicit tool namespaces. Any request invoking unapproved tools (shell_executor, raw SQL) is blocked at the gateway before reaching infrastructure.

Tool Namespace Isolation

Razorpay & Commerce Gateway

Pre-flight policy evaluation for Razorpay and PayPal checkouts. Enforce amount, currency, and customer parameters before calling payment APIs. Verify HMAC signatures.

Pre-Flight Commerce Guard

Forensic Tamper-Evident Audit

Every decision, scan, and order creation is logged to PostgreSQL with immutable requestId, sha256 digests, and policy versioning for complete auditability.

Append-Only Forensic Ledger
Interactive Public Demos

Real Security Scenarios, Tested Live

These are not hardcoded frontend animations. Each scenario sends real evaluation requests to AgentGuard’s Fastify backend, executes policy rules, and returns genuine decisions.

Open Full Workbench
Prompt Security

Prompt Injection Defense

Security Problem

Adversarial user prompts attempt jailbreaks, delimiter hijacking, or secret prompt leaking to hijack agent tool execution.

Expected Behavior

AgentGuard scans input heuristics and token boundaries before execution. Injection payloads are immediately flagged and BLOCKED.

Developer Takeaway: Deterministic heuristic scanning stops malicious prompts before tools or payment APIs are ever called.
Financial Safety

Deterministic Spending Caps

Security Problem

Autonomous agents can hallucinate excessive prices or trigger repeated loops, depleting merchant or customer bank balances.

Expected Behavior

Policy engine checks amount against strict per-transaction and 24h limits. Exceeding operations ($50 max) are strictly BLOCKED.

Developer Takeaway: Deterministic mathematical policies prevent unauthorized spending regardless of model hallucination.
Least Privilege

Unauthorized Tool Invocation

Security Problem

Compromised agents attempt to call high-privilege tools like command shells (shell_executor) or raw database query endpoints.

Expected Behavior

The gateway checks requested tools against an authorized whitelist. Unapproved tools are instantly BLOCKED with DISALLOWED_TOOL.

Developer Takeaway: Principle-of-least-privilege at the gateway layer halts lateral movement and unauthorized tool escalation.
Payment Integration

Razorpay Payment Protection

Security Problem

Agent-initiated commerce checkouts can attempt unverified currencies, rogue amounts, or bypass merchant business logic.

Expected Behavior

Merchant backend requests pre-flight evaluation. AgentGuard verifies limits and currencies. Razorpay orders are created ONLY on ALLOW.

Developer Takeaway: By placing AgentGuard as an authoritative pre-flight gateway, downstream Razorpay APIs are never called for blocked or held actions.
Human Governance

Human-in-the-Loop Review (HITL)

Security Problem

High-value transactions execute without human oversight, creating serious financial liability and compliance risk.

Expected Behavior

Operations exceeding the review threshold ($25.00) return HOLD, creating an immutable approval record with cryptographic digest.

Developer Takeaway: Dual-key authorization pauses sensitive operations until an authorized human operator grants a single-use token.
Commerce & Payment Gateway Protection

Pre-Flight Security for Razorpay Operations

AgentGuard evaluates transactions before orders are created on Razorpay. Held or blocked actions never touch payment rails, and all completed payments are cryptographically verified using HMAC-SHA256 signatures.

1

Customer Requests Payment

AI agent or customer initiates an order. The merchant backend validates currency, customer identity, and amount.

2

AgentGuard Evaluates Action (Fail-Closed)

Merchant calls AgentGuard policy engine. If the gateway is down or times out, the client authoritatively fails closed and blocks the transaction.

3

Conditional Razorpay Execution

Only ALLOW triggers Razorpay order creation. HOLD triggers human reviewer review, and BLOCK immediately rejects the operation.

4

HMAC-SHA256 Signature Verification

Orders are only marked as PAID after verifying cryptographic payment and webhook signatures using constant-time comparison.

merchant-backend.ts
TypeScript SDK
// 1. Pre-flight evaluation before calling Razorpay
const evaluation = await agentGuard.evaluatePayment({
agentId: 'travel-agent-01',
amount: 3500,
currency: 'INR',
tool: 'razorpay_payment'
});
// 2. Enforce decision: NEVER proceed on HOLD or BLOCK
if (evaluation.decision !== 'ALLOW') {
throw new Error(evaluation.reason);
}
// 3. Safe to execute downstream Razorpay order
const order = await razorpay.orders.create({ ... });
System Architecture

Deterministic Dual-Phase Decision Engine

Decisions are calculated through code rules and mathematical constraints, with complete isolation from untrusted client input.

P1

Pre-Flight Interception

Agent actions hit the AgentGuard proxy. Payloads are checked for prompt injection, disallowed tool names, and malicious delimiters.

P2

Deterministic Evaluation

The policy engine evaluates limits: max transaction amounts, cumulative daily spends, velocity windows, and human approval thresholds.

P3

Guarded Execution & Ledger

ALLOW issues a cryptographic authorization token. Execution is strictly tied to token validation, and every event is recorded in PostgreSQL.

Self-Host Anywhere

Own Your Security Gateway. Free Forever.

AgentGuard is 100% open-source software under the MIT/Apache-2.0 license. Run it on your laptop, an internal VPC, or a $5 VPS with Docker Compose.

# Clone and run in one command
git clone https://github.com/altafpasha/agentguard
cd agentguard && docker compose up -d