Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Shashank-H/gaiter-gaurd/llms.txt
Use this file to discover all available pages before exploring further.
Overview
GaiterGuard is an intercepting API gateway built on Bun that enforces human-in-the-loop (HITL) authorization for autonomous AI agents. The trust boundary is enforced by the gateway — not by the agent.Agents never hold production credentials. All secrets are stored in an encrypted vault and injected at request time by the gateway.
Core Components
GaiterGuard consists of five major subsystems:1. Gateway Core
The main proxy service (backend/src/services/proxy.service.ts) orchestrates request handling:
- Service resolution — validates agent access to target service
- SSRF prevention — validates target URLs against registered service baseUrls
- Credential injection — decrypts and injects service credentials
- Request forwarding — proxies to target API with 30s timeout and 10MB size limits
2. Encrypted Vault
The encryption service (backend/src/services/encryption.service.ts) provides AES-256-GCM encryption:
- Key derivation — uses scrypt to derive encryption key from
ENCRYPTION_SECRET - Authenticated encryption — AES-256-GCM with random IV per operation
- Storage format —
iv:authTag:ciphertext(all hex-encoded)
credentials table with encryptedValue field. See Security Model for details.
3. Risk Assessor
The risk assessment service (backend/src/services/risk.service.ts) evaluates every request:
- LLM-based intent analysis — OpenAI-compatible API call with 10s timeout
- HTTP method heuristics — baseline risk scores (DELETE: 0.7, PUT: 0.5, POST: 0.3, GET: 0.1)
- Blended scoring —
finalScore = llmScore * 0.7 + heuristicScore * 0.3 - Fail-closed behavior — on LLM failure, escalates heuristic score by +0.3
4. Approval Queue
The approval service (backend/src/services/approval.service.ts) manages the state machine:
- 5-state model — PENDING → APPROVED/DENIED → EXECUTED/EXPIRED
- Race-safe transitions — uses conditional
WHERE status = fromStatusupdates - TTL enforcement — cleanup job expires approved-but-unexecuted requests
5. Agent Authentication
The agent service (backend/src/services/agent.service.ts) manages agent identities:
- Agent-Key generation — cryptographically random 32-byte keys
- SHA-256 key hashing — only hash stored in database
- Service scoping — many-to-many relationship via
agent_servicestable - Revocation — soft delete via
isActiveflag
Data Flow
Here’s how a request flows through the system:Sequence Diagram
This diagram shows the detailed interaction between components:Request Lifecycle
Every proxy request follows this 8-step lifecycle (fromproxy.service.ts:380):
- Resolve service — validates agent has access to target service
- Validate target URL — SSRF prevention checks hostname and path
- Risk assessment — LLM evaluates intent mismatch and method risk
- Check idempotency — returns cached response if duplicate request
- Inject credentials — decrypts vault secrets and adds auth headers
- Forward request — proxies to target API with timeout and size limits
- Log audit trail — writes to
proxy_requeststable (fire-and-forget) - Complete idempotency — caches response for future duplicate requests
Tech Stack
| Layer | Technology |
|---|---|
| Backend runtime | Bun |
| Backend framework | Bun.serve() (no Express) |
| Database | PostgreSQL 16 |
| ORM | Drizzle ORM |
| Auth | JWT (access + refresh tokens) |
| Encryption | AES-256-GCM via Node.js crypto |
| Risk assessment | OpenAI-compatible LLM |
| Frontend | React 19 + TanStack Router + Vite |
Directory Structure
SSRF Prevention
The gateway implements multiple layers of SSRF protection (proxy.service.ts:92):
SSRF Protection Details
SSRF Protection Details
- Protocol validation — only HTTP/HTTPS allowed
- Hostname matching — target must match registered service
baseUrlhostname - Path prefix validation — target path must start with service
baseUrlpath - Private IP blocking — rejects 127.x, 10.x, 192.168.x, 172.16-31.x, 169.254.x, ::1, fc00:, fe80:
- Localhost blocking — rejects
localhosthostname
Trust Boundaries
GaiterGuard enforces two critical trust boundaries:1. Agent ↔ Gateway
- Agent-Key authentication — SHA-256 hashed keys in
agentstable - Service scoping — agents can only access explicitly granted services
- Intent logging — every request logs stated intent for audit trail
2. Gateway ↔ Target API
- Credential isolation — agents never see real credentials
- Request validation — SSRF checks prevent unauthorized target access
- Response sanitization — 10MB size limit prevents memory exhaustion
The gateway is the single point of trust enforcement. Compromising an agent does not grant access to production credentials or unauthorized services.
Related Concepts
Security Model
Learn how secrets are encrypted and scoped to agents
Risk Assessment
Understand the LLM-based risk scoring system
Approval Flow
Explore the state machine and TTL expiration