Skip to main content

Security Model Overview

Core Security Principle: Agent intent is untrusted until it survives validation, risk evaluation, policy checks, and signing-boundary controls.
Agentic Wallet implements defense-in-depth through multiple isolated trust boundaries. No single component has full system authority.

Trust Boundaries

1. Agent Boundary

Principle: Agents Express Intents Only

Agents cannot construct raw transactions, access private keys, or bypass policy gates.
What Agents CAN Do:
  • Submit high-level intents (e.g., swap, transfer_sol, create_escrow)
  • Query wallet balance, positions, and transaction history
  • Receive execution results and proofs
What Agents CANNOT Do:
  • Read private keys or seed phrases
  • Sign transactions directly
  • Submit raw transaction bytes to RPC
  • Bypass policy or risk evaluation
  • Access other wallets without explicit authorization
Enforcement:
1

API Gateway

All agent requests enter through API gateway with authentication and rate limiting
2

Intent Validation

Transaction-engine validates intent schema with Zod before processing
3

Capability Manifest

Agent-runtime checks intent and protocol allowlists (and optional signed manifest)
4

Signing Isolation

Only wallet-engine can sign; agents never receive key material
Threat Mitigation:
  • ✓ Malicious agent cannot exfiltrate keys
  • ✓ Compromised agent limited to allowlisted intents
  • ✓ Agent cannot drain wallet beyond budget limits

2. Signing Boundary

Principle: Only Wallet-Engine Signs

The wallet-engine is the sole trusted signer. No other service or agent can sign transactions.
Boundary Implementation:
Access Control:
  • Signing API: POST /api/v1/wallets/:walletId/sign
  • Caller: Only transaction-engine (internal service-to-service)
  • Payload: Unsigned transaction (base64)
  • Response: Signed transaction (base64) + signature
Key Provider Backends:

encrypted-file

Development
  • AES-256-GCM encryption
  • Keys persisted to disk
  • Single encryption secret

memory

Testing
  • Ephemeral in-memory storage
  • Lost on restart
  • No encryption needed

kms

Production (Cloud)
  • Centralized key management
  • HSM-backed storage
  • Access logging & rotation
  • Requires: WALLET_KMS_MASTER_SECRET

hsm

Production (On-Prem)
  • Hardware security module
  • FIPS 140-2 compliance
  • Physical tamper resistance
  • Requires: WALLET_HSM_PIN, WALLET_HSM_MODULE_SECRET

mpc

Production (Distributed)
  • Multi-party computation
  • Threshold signatures (2-of-3)
  • No single key holder
  • Requires: 3 node secrets
Threat Mitigation:
  • ✓ Key exfiltration requires compromising wallet-engine process
  • ✓ Signing requires valid wallet ID (no blind signing)
  • ✓ Backend abstraction allows security upgrades without code changes

3. Policy Boundary

Principle: All Spend-Capable Intents Must Pass Policy

No transaction is signed until policy-engine returns allow (or manual approval completes).
Fail-Secure Design:
Policy Evaluation Flow:
1

Fetch Active Policies

Policy-engine retrieves all active policies for wallet
2

Execute Rules

Evaluate each rule in sequence:
  • spending_limit: Check transaction amount vs limits
  • rate_limit: Check transaction count in time window
  • address_allowlist: Verify destination is permitted
  • program_allowlist: Verify program IDs are permitted
  • token_allowlist: Verify token mint is permitted
  • protocol_allowlist: Verify protocol is permitted
  • max_slippage: Verify slippage under threshold
  • protocol_risk: Verify protocol-specific risk parameters
  • portfolio_risk: Verify portfolio exposure limits
3

Aggregate Decision

  • If any rule returns deny → final decision is deny
  • If any rule returns require_approval → final decision is require_approval (unless another rule denies)
  • If all rules return allow → final decision is allow
4

Return Decision

Approval Gate: When policy returns require_approval:
  1. Transaction pauses at approval_gate status
  2. Stored in pending approvals table with 24h expiry
  3. Operator must explicitly approve or reject:
    • POST /api/v1/transactions/:txId/approve → proceeds to signing
    • POST /api/v1/transactions/:txId/reject → marks as failed
Threat Mitigation:
  • ✓ Prevents over-spending beyond configured limits
  • ✓ Prevents unauthorized destination addresses
  • ✓ Prevents interaction with malicious programs
  • ✓ Requires manual approval for high-risk transactions
  • ✓ Policy bypass requires compromising policy-engine (isolated service)

4. Protocol Boundary

Principle: Protocol Logic Isolated in Adapters

