Inspiration

  • The Real-World 2026 Agentic Commerce Crisis:
  • Amazon's AI Bot Lockout (Sept–Oct 2026): Amazon actively blocked Meta's Muse AI shopping agent, OpenAI, Google, and Perplexity's Comet browser at checkout—throwing 403 / Terms-of-Service popups because outside agents impersonate human browsers, scrape account data, and risk exposing customer login credentials.
  • Walmart's Closed Retailer Silo (Oct 2026): Walmart launched an MCP Agent Gateway with Agent Profiles and spending caps, proving retailers want controlled agentic commerce—but Walmart's gateway only works inside Walmart & Sam's Club.
  • Financial Institution Blocks: Major banks and brokerages (JPMorgan, Charles Schwab) block external AI agents from moving money because handing raw payment credentials to an LLM is an unacceptable security and prompt-injection liability.

  • The Core Ideology (Zero-Trust Delegation):

  • Today's Broken Choice: Either you slow an AI agent down by clicking "Approve" on every screen, or you hand an LLM your PayPal password, email, and home address—exposing yourself to Indirect Prompt Injection (hidden website metadata tricking the agent into buying a $75 gift card) and Merchant Bot-Bans.

  • Our Vision: Make PayPal the universal, cross-merchant trust layer for AI agents—where the AI shops blindfolded (0% PII), merchants verify a cryptographic human mandate (200 OK), and PayPal Sandbox `Orders v2` settles funds strictly within human-defined rules.


What it does

PayPal GhostPass is an Agentic Commerce Authorization & Settlement Broker (MCP + REST) sitting between any external AI Agent (Claude, Gemini, OpenAI Operator, or custom clients) and PayPal `Orders v2`.

  • 1 · Programmable Zero-PII Payment Passes (Scoped Mandates):
  • Users connect PayPal once and mint a single-use, spend-capped credential (gp_live_..., e.g., "$60/tx max · $150/day cap · Hardware & books only · No gift cards").
  • Triple-Blind Separation:
  • External AI Agent Sees: Public product catalog + scoped token (0% name, email, shipping address, or PayPal credentials).
  • Merchant Storefront Sees: Cryptographic X-PayPal-GhostPass-Signature proving a real human authorized the budget + PayPal vaulted shipping relay (eliminating 403 scraper blocks and CAPTCHAs).
  • PayPal Vault Executes: Real USD transfer via PayPal Sandbox `Orders v2` only after passing local security checks.

  • 2 · Dual-Layer Adversarial & Policy Guardrail:

  • Deterministic Math Firewall: Enforces exact per-transaction caps, daily velocity limits, and regex injection signatures in < 5ms.

  • Semantic LLM Auditor (Gemini 2.5 Flash): Evaluates cart intent against the user's plain-English rule—catching disguised items and Indirect Prompt Injections (e.g., a $19 USB-C cable hiding metadata that tries to sneak a $75 Steam Gift Card into checkout).

  • 3 · Human-in-the-Loop (HITL) Step-Up Authorization:

  • Safe items within budget ($48 mechanical keyboard) settle autonomously in seconds.

  • Legitimate items exceeding the auto-approve threshold ($115 Sony headphones) freeze checkout and trigger a 1-Click Human Override (Authorize / Decline).

  • 4 · Live 3-Stage Payload Inspector & AG Grid Compliance Ledger:

  • Judges inspect the exact 1. Input (Agent Context) → 2. Analysis (Guardrail Verdict & Risk Score) → 3. Output (PayPal Orders v2 & Store Firewall) diff live, test custom prompts or custom adversarial payloads, and audit every transaction in AG Grid.


How we built it

Architecture & Tech Stack

  • Payment & Settlement Engine: PayPal Developer Platform (Sandbox REST API) — OAuth 2.0 Client Credentials token exchange (POST /v1/oauth2/token) + Orders v2 (POST /v2/checkout/orders) with intent: "CAPTURE" and live Sandbox verification links.
  • AI Reasoning & Security Brain: Google Gemini 2.5 Flash (@google/genai) — Structured JSON schema outputs powering both the Identity-Blind Shopping Agent and the Semantic Policy & Prompt-Injection Auditor.
  • Enterprise Observability & Audit Grid: AG Grid (ag-grid-react & ag-grid-community) — Real-time compliance ledger tracking timestamps, agent mode, PII exposure (0% vs 100%), risk scores, guardrail verdicts, and clickable PayPal Sandbox Order IDs.
  • Full-Stack Framework & Hybrid Persistence: Next.js 16 (App Router, TypeScript, Tailwind CSS) with a Strategy/Adapter storage layer supporting zero-config in-memory/localStorage persistence out of the box plus ready-to-run Neon PostgreSQL SQL migrations (migrations/001_init.sql).

Core Algorithms & Mathematical Formulas

  1. Cryptographic Mandate Attestation (HMAC-SHA256): Every approved cart mints a tamper-proof merchant header bound to exact item, price, session, and expiry:

$$\text{Signature} = \text{HMAC}{\text{SHA256}}\Big(K{\text{secret}},\; \text{productId} \parallel \text{amount}{\text{USD}} \parallel \text{sessionId} \parallel t{\text{exp}}\Big)$$

  • If a compromised agent or rogue storefront alters the cart total by even $0.01 after Gatekeeper approval, signature verification fails immediately at the merchant firewall.
  1. Spend & Velocity Guardrail Invariants:

$$\text{Decision}(p, M) = \begin{cases} \mathbf{BLOCK}, & \text{if } \text{Injection}(p) = 1 \;\lor\; \neg\text{IntentMatch}(p, M) \;\lor\; (S_{\text{today}} + p_{\text{amount}} > C_{\text{daily}}) \ \mathbf{HITL_REQUIRED}, & \text{if } p_{\text{amount}} > L_{\text{auto}} \;\land\; (S_{\text{today}} + p_{\text{amount}} \le C_{\text{daily}}) \ \mathbf{AUTO_APPROVE}, & \text{otherwise} \end{cases}$$

  • Where $p_{\text{amount}}$ is proposed cart total, $L_{\text{auto}}$ is per-transaction auto-approve cap ($60.00), $S_{\text{today}}$ is cumulative daily spend, and $C_{\text{daily}}$ is the 24-hour rolling cap ($150.00).
  1. Composite Risk Scoring & PII Exposure Metric:

$$R_{\text{score}} = \min\Big(100,\; 85 \cdot I_{\text{inject}} + 60 \cdot V_{\text{policy}} + 35 \cdot \max\Big(0, \frac{p_{\text{amount}} - L_{\text{auto}}}{L_{\text{auto}}}\Big)\Big)$$

$$\text{PII_Exposure}(\%) = \frac{\vert{}\text{Fields}_{\text{leaked}} \cap {\text{Name}, \text{Email}, \text{Address}, \text{AuthToken}}\vert{}}{4} \times 100\%$$

  • Unverified Bot Mode: $\text{PII_Exposure} = 100\%$ → Merchant Firewall returns HTTP 403 Forbidden.
  • PayPal GhostPass Mode: $\text{PII_Exposure} = 0\%$ → Merchant Firewall returns HTTP 200 Verified and settles via PayPal Orders v2.

Challenges we ran into

  • Separating Merchant Storefront Logic from External AI Agents:
  • Challenge: Initially, placing AI checkout buttons inside the storefront blurred the real-world boundary—real merchants (like Amazon or NovaTech) do not run the buyer's personal AI agent.
  • Fix: We decoupled the architecture into two independent domains: a 100% pure e-commerce merchant storefront (NovaTech Store) enforcing an anti-bot HTTP firewall, and an external MCP Authorization Broker (PayPal GhostPass Control Plane) that authenticates across the boundary using cryptographic headers.

  • Preventing LLM Hallucinations on Hard Financial Limits:

  • Challenge: LLMs alone can occasionally miscalculate running daily totals or be persuaded by cleverly phrased prompt injections inside product descriptions.

  • Fix: We implemented a Defense-in-Depth Chain of Responsibility—hard TypeScript arithmetic and regex injection filters execute before and alongside Gemini 2.5 Flash's structured JSON schema evaluation, guaranteeing deterministic enforcement of financial caps.

  • Designing Layman-Clear Observability Without Clutter:

  • Challenge: Raw security protocols and JSON logs are intimidating to non-technical viewers, while simplified mockups fail technical scrutiny.

  • Fix: We built a 3-Stage Visual Pipeline Diff (Input → Analysis → Output) paired with AG Grid, showing both plain-English status badges (0% PII, CLEAN, 200 VERIFIED) and the real underlying PayPal Orders v2 payloads.


Accomplishments that we're proud of

  • True End-to-End PayPal Sandbox Settlement (Orders v2): Every approved agent execution generates a genuine, verifiable PayPal Sandbox Order ID (POST /v2/checkout/orders), not a simulated mock string.
  • Demonstrable Defense Against Real Agentic Attacks: One-click presets and custom payload inputs let anyone test 3 real-world outcomes live:
  • Unverified scraper blocked (HTTP 403, 100% PII leaked) vs. GhostPass auto-settled (HTTP 200, 0% PII leaked).
  • Hidden $75 Steam Gift Card prompt-injection trap neutralized ($0.00 lost, Risk Score 95/100).
  • Over-budget $115 headphones paused for 1-Click Human-in-the-Loop Override before PayPal capture.

  • Production-Grade Engineering & Automated Test Coverage: Backed by Vitest unit & integration test suites covering HMAC signature tampering, Gatekeeper policy enforcement, merchant 403 firewall rules, and PayPal OAuth2/Orders v2 flows.


What we learned

  • Identity-Blindness Is the Key to Safe Agentic Commerce: An AI agent only needs product context to shop and a scoped cryptographic token to pay—keeping PII and credentials vaulted in PayPal eliminates the biggest attack surface in autonomous commerce.
  • Open Protocols Beat Retailer-Specific Silos: While closed gateways lock users into single stores, pairing Model Context Protocol (MCP) tool calls with PayPal's universal merchant network lets one user mandate work across the entire open web.
  • Hybrid Guardrails Outperform Pure Prompts: Combining deterministic math/cryptography (HMAC-SHA256 + budget invariants) with Gemini 2.5 Flash semantic reasoning delivers both sub-second speed and contextual intelligence.

What's next for PayPal GhostPass

  • Official @paypal/agent-toolkit & Stdio/SSE MCP Package: Publish paypal-ghostpass-mcp on npm so developers using Claude Desktop, Cursor, Windsurf, or Gemini CLI can plug in their GhostPass token in 30 seconds.
  • PayPal Vault & Shipping Relay Webhooks: Expand zero-PII fulfillment with automated carrier tracking webhooks so merchants ship physical orders without ever exposing raw buyer addresses to third-party AI agents.
  • Multi-Agent Enterprise Treasury Policies: Add team-level spending mandates, role-based approval quorums, and automated accounting exports via AG Grid for autonomous B2B procurement agents.

Built With

Share this project:

Updates

Submission history