Skip to main content
AI Agents Need Service Accounts, Not Root AccessGeneral
5 min readFor Security Engineers

AI Agents Need Service Accounts, Not Root Access

Google's Customer Support & Returns Agent can issue refunds. Without proper controls, it could process a $10,000 refund instead of $149. You wouldn't give a contractor root access to your production database. Don't give an AI agent unrestricted permissions either.

This guide walks you through implementing zero-trust controls for AI agents that interact with sensitive systems. Bookmark it for your next AI integration project.

Scope - What This Guide Covers

This guide focuses on security controls for AI agents that:

  • Execute database transactions
  • Generate and run code
  • Access customer data or financial systems
  • Make decisions that affect business operations

If you're deploying AI agents in production environments where mistakes cost money or expose data, these controls apply to your architecture.

Key Concepts and Definitions

AI Agent: An autonomous system that makes decisions and takes actions without human intervention for each step. Different from traditional automation because the agent determines its own sequence of operations.

Zero-Trust for AI: A security model where you verify and limit every action an AI agent attempts. The agent proves its identity, requests permission for each operation, and executes in an isolated environment.

Cryptographic Attribution: Using digital signatures to create an auditable record of which agent requested which operation. You can detect tampering and trace actions back to specific agent identities.

Semantic Gateway: A control layer that validates whether an agent's requested action matches its authorized scope. It's not just checking permissions, it's evaluating whether the action makes sense given the agent's role.

Requirements Breakdown

Identity and Authentication

Assign each agent its own service account with signing permissions on an asymmetric key in Cloud KMS (or your equivalent key management system). Don't share keys between agents.

Your implementation needs:

  • One service account per agent instance
  • Asymmetric key pairs (not symmetric keys)
  • Key rotation policy (30-90 days recommended)
  • Audit logging for all key operations

This maps to NIST 800-53 Rev 5 control IA-2 (Identification and Authentication) and IA-5 (Authenticator Management).

Transaction Signing

Every database operation the agent requests must include a cryptographic signature. Your backend verifies the signature before executing the transaction.

The signature should cover:

  • Operation type (INSERT, UPDATE, DELETE)
  • Affected table and record IDs
  • Timestamp
  • Agent identity

If the signature fails verification, reject the operation and alert your security team. Log the attempt with full context.

Code Execution Sandboxing

When your agent generates code, run it in an isolated environment like gVisor. The sandbox prevents:

  • Network access to internal systems
  • File system writes outside designated directories
  • Process spawning beyond resource limits
  • Access to secrets or credentials

Configure resource limits before you deploy:

  • CPU: 1-2 cores maximum
  • Memory: 512MB-2GB depending on workload
  • Execution timeout: 30-60 seconds
  • No outbound network by default

Semantic Validation

Before executing an agent's request, validate it against business rules. Consider a refund request:

Request: Issue $10,000 refund
Original purchase: $149
Time since purchase: 3 days

Your Semantic Gateway checks:

  • Is refund amount ≤ original purchase?
  • Is request within return policy window?
  • Does agent have refund authority for this amount tier?

Reject requests that fail validation. Don't just log them, block execution.

Implementation Guidance

Step 1: Inventory Your Agent Actions

List every operation your agent can perform. For each operation, document:

  • Which database tables it touches
  • Maximum values it can write (dollar amounts, quantities)
  • Required approval thresholds
  • Rollback procedures

Step 2: Design Your Signing Flow

Your agent signs requests before sending them to your backend:

  1. Agent constructs operation payload
  2. Agent retrieves signing key from KMS
  3. Agent signs payload with private key
  4. Agent sends signed request to backend
  5. Backend verifies signature with public key
  6. Backend executes operation if signature valid

Store public keys in your backend service. Never give agents access to verify their own signatures.

Step 3: Configure Sandboxing

If you're running on Google Cloud, use gVisor. For AWS, consider Firecracker. For on-premises deployments, look at Kata Containers.

Your sandbox configuration:

resources:
  cpu: 1
  memory: 1Gi
  timeout: 30s
network:
  egress: deny
  ingress: deny
filesystem:
  writable: /tmp only
  readonly: /app, /lib

Step 4: Build Validation Rules

Start with hard limits:

  • Maximum refund: original purchase amount
  • Maximum quantity: current inventory
  • Maximum users affected: 1 per operation

Add business logic:

  • Refund windows (30 days, 90 days)
  • Approval requirements by dollar threshold
  • Geographic restrictions

Step 5: Implement Monitoring

Track these metrics:

  • Signature verification failures per hour
  • Sandbox execution timeouts
  • Semantic validation rejections by rule
  • Agent requests by operation type

Alert when you see:

  • More than 5 signature failures in 10 minutes
  • Any sandbox escape attempts
  • Unusual operation patterns (100 refunds in 1 hour)

Common Pitfalls

Sharing keys between agent instances: You lose attribution. When something goes wrong, you can't identify which agent caused it.

Skipping signature verification in development: You'll forget to enable it in production. Verify signatures in every environment.

Overly permissive sandboxes: "We'll tighten it later" never happens. Start restrictive, then relax specific constraints as needed.

Trusting agent self-assessment: Don't let the agent validate its own requests. The Semantic Gateway must run outside the agent's control.

Logging without alerting: Logs don't stop attacks in progress. Configure real-time alerts for signature failures and validation rejections.

Quick Reference Table

Control Technology Configuration Alert Threshold
Identity Service account per agent Asymmetric keys, 30-day rotation Key access from unexpected IP
Transaction signing Cloud KMS or equivalent SHA-256 signatures, public key verification >5 failures/10 min
Code sandboxing gVisor, Firecracker, Kata 1 CPU, 1GB RAM, 30s timeout, no network Any escape attempt
Semantic validation Custom gateway Business rules + hard limits Pattern anomalies
Audit logging SIEM integration All operations with signatures Gaps in log stream

Your AI agents will make mistakes. Zero-trust architecture ensures those mistakes don't become security incidents. Start with identity, add signing, isolate execution, and validate every request. The $10,000 refund scenario isn't hypothetical, it's what happens when you skip these controls.

Topics:General

You Might Also Like