惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
G
Google Developers Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
有赞技术团队
有赞技术团队
Vercel News
Vercel News
MongoDB | Blog
MongoDB | Blog
M
MIT News - Artificial intelligence
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog RSS Feed
I
InfoQ
Blog — PlanetScale
Blog — PlanetScale
博客园_首页
The Cloudflare Blog
B
Blog
C
Check Point Blog
Stack Overflow Blog
Stack Overflow Blog
IT之家
IT之家
U
Unit 42
D
Docker
月光博客
月光博客
aimingoo的专栏
aimingoo的专栏
博客园 - Franky
A
About on SuperTechFans

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
APPROVED_SPENDERS Policy: Control Which Contracts Your AI...
Wallet Guy · 2026-05-16 · via DEV Community

The biggest fear in AI agent development isn't that your bot will make bad trades—it's that it will drain your entire wallet by approving unlimited token access to malicious contracts. The APPROVED_SPENDERS policy in WAIaaS gives you surgical control over which contracts your AI agent can approve, preventing the classic "infinite approval" attack that has cost users millions.

Why Token Approvals Are the Biggest Security Risk

When your AI agent interacts with DeFi protocols, it needs to approve contracts to spend your tokens. Most wallets default to unlimited approvals for convenience—your agent approves a DEX to spend "infinite" USDC, then that approval stays forever. If the DEX gets hacked, exploited, or turns malicious, they can drain all your USDC instantly.

Traditional wallets make this worse by hiding approval amounts in tiny text or defaulting to maximum values. Your AI agent, operating autonomously, has no intuition about "this approval seems too high." It just follows its programming and approves whatever the protocol requests.

Default-Deny: Block Unlimited Approvals by Default

WAIaaS implements default-deny for token approvals through the APPROVED_SPENDERS policy. Without this policy configured, your AI agent cannot approve any contract to spend your tokens—transactions are blocked with POLICY_DENIED.

When you do configure APPROVED_SPENDERS, you specify exactly which contracts can receive approvals and set maximum amounts:

curl -X POST http://127.0.0.1:3100/v1/policies \
  -H "Content-Type: application/json" \
  -H "X-Master-Password: my-secret-password" \
  -d '{
    "walletId": "<wallet-uuid>",
    "type": "APPROVED_SPENDERS",
    "rules": {
      "spenders": [
        {
          "address": "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
          "name": "Uniswap Universal Router",
          "maxAmount": "1000000000"
        },
        {
          "address": "0xDEF1C0DED9bec7F1a1670819833240f027b25EfF",
          "name": "0x Protocol",
          "maxAmount": "500000000"
        }
      ]
    }
  }'

Enter fullscreen mode Exit fullscreen mode

This policy means your AI agent can only approve these two specific contracts, and only up to the specified amounts (in token base units). Any attempt to approve other contracts or exceed these limits gets blocked.

Layered Security: Approval Amount + Spending Tier

APPROVED_SPENDERS works alongside other WAIaaS policies for defense in depth. Even if a spender is whitelisted, large approvals can still trigger higher security tiers:

# First, create the APPROVED_SPENDERS whitelist
curl -X POST http://127.0.0.1:3100/v1/policies \
  -H "Content-Type: application/json" \
  -H "X-Master-Password: my-secret-password" \
  -d '{
    "walletId": "<wallet-uuid>",
    "type": "APPROVED_SPENDERS",
    "rules": {
      "spenders": [
        {
          "address": "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
          "name": "Uniswap Universal Router",
          "maxAmount": "10000000000"
        }
      ]
    }
  }'

# Then, set approval-specific spending limits
curl -X POST http://127.0.0.1:3100/v1/policies \
  -H "Content-Type: application/json" \
  -H "X-Master-Password: my-secret-password" \
  -d '{
    "walletId": "<wallet-uuid>",
    "type": "APPROVE_AMOUNT_LIMIT",
    "rules": {
      "instant_max_usd": 50,
      "notify_max_usd": 200,
      "delay_max_usd": 1000,
      "delay_seconds": 300,
      "block_unlimited": true
    }
  }'

Enter fullscreen mode Exit fullscreen mode

Now your AI agent can approve Uniswap, but:

  • Approvals ≤ $50 USD: Execute instantly
  • $50-200: Execute with notification
  • $200-1000: 5-minute delay (cancellable by you)
  • >$1000: Requires your explicit approval
  • Unlimited approvals: Blocked entirely

Human-in-the-Loop for High-Risk Approvals

For approvals that exceed your comfort zone, WAIaaS queues them for human approval. You get notified via your preferred channel and can approve or reject:

