Skip to main content

Security Architecture

Conto implements multiple layers of security to protect AI agent financial operations.

Authentication

SDK Keys

SDK keys authenticate AI agents making payment requests.
Format: conto_agent_{random_32_bytes_hex}
Example: conto_agent_a1b2c3d4e5f6...
Key Properties:
  • Cryptographically random (32 bytes entropy)
  • Hashed before storage (SHA-256)
  • Scoped to specific agent
  • Support expiration dates
  • Can be instantly revoked
Security Measures:
  • Keys shown only once at creation
  • Only key prefix stored for identification
  • Rate limited per key
  • Usage tracking and anomaly detection

API Keys

Organization-level API keys for dashboard and management access.
Format: conto_{random_32_bytes_hex}
Example: conto_x7y8z9...
Scope System:
ScopeDescription
agents:readView agent data
agents:writeModify agents
wallets:readView wallet data
wallets:writeModify wallets
transactions:readView transactions
policies:readView policies
policies:writeModify policies
adminFull access

Session Authentication

Dashboard users authenticate via NextAuth.js:
  • OAuth Providers: Google, GitHub
  • Email/Password: With bcrypt hashing
  • Session Storage: HTTP-only cookies
  • CSRF Protection: Built-in token validation

Encryption

At Rest

Database Encryption:
  • PostgreSQL with TLS connections
  • Sensitive fields encrypted at application layer
  • AES-256-GCM for symmetric encryption
Wallet Private Keys:
// Encryption approach
const encrypted = await encryptPrivateKey(privateKey, ENCRYPTION_KEY);
// Stored as: iv:authTag:ciphertext (base64)
In production, use a Hardware Security Module (HSM) or cloud KMS (AWS KMS, Google Cloud KMS) for key management.

In Transit

  • All API traffic over HTTPS (TLS 1.3)
  • Certificate pinning for mobile clients
  • Strict Transport Security headers

Authorization

Role-Based Access Control (RBAC)

Organization member roles:
RoleCapabilities
OWNERFull access, billing, delete org
ADMINManage agents, wallets, policies
MANAGERView all, manage assigned agents
VIEWERRead-only access

Policy-Based Authorization

Payment authorization flows through the policy engine:
Payment Request

┌─────────────────┐
│ Authentication  │ → Is SDK key valid?
└────────┬────────┘

┌─────────────────┐
│ Authorization   │ → Does agent have wallet access?
└────────┬────────┘

┌─────────────────┐
│ Policy Engine   │ → Do policies allow this payment?
└────────┬────────┘

┌─────────────────┐
│ Spend Limits    │ → Is agent within limits?
└────────┬────────┘

    APPROVED / DENIED

Rate Limiting

Protects against abuse and ensures fair usage.

Limits by Endpoint Type

EndpointLimitWindow
SDK Payments60 requestsper minute
SDK Read120 requestsper minute
API Write100 requestsper minute
API Read100 requestsper minute

Implementation

// Redis-based sliding window rate limiting
const result = await rateLimit(agentId, {
  limit: 60,
  window: '1m',
  identifier: `sdk:${agentId}`
});

if (!result.allowed) {
  return Response.json(
    { error: 'Rate limited', retryAfter: result.retryAfter },
    { status: 429 }
  );
}

Response Headers

X-RateLimit-Remaining: 45
X-RateLimit-Reset: 2024-01-15T10:01:00.000Z
Retry-After: 30

Input Validation

All inputs validated using Zod schemas:
const PaymentRequestSchema = z.object({
  amount: z.number().positive().max(1_000_000),
  recipientAddress: z.string().regex(/^0x[a-fA-F0-9]{40}$/),
  recipientName: z.string().max(100).optional(),
  purpose: z.string().max(500).optional(),
  category: z.enum(['API_PROVIDER', 'CLOUD_SERVICES', ...]).optional(),
});

Protection Against

  • SQL Injection: Parameterized queries via Prisma
  • XSS: Input sanitization, CSP headers
  • CSRF: Token validation on mutations
  • Path Traversal: Input validation, no file system access

Audit Logging

Comprehensive audit trail for compliance and forensics.

Logged Events

CategoryEvents
AuthenticationLogin, logout, key creation/revocation
AgentsCreate, update, suspend, revoke
WalletsCreate, freeze, link to agent
TransactionsRequest, approve, execute, confirm
PoliciesCreate, update, delete, apply
SettingsOrganization changes, role updates

Audit Log Schema

{
  id: "audit_abc123",
  timestamp: "2024-01-15T14:30:00Z",
  action: "PAYMENT_EXECUTED",
  actorType: "AGENT",  // AGENT, USER, SYSTEM
  actorId: "agt_xyz789",
  resource: "transaction",
  resourceId: "tx_abc123",
  organizationId: "org_123",
  ipAddress: "203.0.113.1",
  userAgent: "Conto-SDK/1.0.0",
  metadata: {
    amount: 50,
    recipient: "0x...",
    policyResult: "ALLOWED"
  }
}

Retention

  • Active logs: 90 days hot storage
  • Archived logs: 7 years cold storage (compliance)
  • Immutable once written

Network Security

Infrastructure

  • WAF: Web Application Firewall (Cloudflare/Vercel)
  • DDoS Protection: Automatic mitigation
  • IP Allowlisting: Available for enterprise
  • VPC Isolation: Database in private subnet

Headers

Strict-Transport-Security: max-age=31536000; includeSubDomains
Content-Security-Policy: default-src 'self'
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Referrer-Policy: strict-origin-when-cross-origin

Blockchain Security

Transaction Safety

  • Atomic Operations: Database + blockchain in sync
  • Nonce Management: Prevent transaction replay
  • Gas Estimation: Prevent failed transactions
  • Balance Verification: Before every transaction

Smart Contract Interaction

// Only interact with verified stablecoin contracts
const stablecoin = getContract({
  address: STABLECOIN_ADDRESS,
  abi: STABLECOIN_ABI,
  client: publicClient,
});

Incident Response

Detection

  • Real-time anomaly detection
  • Unusual spending pattern alerts
  • Failed authentication monitoring
  • Rate limit breach alerts

Response Playbook

  1. Contain: Suspend affected agents/keys
  2. Assess: Review audit logs
  3. Remediate: Revoke compromised credentials
  4. Recover: Restore from known-good state
  5. Review: Post-incident analysis

Emergency Actions

# Suspend agent immediately
curl -X POST https://conto.finance/api/agents/{id}/suspend \
  -H "Authorization: Bearer $ADMIN_KEY"

# Revoke all SDK keys for agent
curl -X DELETE https://conto.finance/api/agents/{id}/sdk-keys/all \
  -H "Authorization: Bearer $ADMIN_KEY"

# Freeze wallet
curl -X POST https://conto.finance/api/wallets/{id}/freeze \
  -H "Authorization: Bearer $ADMIN_KEY"

Compliance

Standards

  • SOC 2 Type II: In progress
  • GDPR: Data protection controls
  • OFAC: Sanctions screening integration

Data Handling

Data TypeRetentionEncryption
Transaction history7 yearsAES-256
Audit logs7 yearsAt rest
User PIIWhile activeAES-256
API keysUntil revokedSHA-256 (hashed)
Session data24 hoursHTTP-only cookies

Security Best Practices

Reporting Vulnerabilities

If you discover a security vulnerability:
  1. Do not open a public GitHub issue
  2. Email security@conto.finance
  3. Include detailed reproduction steps
  4. We’ll respond within 24 hours
We offer a bug bounty program for qualifying vulnerabilities.