Deep Egress Filtering: Hardening Isolated Agent Networks with Forward Proxying
Automated coding agents need outbound access to package repositories and Git, but direct Internet routing risks lateral pivoting. We enforced zero-trust egress via a locked-down Squid proxy.

Key Architectural Takeaways
- Allowing unmonitored outbound traffic from automated agent subnets allows command-and-control pivots into private management interfaces.
- Our firewall strictly blocks all direct outbound traffic from the agent VLAN, routing traffic through an internal forward proxy.
- Squid enforces anti-pivot rules by resolving target FQDNs and denying any request resolving to private RFC 1918 addresses.
The dilemma of automated development environments
Autonomous coding agents and continuous-integration runners present a modern security challenge:
- To be productive, they must install dependencies (
pip install,apt-get update), clone public GitHub repositories, and query developer APIs. - But granting an automated runtime direct, unrestricted outbound network access transforms every compromised dependency or prompt injection vulnerability into an immediate pivoting hazard against internal management planes.
Placing agents in an isolated VLAN is a necessary first step. But if firewall rules simply permit Allow Agent_VLAN -> Any (80, 443), an attacker who compromises an agent container can establish reverse shells, exfiltrate data to arbitrary cloud endpoints, or exploit internal services via DNS rebinding.
The proxy boundary architecture
We solved this dilemma by severing direct Internet access entirely.
On the edge firewall, the rule is uncompromising: zero outbound WAN traffic is permitted from the agent subnet. No direct DNS queries to external servers, no HTTP, and no HTTPS.
The single permitted egress path is through an internal Squid forward proxy running in a dedicated, minimal Linux container on our production management segment:
- Agent containers configure standard environment variables (
http_proxy,https_proxy,all_proxy) pointing to the internal proxy endpoint on port3128. - The proxy host alone has firewall clearance to initiate outbound connections to the Internet on ports 80 and 443.
The anti-pivot guard: preventing SSRF and internal routing
The primary vulnerability of a simple forward proxy is Server-Side Request Forgery (SSRF). If an agent script requests http://internal-router.local:8080/admin or http://169.254.169.254/metadata, a naive proxy might happily connect to the private target and return the payload to the attacker.
We hardened Squid with an explicit, load-bearing ACL hierarchy where order is paramount:
# 1. Authorize only the agent subnet
acl agent_clients src 192.0.2.0/24
http_access deny !agent_clients
# 2. Restrict TLS tunneling strictly to HTTPS
acl SSL_ports port 443
acl CONNECT method CONNECT
http_access deny CONNECT !SSL_ports
# 3. The Anti-Pivot Guard: Deny all internal private destinations
# Blocks RFC1918 private subnets, loopback, and link-local ranges
acl private_subnets dst all_rfc1918_and_link_local
http_access deny private_subnets
# 4. Enforce strict destination FQDN allowlists
acl allowed_domains dstdomain .github.com .githubusercontent.com
acl allowed_domains dstdomain .debian.org .python.org .pypi.org
acl allowed_domains dstdomain .ollama.com .wazuh.com
http_access allow allowed_domains
# 5. Default deny everything else
http_access deny allThe critical rule is http_access deny private_subnets. Because it uses the dst ACL type, Squid performs an internal DNS lookup and inspects the resolved IP address before sending a single TCP packet.
If an attacker constructs a malicious public domain that resolves to an internal management IP, Squid detects that the destination address lies within private IP space and terminates the request immediately with TCP_DENIED/403.
Least privilege on the proxy daemon
The proxy was engineered as a pure security gate, not an caching appliance:
cache deny all: Disk and memory caching are disabled completely, preventing sensitive build artifacts from persisting on proxy storage.access_log: Every permitted request and denied attempt is recorded with exact timestamps, client source IPs, and destination hostnames for SIEM ingestion.- Configuration validation (
squid -k parse) runs automatically in CI/CD before any service reload is triggered.
Verification
We validated the proxy with three deliberate attack simulations from inside the agent subnet:
- Direct outbound egress: Running
curl -I https://github.comwithout proxy variables timed out immediately, proving the firewall drops direct WAN flows. - Authorized proxy access: Running
curl -x proxy:3128 -I https://github.comreturned HTTP 200, verifying legitimate traffic flows smoothly. - Internal pivot attempt: Running
curl -x proxy:3128 -I http://192.0.2.1returned HTTP 403 Forbidden withERR_ACCESS_DENIEDlogged inaccess.log.
Engineering takeaway
Network segmentation that ignores egress is half a defense. By forcing automated workloads through a hardened forward proxy with resolved-IP anti-pivot rules, you give agents the external dependencies they need while keeping internal infrastructure strictly out of reach.