Lesson 5 of 9 · 27m
Egress Control, DNS, and the Cost of Letting Everything Leave
Design outbound filtering that limits command-and-control and data theft while preserving updates, automation, and developer velocity.
Inbound filtering gets the attention because it is easy to draw. Egress control is where breaches become expensive. Once a host is compromised, outbound access decides how easily the operator can establish command-and-control, download tooling, tunnel data, and reach cloud metadata or control planes. If everything inside can reach everything outside, you have outsourced a large part of your security boundary to the attacker's imagination.
Egress control is also where security teams lose credibility. Break updates, package builds, container pulls, or SaaS integrations without warning, and engineers will spend their creativity bypassing you.
Start by separating client and server egress
User endpoints and servers have different outbound needs:
user endpoints SaaS, collaboration, browsing, software update, identity
servers package repos, APIs, telemetry, backup, cloud control, dependencies
build systems registries, source control, artifact stores, vendor endpoints
appliances vendor update and support endpoints, often opaqueDo not apply one giant proxy policy to all of them and call it defense in depth. A database server does not need general web browsing. A developer workstation may legitimately need broader destinations than a finance laptop.
DNS is control-plane traffic
DNS is often the first and last egress path left open. Attackers know this. If clients can use arbitrary resolvers, they can bypass filtering, policy, and visibility:
udp/tcp 53 to internet resolvers
DNS-over-HTTPS to public resolvers
DNS tunneling through long-lived query streamsForce managed resolvers where possible and block direct external DNS from user and server segments. At the resolver, log enough to investigate without turning privacy into collateral damage.
Example Unbound forwarding configuration:
forward-zone:
name: "."
forward-tls-upstream: yes
forward-addr: 1.1.1.1@853#cloudflare-dns.com
forward-addr: 1.0.0.1@853#cloudflare-dns.comThat forwards controlled traffic upstream. It does not by itself stop malicious use of allowed domains. DNS filtering is a layer, not a verdict.
Egress policy is a dependency inventory
The durable artifact is not a firewall rule; it is an inventory of required dependencies:
service destination port/protocol owner
artifact builder registry.npmjs.org tcp/443 platform
container nodes ghcr.io, production registry tcp/443 platform
backup agent backup.s3.us-east-1.amazonaws.com tcp/443 infra
payment service api.stripe.com tcp/443 paymentsThen enforce through proxy allowlists, firewall FQDN rules where reliable, private endpoints, or egress gateways. Expect IP-based SaaS rules to rot. Expect FQDN rules to fail when DNS resolution paths are inconsistent.
TLS inspection is a trade, not a default
Inspecting TLS can expose malicious downloads, data theft, and shadow SaaS. It can also break certificate pinning, weaken privacy, centralize sensitive traffic, and create a high-value inspection platform. Decide deliberately:
inspect managed user endpoints, selected categories, controlled workloads
do not inspect health data where policy forbids, pinned update paths, sensitive privileged flows
bypass only documented endpoints with owners and review datesIf you deploy inspection, protect the CA private key like a crown jewel. A trusted inspection CA on unmanaged devices is an incident waiting for a misunderstanding.
Look for the quiet bypasses
Common bypasses include cloud NAT instances, test VPCs with open egress, container registries used as transfer points, source-control gists, SaaS storage, webhook endpoints, and fallback VPN clients. If a workload can reach the internet because "the base image needed it," the segment is not controlled.
A simple test belongs in deployment validation:
curl -I --max-time 5 https://internet-bad-candidate.invalid || true
curl -I --max-time 5 https://1.1.1.1 || true
curl -I --max-time 5 https://allowed-service.example || trueTest both expected success and expected failure. Alerting only on blocks is not proof that blocks happen.
Field notes
- Egress allowlists fail when applications use content delivery networks shared with millions of unrelated domains.
- Blocked traffic should produce useful telemetry. A silent deny creates mysteries; a noisy deny creates fatigue.
- Package managers need cache and mirror strategies or security teams will eventually lose the egress argument.
- Cloud private endpoints reduce exposure but can complicate split-horizon DNS and hybrid resolution.
- Do not confuse proxy authentication with application authorization. They solve different problems.
Was this lesson helpful?