Closing the Exfiltration Path: Egress and Private Connectivity for Data Agents
Content reflects the state as of November 2026. AI tooling and model capabilities in this area change frequently.
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 unlessprivate-endpoint-network-policiesis enabled, and recursive DNS resolvers still allow DNS tunneling if left open.
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.”
Four concrete networking constraints govern why naive VPC setups fail under agent exploitation:
- 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 pinningPrincipalandaws: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. - 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. - 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. - Recursive DNS provides a covert exfiltration channel even when HTTP is blocked (TB-1). If an isolated subnet blocks
0.0.0.0/0on 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 (viafetch,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.
How the Options Compare
| Capability | AWS PrivateLink + SG | Google Cloud PSC + VPC-SC | Azure Private Link + NSG |
|---|---|---|---|
| Private LLM API routing | Interface VPC Endpoint (com.amazonaws.<region>.bedrock-runtime) with Private DNS | PSC Endpoint (all-apis or service attachment) + PSC Interface for Vertex AI | Private Endpoint for Azure OpenAI (*.openai.azure.com) + Private DNS Zone |
| Private DB routing | RDS 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 VPC | Private Endpoint for Azure SQL (*.database.windows.net, TCP 1433) |
| What it DOES control | Keeps traffic off public internet; Endpoint Policies restrict IAM principals & org resources | Keeps traffic on Google backbone; VPC Service Controls (VPC-SC) blocks cross-org data exfiltration even with stolen creds | Keeps traffic off public internet; Private DNS resolves FQDNs to VNet private IPs |
| What it DOES NOT control | Does not block DNS tunneling or arbitrary NAT egress on its own; RDS needs SG rules | Does not stop allowed intra-perimeter egress or NAT egress unless firewall deny rules block internet | Does not disable Public Network Access automatically; subnet NSGs ignored on PE subnet by default |
| Critical hardening step | Replace default Allow * VPC Endpoint Policy; remove NAT/IGW from agent subnet | Place Vertex AI & Cloud SQL inside a VPC-SC perimeter; scope egress rules to pscEndpoint | Enable --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.
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 /
Hostallowlists (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 Vector | Trust Boundary Crossed | Attacker Objective (OWASP / ATLAS) | Defender Control (Deterministic) | Verification Signal |
|---|---|---|---|---|
Outbound webhook / curl via NAT | TB-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/NSG | curl https://example.com from agent pod times out immediately |
| Same-cloud cross-account copy | TB-2 (Endpoint → Attacker Acct) | Copy data to attacker’s S3/GCS bucket via private backbone | AWS VPC Endpoint Policy (Principal + ResourceOrgID) / GCP VPC-SC | Write to external bucket fails with AccessDenied / VPC-SC violation |
| Azure public endpoint fallback | TB-3 (Public Net → Azure SQL) | Bypass Private Link and hit public FQDN if DNS leaks | Set Public network access = Disabled + Private DNS Zones | Public IP resolution or external connection attempt returns 403 / blocked |
| Azure PE subnet NSG bypass | TB-2 (Subnet → PE NIC) | Reach Private Endpoint from unauthorized VNet subnet | Run --private-endpoint-network-policies Enabled + inbound NSG allowlist | Unauthorized subnet connection to PE private IP is dropped by NSG |
| DNS tunneling exfiltration | TB-1 (Pod → Recursive DNS) | Encode rows into *.evil.tld DNS lookups when HTTP is blocked | Internal-only DNS + Route 53 DNS Firewall / Cloud DNS blocklist | dig secret.evil.tld returns NXDOMAIN or REFUSED |
| In-pod proxy / sidecar bypass | TB-1 (Compromised Tool → Net) | Ignore HTTPS_PROXY env var and open raw TCP socket | Enforce L4 NetworkPolicy blocking all pod egress except Envoy Egress GW | Direct 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/NetworkPolicy | Metadata 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.
Runtime Packet Flow
- 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. - 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/0andInternettags are denied. - 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.
- 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
- 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:
nslookupfrom 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. - 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 = Disabledplus--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. - 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:curlanddigto external domains fail from inside the agent pod. Rollback: Re-attach temporary NAT only for non-sensitive Profile C research pods, never Profile A. - Phase 4 — Deploy Envoy Egress Gateway for Profile B: Route approved external SaaS webhooks through a dedicated Istio/Envoy Egress Gateway with L4
NetworkPolicyenforcement. Gate: Direct pod egress to approved SaaS IPs is blocked unless traversing the Envoy gateway. Rollback: Add missing approved host to EnvoyServiceEntryvia 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 Enabledis 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
| Condition | Breaks How | Detect | Mitigate |
|---|---|---|---|
| VPC-SC retrofitted onto active pipelines | Enforcing VPC-SC on existing Vertex AI / Cloud SQL projects breaks undocumented cross-project data paths | Spike in VPC_SERVICE_CONTROLS audit denial logs | Run VPC-SC in dry-run mode first to inventory all cross-project calls before enforcing |
| Private DNS resolution fails silently | Client falls back to public DNS, sending traffic toward a disabled public endpoint and failing with 403/timeout | dig returns public IP instead of 10.x / 172.16.x | Validate Private DNS Zone links and Enable Private DNS Name in CI/CD smoke tests |
| Shared NAT Gateway across Profile A and C pods | Putting untrusted triage agents in the same subnet as web-research agents gives triage agents full NAT egress | Subnet route table shows 0.0.0.0/0 -> nat-... attached to Profile A subnet | Physically separate Profile A (no NAT) and Profile C (egress-allowed, no DB creds) into distinct subnets |
| Stale VPC Flow Logs / unmonitored egress denials | Repeated blocked exfiltration attempts go unnoticed by security teams | Zero alerts on REJECT entries in VPC Flow Logs | Alert 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 endpoints | Envoy access logs show connections to unapproved subdomains | Allowlist 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-policiesplusPublic network access = Disabled. - Close DNS tunneling and metadata SSRF: Use internal-only DNS with DNS firewalls, and block
169.254.169.254from 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.