# Your AI agent tries to approve $2000 worth of tokens
# WAIaaS blocks it and sends you a notification:
{
  "status": "PENDING_APPROVAL",
  "reason": "APPROVE_AMOUNT_LIMIT policy requires approval for $2000 > $1000 limit",
  "action": "Approve Uniswap Universal Router to spend 2000 USDC",
  "approve_url": "https://walletconnect.app/...",
  "expires_at": "2026-05-15T10:30:00Z"
}

Enter fullscreen mode Exit fullscreen mode

You can approve via WalletConnect, sign a message, or use the Admin Web UI. If you don't respond within the timeout, the approval is automatically rejected.

Contract Reputation and Verification

APPROVED_SPENDERS integrates with WAIaaS's ERC-8004 Trustless Agents system for onchain contract reputation. You can set minimum reputation thresholds:

{
  "spenders": [
    {
      "address": "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
      "name": "Uniswap Universal Router",
      "maxAmount": "1000000000",
      "min_reputation": 850,
      "require_verification": true
    }
  ]
}

Enter fullscreen mode Exit fullscreen mode

This blocks approvals to contracts below reputation threshold 850 or without verified source code, even if they're on your whitelist.

Monitoring and Kill Switch

All approval transactions flow through WAIaaS's 7-stage pipeline with full audit logging:

# Check recent approvals
curl http://127.0.0.1:3100/v1/transactions \
  -H "Authorization: Bearer wai_sess_<token>" \
  -G -d "type=APPROVE&limit=10"

# Emergency: revoke all active approvals
curl -X POST http://127.0.0.1:3100/v1/emergency/revoke-all-approvals \
  -H "X-Owner-Signature: <signature>" \
  -H "X-Owner-Message: <signed-message>"

Enter fullscreen mode Exit fullscreen mode

The kill switch immediately sends zero-amount approval transactions to revoke all active approvals, effectively cutting off malicious contracts from your funds.

Quick Start: Lock Down Your Agent's Approvals

Here's how to implement approval security for your AI trading agent in under 5 minutes:

1. Start WAIaaS with Docker

git clone https://github.com/minhoyoo-iotrust/WAIaaS.git
cd WAIaaS
docker compose up -d

Enter fullscreen mode Exit fullscreen mode

2. Create wallet and session

npm install -g @waiaas/cli
waiaas quickset --mode mainnet  # Creates wallet + session

Enter fullscreen mode Exit fullscreen mode

3. Configure APPROVED_SPENDERS policy

# Replace <wallet-id> with your wallet UUID from step 2
curl -X POST http://127.0.0.1:3100/v1/policies \
  -H "Content-Type: application/json" \
  -H "X-Master-Password: $(cat ~/.waiaas/recovery.key)" \
  -d '{
    "walletId": "<wallet-id>",
    "type": "APPROVED_SPENDERS",
    "rules": {
      "spenders": [
        {
          "address": "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",
          "name": "Uniswap Universal Router",
          "maxAmount": "1000000000"
        }
      ]
    }
  }'

Enter fullscreen mode Exit fullscreen mode

4. Add approval limits

curl -X POST http://127.0.0.1:3100/v1/policies \
  -H "Content-Type: application/json" \
  -H "X-Master-Password: $(cat ~/.waiaas/recovery.key)" \
  -d '{
    "walletId": "<wallet-id>",
    "type": "APPROVE_AMOUNT_LIMIT", 
    "rules": {
      "instant_max_usd": 100,
      "notify_max_usd": 500,
      "delay_max_usd": 2000,
      "delay_seconds": 300,
      "block_unlimited": true
    }
  }'

Enter fullscreen mode Exit fullscreen mode

5. Test with your agent

# Your agent tries to approve a non-whitelisted contract
# Result: Transaction blocked with POLICY_DENIED

# Your agent tries to approve Uniswap for $50
# Result: Executes instantly

# Your agent tries to approve Uniswap for $1500  
# Result: 5-minute delay, you can cancel if suspicious

Enter fullscreen mode Exit fullscreen mode

Now your AI agent can only approve contracts you've explicitly whitelisted, with amount limits and human oversight for large approvals. No more infinite approval attacks.

Related posts that dive deeper into WAIaaS security:

Policy Engine: 21 Ways to Control Your AI Agent's Spending
3-Layer Security: How WAIaaS Prevents AI Agents from Draining Your Wallet

What's Next

The APPROVED_SPENDERS policy gives you surgical control over token approvals, but it's just one of 21 policy types in WAIaaS. Combine it with CONTRACT_WHITELIST, ALLOWED_TOKENS, and SPENDING_LIMIT for comprehensive protection. Ready to build AI agents with enterprise-grade security? Check out the full source code at GitHub or visit waiaas.ai to get started.