5.1 Follow the Prompt: Perimeter Defense with Agent Gateway & Model Armor
1. Key Concept Definitions: The Perimeter Security Stack
Section titled “1. Key Concept Definitions: The Perimeter Security Stack”Before tracing the prompt flow, review these four foundational Google Cloud security building blocks:
1. Agent Gateway
The managed network front door for AI agents, A2A endpoints, and MCP servers. Enforces authentication, rate limiting, traffic routing, and triggers inline Model Armor security callouts before traffic ever reaches your agent code.
2. Model Armor
Google Cloud’s model-agnostic AI security service that screens both incoming prompts (ingress) and model/tool outputs (egress) for Prompt Injection & Jailbreaks, Malicious URLs, Responsible AI safety, and Sensitive Data (SDP).
3. Sensitive Data Protection (SDP)
Integrated directly inside Model Armor templates to detect and mask/de-identify sensitive infoTypes (credit card numbers, SSNs, API keys) inline—or replace them with cryptographic surrogate tokens.
4. Model Armor Floor Settings
Configured at the Google Cloud Organization or Folder level to enforce a mandatory minimum detection threshold across all child projects that individual project owners cannot weaken!
2. Interactive Flow: Single PII (Redact) vs. Multi-Violation (Block) vs. Protocol Rules
Section titled “2. Interactive Flow: Single PII (Redact) vs. Multi-Violation (Block) vs. Protocol Rules”Switch between the 3 Perimeter Scenarios below and click through the 4 stages to see how Agent Gateway and Model Armor inspect traffic—and how ADK troubleshoots customer issues safely after a credit card number is redacted:
3. How ADK Troubleshoots Customer Issues After PII Redaction
Section titled “3. How ADK Troubleshoots Customer Issues After PII Redaction”A common question architects ask is: “If Model Armor redacts a customer’s credit card number or SSN at the perimeter, how does the ADK agent look up their account to help them?” Apply these two enterprise patterns:
| Resolution Pattern | How It Works End-to-End | When to Use It |
|---|---|---|
| 1. Out-of-Band Authenticated Session & OAuth 2.0 Delegation (Primary Pattern) | The customer is authenticated in the web/mobile app. While Model Armor scrubs [REDACTED_CC] from the prompt text so Gemini never sees raw PCI digits, the ADK tool reads the verified user_id or OAuth 2.0 access token (via Agent Identity Auth Manager / ToolContext) to query the customer’s orders and cards safely in the backend! |
95% of customer support agents: Never rely on raw credit card digits typed into a chat prompt to identify a user! |
| 2. SDP Format-Preserving / Cryptographic Surrogate Tokenization | Instead of static masking ([REDACTED]), Sensitive Data Protection (SDP) replaces the 16-digit PAN with a deterministic surrogate token (e.g., TOKEN_4910-8821). Gemini passes that harmless surrogate token into the ADK tool argument, and only the downstream PCI-compliant vault detokenizes it! |
Specialized guests/unauthenticated flows where a specific card or document number must be correlated across systems without exposing raw PII to the LLM. |
4. Perimeter Defense Reference Matrix
Section titled “4. Perimeter Defense Reference Matrix”| Perimeter Rule / Component | Technical Configuration | Runtime Verdict / Behavior |
|---|---|---|
| Single SDP Detector Match | Ingress/Egress Model Armor template with SDP enabled (no other threat matched). | Redact & Continue: Masks or tokenizes the sensitive infoType inline and forwards the sanitized payload. |
| Multi-Detector Match | Payload triggers Prompt Injection/Jailbreak + SDP (or Malicious URI) simultaneously. | Hard Block: Refuses partial redaction and terminates the request at Agent Gateway. |
| Gateway-to-Model-Armor IAM | Bind roles to the Agent Gateway service identity. | Requires roles/modelarmor.calloutUser AND roles/modelarmor.user (least privilege). |
| Protocol Inspection Scope | Model Armor attached to Agent Gateway for A2A v1 and MCP traffic. | Scanned: A2A Send Message, A2A Agent Card, MCP tools/call.Bypassed: MCP tools/list! |
| Organization Floor Settings | Configured at the GCP Organization or Folder hierarchy node. | Enforces a mandatory minimum safety threshold across all child projects. |