Protocol-specific transaction building is isolated in protocol-adapters service with registry pattern.
Adapter Registry Pattern:
Isolation Benefits:
If external protocol API (e.g., Jupiter quote API) fails:
  • Adapter returns error
  • Transaction-engine marks transaction as failed
  • No synthetic success or stale quotes used
Each adapter declares its program IDs:
Policy rules can enforce:
Adapters support version migrations:
Ensures backward compatibility when protocols change.
Each adapter can implement health checks:
Enables pre-flight validation of protocol availability.
Escrow Program (Real Anchor Program): The escrow adapter is backed by a real on-chain Anchor program, not memo placeholders:
  • Program location: programs/escrow/
  • Instructions: create_escrow, accept_escrow, release_escrow, refund_escrow, dispute_escrow, resolve_dispute, create_milestone_escrow, release_milestone, x402_pay
  • Deployed to devnet: npm run escrow:deploy:devnet
  • Program ID stored in .env: ESCROW_PROGRAM_ID=<deployed_id>
Threat Mitigation:
  • ✓ Protocol vulnerabilities isolated to single adapter
  • ✓ Adapter upgrades don’t affect other protocols
  • ✓ Program ID allowlists prevent malicious program interaction
  • ✓ Health checks detect deployment/configuration issues early

Gateway Boundary

Principle: Single Entry Point with Layered Controls

All external requests enter through API Gateway with authentication, authorization, and rate limiting.

Authentication

API Key Header: x-api-key
Format: apiKey:tenant:scopes Enforcement:

Authorization

Scope-Based Access Control: Enforcement:

Tenant Isolation (Optional)

Tenant Header: x-tenant-id
Enables multi-tenant deployments where API keys are scoped to specific tenants.

Rate Limiting

Per-Key Rate Limit:
Sliding Window:

Response Normalization

Stable Machine Envelope: All responses normalized to:
Benefits:
  • Consistent error handling across all endpoints
  • Deterministic error codes for programmatic handling
  • Trace IDs for debugging and audit correlation
  • Stage tracking for execution visibility
Threat Mitigation:
  • ✓ Prevents unauthorized API access
  • ✓ Limits API abuse via rate limiting
  • ✓ Provides tenant isolation for multi-tenant deployments
  • ✓ Normalizes error responses to prevent information leakage

Input Validation Boundary

Principle: Strict Schema Validation at Every Service Edge

All public APIs validate inputs with Zod schemas before processing.
Schema Validation Example:
Validated Entities:
  • Transaction requests (type, protocol, intent fields)
  • Policy rules (discriminated unions by rule type)
  • Agent configurations (capabilities, execution modes)
  • Risk configurations (protocol risk, portfolio risk)
  • Capability manifests (signature verification)
Threat Mitigation:
  • ✓ Prevents injection attacks (SQL, NoSQL, command injection)
  • ✓ Prevents type confusion attacks
  • ✓ Rejects malformed payloads at service edge
  • ✓ Ensures downstream code operates on clean, typed data

Capability Manifest Boundary

Principle: Signed Manifests Enforce Runtime Permissions

Agents can be issued signed capability manifests that restrict intents and protocols at runtime.
Manifest Structure:
Issuance:
Verification:
Signature:
Runtime Enforcement:
When enabled, all agent executions require a valid manifest. Threat Mitigation:
  • ✓ Prevents agent privilege escalation
  • ✓ Time-bound permissions (manifest expiry)
  • ✓ Cryptographic proof of authorization
  • ✓ Runtime revocation by rotating AGENT_MANIFEST_SIGNING_SECRET

Delta Guard Boundary

Principle: Post-Execution Balance Verification

After transaction confirmation, verify actual balance change matches expected delta.
Purpose: Detect silent execution failures, sandwich attacks, or unexpected fees. Calculation:
Configuration:
Auto-Pause on Breach:
If delta guard fails and autoPauseOnBreach is enabled:
  • Agent is automatically paused
  • Webhook notification sent (if configured)
  • Audit event emitted
Threat Mitigation:
  • ✓ Detects MEV sandwich attacks
  • ✓ Detects unexpected fee drains
  • ✓ Detects silent transaction failures with partial execution
  • ✓ Provides post-execution safety net

Audit & Observability Boundary

Principle: Immutable Audit Log with Execution Proofs

Every transaction generates an immutable audit trail and cryptographic execution proof.

Execution Proof

Generated on Confirmation:
Properties:
  • Deterministic: Same inputs always produce same hashes
  • Tamper-Evident: Any modification changes proofHash
  • Replayable: Proof can be regenerated from stored inputs
Retrieval:

Audit Event Stream

