Overview
GaiterGuard’s security model is built on three pillars:- Encrypted vault — secrets encrypted at rest with AES-256-GCM
- Agent-key scoping — agents can only access explicitly granted services
- Trust boundaries — gateway enforces isolation between agents and credentials
Encrypted Vault
Encryption Algorithm
GaiterGuard uses AES-256-GCM (Galois/Counter Mode) for authenticated encryption:- Key size: 256 bits (32 bytes)
- IV size: 128 bits (16 bytes, randomly generated per operation)
- Authentication: GCM mode provides built-in authentication tag
- Key derivation: scrypt with configurable salt
Implementation
The encryption service is implemented inbackend/src/services/encryption.service.ts:
Storage Format
Encrypted credentials are stored in thecredentials table with format:
Why GCM mode? AES-GCM provides authenticated encryption, which detects tampering. If someone modifies the ciphertext, the authentication tag verification will fail during decryption.
Decryption Process
Decryption verifies the authentication tag to detect corruption or tampering:Key Management
The encryption key is derived at server startup inserver.ts:191:
Environment Variables
Required configuration in.env:
backend/src/config/env.ts:28:
Agent-Key Authentication
Key Generation
Agent keys are 32-byte cryptographically random values generated via Node.js crypto:gg_a1b2c3d4e5f6... (67 characters total)
Key Storage
Only the SHA-256 hash of the key is stored in the database:agents table schema (backend/src/db/schema.ts:73):
The full API key is returned only once when the agent is created. If lost, a new agent must be created.
Authentication Flow
Agent authentication is handled by middleware (backend/src/middleware/auth.ts):
- Extract
Agent-Keyheader from request - Hash the provided key with SHA-256
- Look up agent by
keyHashin database - Verify agent is active (
isActive = true) - Update
lastUsedAttimestamp
Service Scoping
Agent-Service Association
Agents are granted access to specific services via theagent_services join table:
Access Enforcement
When an agent makes a proxy request, the gateway validates access inproxy.service.ts:169:
Updating Agent Scope
Service associations can be updated via the dashboard API:agent.service.ts:297).
Credential Injection
Credentials are decrypted and injected only at request time, never returned to the agent.Supported Authentication Types
The gateway supports four auth types (proxy.service.ts:212):
- Bearer Token
- API Key
- Basic Auth
- OAuth2
tokenCredential Storage
Credentials are stored via the dashboard API:credentials table.
Auth Header Stripping
Before storing blocked requests in the approval queue, auth headers are stripped (proxy.service.ts:408):
Trust Boundaries
1. Agent ↔ Gateway Boundary
Enforced by:- Agent-Key authentication (SHA-256 hashed)
- Service scoping (agent_services table)
- SSRF validation (hostname and path checks)
- Agents can only access services explicitly granted
- Agents cannot forge requests to unauthorized services
- Agents cannot access other agents’ approval actions
2. Gateway ↔ Vault Boundary
Enforced by:- AES-256-GCM encryption at rest
- Key derivation from ENCRYPTION_SECRET
- Runtime-only decryption (never stored decrypted)
- Credentials are encrypted in database
- Decryption key never leaves server memory
- Tampering detected via authentication tag
3. Gateway ↔ Target API Boundary
Enforced by:- 30-second request timeout
- 10MB response size limit
- Manual redirect handling (disabled)
- Private IP blocking
- No SSRF attacks to internal networks
- No unbounded memory consumption
- No credential leakage via redirects
Attack Scenarios
Scenario 1: Agent Key Compromise
Attack: Attacker steals an agent key Mitigation:- Agent can only access services it’s scoped to
- All requests are logged with
agentIdfor audit trail - High-risk requests require human approval (can’t be bypassed)
- Revoke agent via dashboard (
isActive = false)
Scenario 2: Database Breach
Attack: Attacker gains read access to PostgreSQL database Mitigation:- Credentials are AES-256-GCM encrypted
- Agent keys are SHA-256 hashed (not reversible)
- Encryption key (
ENCRYPTION_SECRET) not stored in database - Without encryption key, credentials are unreadable
Scenario 3: SSRF Attempt
Attack: Agent tries to access internal network viatargetUrl
Mitigation:
- Target hostname must match service
baseUrlhostname - Private IP ranges blocked (127.x, 10.x, 192.168.x, etc.)
- Localhost access blocked
- Target path must start with service
baseUrlpath
Scenario 4: Intent Mismatch
Attack: Agent states benign intent but sends malicious payload Mitigation:- LLM risk assessor compares intent to actual request
- Intent integrity check flags mismatches
- Mismatched requests blocked with 428 status
- Human reviews full context before approval
Security Best Practices
Rotate Encryption Keys
Rotate Encryption Keys
To rotate the
ENCRYPTION_SECRET:- Deploy new instance with new secret
- Re-upload all service credentials via dashboard
- Old instance’s encrypted data becomes unreadable
Audit Agent Activity
Audit Agent Activity
All proxy requests are logged in the
proxy_requests table:Revoke Compromised Agents
Revoke Compromised Agents
If an agent key is compromised:All subsequent requests with that key will be rejected.
Monitor Approval Queue
Monitor Approval Queue
High volumes of risk-blocked requests may indicate:
- Agent malfunction or misconfiguration
- Threshold too low (
RISK_THRESHOLD< 0.5) - LLM hallucination or overly sensitive rules
approval_queue table for patterns.Related Concepts
Architecture
See how encryption integrates with the gateway
Risk Assessment
Understand intent integrity checking