Security Model Overview
Core Security Principle: Agent intent is untrusted until it survives validation, risk evaluation, policy checks, and signing-boundary controls.
Trust Boundaries
1. Agent Boundary
Principle: Agents Express Intents Only
Agents cannot construct raw transactions, access private keys, or bypass policy gates.
- Submit high-level intents (e.g.,
swap,transfer_sol,create_escrow) - Query wallet balance, positions, and transaction history
- Receive execution results and proofs
- 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
Capability Manifest
Agent-runtime checks intent and protocol allowlists (and optional signed manifest)
- ✓ 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.
- 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
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
- ✓ 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).Execute Rules
Evaluate each rule in sequence:
spending_limit: Check transaction amount vs limitsrate_limit: Check transaction count in time windowaddress_allowlist: Verify destination is permittedprogram_allowlist: Verify program IDs are permittedtoken_allowlist: Verify token mint is permittedprotocol_allowlist: Verify protocol is permittedmax_slippage: Verify slippage under thresholdprotocol_risk: Verify protocol-specific risk parametersportfolio_risk: Verify portfolio exposure limits
Aggregate Decision
- If any rule returns
deny→ final decision isdeny - If any rule returns
require_approval→ final decision isrequire_approval(unless another rule denies) - If all rules return
allow→ final decision isallow
require_approval:
- Transaction pauses at
approval_gatestatus - Stored in pending approvals table with 24h expiry
- Operator must explicitly approve or reject:
POST /api/v1/transactions/:txId/approve→ proceeds to signingPOST /api/v1/transactions/:txId/reject→ marks as failed
- ✓ 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.
1. Fail-Closed Quotes
1. Fail-Closed Quotes
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
2. Program ID Allowlists
2. Program ID Allowlists
Each adapter declares its program IDs:Policy rules can enforce:
3. Version Migrations
3. Version Migrations
Adapters support version migrations:Ensures backward compatibility when protocols change.
4. Health Checks
4. Health Checks
Each adapter can implement health checks:Enables pre-flight validation of protocol availability.
- 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>
- ✓ 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
apiKey:tenant:scopes
Enforcement:
Authorization
Scope-Based Access Control:| Route Pattern | Required Scope |
|---|---|
/api/v1/wallets/** | wallets |
/api/v1/transactions/** | transactions |
/api/v1/policies/** | policies |
/api/v1/agents/** | agents |
/api/v1/protocols/** | protocols |
/api/v1/risk/** | risk |
/api/v1/audit/** | audit |
/mcp/** | mcp |
Tenant Isolation (Optional)
Tenant Header:x-tenant-id
Rate Limiting
Per-Key Rate Limit:Response Normalization
Stable Machine Envelope: All responses normalized to:- Consistent error handling across all endpoints
- Deterministic error codes for programmatic handling
- Trace IDs for debugging and audit correlation
- Stage tracking for execution visibility
- ✓ 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.
- 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)
- ✓ 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.
- ✓ 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.
autoPauseOnBreach is enabled:
- Agent is automatically paused
- Webhook notification sent (if configured)
- Audit event emitted
- ✓ 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:- Deterministic: Same inputs always produce same hashes
- Tamper-Evident: Any modification changes
proofHash - Replayable: Proof can be regenerated from stored inputs
Audit Event Stream
Event Types:tx_status: Transaction status changesprotocol_risk_decision: Protocol risk evaluation resultpolicy_decision: Policy evaluation resultexecution_proof: Execution proof generatedexecution_proof_failed: Failure proof generatedagent_paused: Agent auto-pauseddelta_guard_breach: Delta guard violation
- ✓ 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
- Wallet Private Keys → Protected by signing boundary
- Signing Capability → Protected by wallet-engine isolation
- Policy Integrity → Protected by policy-engine isolation
- Transaction Finality → Protected by RPC failover and outbox durability
- Audit Artifacts → Protected by immutable audit log and execution proofs
- API Credentials → Protected by gateway authentication and scoping
Attack Scenarios & Mitigations
Malicious Agent Exfiltration
Malicious Agent Exfiltration
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
Policy Bypass
Policy Bypass
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
Unauthorized Spending
Unauthorized Spending
Malicious Protocol Interaction
Malicious Protocol Interaction
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
Sandwich Attack (MEV)
Sandwich Attack (MEV)
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
Replay Attack
Replay Attack
Attack: Attacker replays captured transactionMitigation:
- ✓ Idempotency keys: Deduplicate identical requests
- ✓ Blockhash expiry: Solana transactions expire after ~60s
- ✓ Durable outbox: Lease mechanism prevents double execution
API Abuse
API Abuse
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
Key Management
- Use
kms,hsm, ormpcbackend (notencrypted-file) - Rotate
WALLET_KEY_ENCRYPTION_SECRETregularly - Enable access logging for signing operations
- Implement key rotation policy
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
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
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
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
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