You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Route Cloud Run container traffic through a VPC where Cloud NGFW
firewall policies control outbound access by domain name (FQDN rules).
We previously tried iptables inside the container but found that
curl -6 bypasses iptables on Cloud Run, ip6tables kills the container,
and /proc/sys is read-only. The VPC approach applies firewall rules at
the GCP infrastructure level, outside the container.
Changes:
- Add vpc_network/vpc_subnet/vpc_egress to CloudRunClientConfig
- Configure run_v2.VpcAccess on job creation
- Add vpc_network/vpc_subnet/vpc_egress to ClaudeCodeClientConfig
- Document egress firewall setup in README (with example FQDN rules)
- Add integration test for VPC egress (allowed/blocked domains)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: safetytooling/infra/cloud_run/README.md
+110-1Lines changed: 110 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -177,12 +177,115 @@ client = ClaudeCodeClient(
177
177
-**Without this, Claude could take over your entire GCP project** - don't skip this step!
178
178
179
179
**What this doesn't limit:**
180
-
- Outbound network access (Claude could exfiltrate data to external URLs)
180
+
- Outbound network access (see Egress Firewall below)
181
181
- Anthropic API usage (Claude could use your API key for other purposes)
182
182
183
183
For the "yolo Claude" use case, the main risks are data exfiltration and API key abuse.
184
184
Containers are ephemeral (destroyed after job), so there's no persistence risk.
185
185
186
+
## Egress Firewall (Recommended)
187
+
188
+
By default, containers can make outbound requests to any host. To restrict egress (e.g., only allow `api.anthropic.com` and Google APIs), use VPC Direct Egress with Cloud NGFW firewall rules.
189
+
190
+
**How it works:** When `vpc_network` is set, all container traffic routes through a VPC where a Cloud NGFW firewall policy controls access by domain name (FQDN rules). This covers both IPv4 and IPv6.
0 commit comments