Event Types:
  • tx_status: Transaction status changes
  • protocol_risk_decision: Protocol risk evaluation result
  • policy_decision: Policy evaluation result
  • execution_proof: Execution proof generated
  • execution_proof_failed: Failure proof generated
  • agent_paused: Agent auto-paused
  • delta_guard_breach: Delta guard violation
Event Schema:
Query:
Threat Mitigation:
  • ✓ Provides forensic evidence for security incidents
  • ✓ Enables compliance audits
  • ✓ Detects unauthorized access patterns
  • ✓ Supports dispute resolution with cryptographic proofs

Threat Model Summary

Assets to Protect

  1. Wallet Private Keys → Protected by signing boundary
  2. Signing Capability → Protected by wallet-engine isolation
  3. Policy Integrity → Protected by policy-engine isolation
  4. Transaction Finality → Protected by RPC failover and outbox durability
  5. Audit Artifacts → Protected by immutable audit log and execution proofs
  6. API Credentials → Protected by gateway authentication and scoping

Attack Scenarios & Mitigations

Attack: Compromised agent attempts to read private keysMitigation:
  • ✓ Agent boundary: No key access via API
  • ✓ Signing boundary: Keys never leave wallet-engine
  • ✓ Network isolation: Agent cannot connect to wallet-engine directly
Attack: Agent attempts to bypass policy evaluationMitigation:
  • ✓ Policy boundary: All transactions flow through policy gate
  • ✓ Fail-secure: Policy-engine unreachable → deny
  • ✓ Approval gate: High-risk transactions require manual approval
Attack: Agent attempts to spend beyond budget or policy limitsMitigation:
  • ✓ Budget enforcement: Agent-runtime checks budget before execution
  • ✓ Policy rules: Spending limits enforced at policy gate
  • ✓ Portfolio risk: Portfolio-level exposure limits
  • ✓ Auto-pause: Agent paused on budget breach
Attack: Agent attempts to interact with malicious Solana programMitigation:
  • ✓ Protocol boundary: Adapters declare program IDs
  • ✓ Program allowlists: Policy rules enforce allowed programs
  • ✓ Health checks: Detect misconfigured or unavailable protocols
Attack: Front-runner extracts value from agent’s swapMitigation:
  • ✓ Slippage controls: Protocol risk limits max slippage
  • ✓ Delta guard: Post-execution balance verification
  • ✓ Auto-pause: Agent paused on unexpected balance change
Attack: Attacker replays captured transactionMitigation:
  • ✓ Idempotency keys: Deduplicate identical requests
  • ✓ Blockhash expiry: Solana transactions expire after ~60s
  • ✓ Durable outbox: Lease mechanism prevents double execution
Attack: Attacker floods API with requestsMitigation:
  • ✓ Rate limiting: 120 req/min per API key
  • ✓ Authentication: Invalid API keys rejected
  • ✓ Scope enforcement: API keys restricted to specific operations

Production Hardening Checklist

1

Key Management

  • Use kms, hsm, or mpc backend (not encrypted-file)
  • Rotate WALLET_KEY_ENCRYPTION_SECRET regularly
  • Enable access logging for signing operations
  • Implement key rotation policy
2

Authentication

  • Set API_GATEWAY_ENFORCE_AUTH=true
  • Generate strong, unique API keys per client
  • Use tenant isolation (x-tenant-id)
  • Rotate API keys on compromise
3

Network Security

  • Deploy services in private network (no public IPs)
  • Use TLS for all service-to-service communication
  • Enable firewall rules (allow only necessary ports)
  • Use VPN or bastion host for operator access
4

Policy Enforcement

  • Enable AGENT_REQUIRE_MANIFEST=true
  • Enable AGENT_REQUIRE_BACKTEST_PASS=true
  • Configure spending limits for all wallets
  • Configure rate limits for all wallets
  • Use address/program allowlists
5

Monitoring

  • Set up audit log monitoring
  • Alert on delta guard breaches
  • Alert on agent auto-pause events
  • Monitor RPC health and failover
  • Track transaction confirmation latency
6

Disaster Recovery

  • Backup wallet-engine database regularly
  • Test key recovery from backups
  • Document incident response procedures
  • Maintain offline key recovery mechanism

Security Posture Summary

Preventive Controls

  • API authentication
  • Policy gates
  • Signing boundary
  • Input validation
  • Rate limiting

Detective Controls

  • Audit event stream
  • Delta guard checks
  • RPC health monitoring
  • Execution proofs

Corrective Controls

  • Agent auto-pause
  • Transaction retry
  • RPC failover
  • Manual approval gate
  • Durable outbox recovery

Next Steps

Architecture Overview

Return to high-level architecture overview

API Reference

Explore API endpoints with security context