跳到正文
DEV Community· Kanan Gandhi·· 2 小時前AI 評分46

PromptPay Guard:面向智能體支付的零信任防禦

PromptPay Guard: A Zero-Trust Defense for Agentic Payments

AI 導讀

PromptPay Guard 是為 PayPal AI Agent Hackathon 建構的內聯雙層零信任防火牆,位於自主 LLM Agent 與 PayPal Orders API v2 之間。

正文

Kanan Gandhi

Securing Autonomous AI Agent Payments: Building an Inline Zero-Trust Firewall for PayPal

Autonomous AI agents are shifting from passive text assistants to autonomous financial actors. Today, agents can analyze vendor quotes, generate invoices, and execute checkout flows without human intervention.

However, connecting non-deterministic Large Language Models (LLMs) directly to financial payment rails introduces a critical attack surface:

  • Indirect Prompt Injections: Hidden instructions inside invoices or web scraping targets that divert funds.
  • Salami Micro-Drains: High-frequency, sub-dollar loops designed to bypass typical velocity and fraud limits.
  • Denial-of-Wallet (Token Exhaustion): Massive adversarial reasoning payloads sent to exhaust LLM inference budgets before a payment even executes.

To address this, I built PromptPay Guard for the PayPal AI Agent Hackathon — an inline, Two-Tier Zero-Trust security firewall positioned between autonomous LLM agents and the PayPal Orders API v2.


The Core Philosophy: Two-Tier Defense Pipeline

Relying purely on LLM-based security guards creates latency and high operational expense (OpEx). If every $1.00 payment requires $0.05 of model inference to verify, the system is economically unviable.

PromptPay Guard resolves this via a dual-engine architecture:

1. Tier-1: Fast In-Memory Heuristics (<0.5ms)

  • Zero Marginal Cost: Evaluates incoming payloads entirely in-memory using sliding-window rate limiters, budget caps, and regex boundary checks.
  • Typo-Squatting & Homoglyphs: Intercepts Unicode lookalike domains (e.g., Cyrillic characters mimicking PayPal merchant addresses).
  • Payload Context Capping: Enforces a hard 4,000-character ceiling, dropping context-bombing attempts at $0.00 compute cost.
  • Impact: Discards roughly 38% of anomalous traffic instantly before waking up heavier models.

2. Tier-2: Semantic Intent Engine (Google Gemini 1.5)

  • Inspects the agent's raw chain-of-thought scratchpad against the declared user mandate.
  • Utilizes Gemini 1.5 Flash for sub-200ms semantic reconciliation, falling back dynamically to Gemini 1.5 Pro for ambiguous, high-value payloads.
  • Employs native JSON schema enforcement (response_mime_type: "application/json") to ensure deterministic risk outputs (risk_score, threat_type, rationale).

The 3-Zone Operational Risk Model

Instead of a binary "pass or block" model that causes friction or false positives, PromptPay Guard employs a tri-state risk model:

  1. Zone 1 (Score 0–30 | Green): Autonomous pass-through. Orders are authorized and captured via the PayPal Orders API v2.
  2. Zone 2 (Score 31–70 | Amber): Ambiguous or medium-risk transactions. Execution is held, and an asynchronous event is pushed via Server-Sent Events (SSE) to an administrative Human-in-the-Loop (HITL) console for 1-click operator review.
  3. Zone 3 (Score 71–100 | Red): High-confidence adversarial attack or prompt injection. The transaction is instantly blocked with an HTTP 403 response.

Enterprise Hardening & Resilience

  • Idempotency Engine: In-memory caching using unique x-idempotency-key headers prevents duplicate charges during agent network retries.
  • Cryptographic Webhook Validation: Full signature verification (PAYPAL-TRANSMISSION-SIG) and timestamp skew validation prevent replay attacks.
  • Automated Verification: The entire gateway is verified through a 60-test automated suite covering unit tests, injection attempts, and fail-secure crash resilience.

Explore the Code & Demo

How are you approaching security for autonomous agentic commerce? Let's discuss in the comments

Demo video

來源:DEV Community · dev.to