The question nobody could answer
A prospective enterprise customer asked a simple due diligence question: if an attacker popped one of your containers, what else could they reach?
Nobody on a 40-engineer team running a B2B scheduling platform (roughly 9,000 paying seats) could answer with confidence. No breach had happened. The uncertainty itself was the problem, and it's the same uncertainty a lot of growing platforms are sitting on without realizing it.
This is a condensed breakdown of how we moved that infrastructure from a flat, perimeter-trust network to a zero trust model, in four shippable stages, with no rip-and-replace and no maintenance window.
What the flat network actually looked like
Five years of organic growth had produced the usual pattern: a perimeter firewall at the VPC edge, flat routing inside it, and an implicit assumption that anything inside the boundary was safe. We ran a two-week audit to map real traffic flows instead of trusting the architecture diagram, and the two didn't match.
What we found:
- East-west traffic was wide open. Any instance in the VPC could reach any other instance on any port. A compromised billing worker could hit the customer database directly.
- No service-to-service auth. Internal REST calls between the scheduling engine, notifications, and reporting were plain unauthenticated HTTP. Network location was the only "proof" of identity.
- One shared DB user, full read/write, used by six services. Not rotated in over 14 months because nobody wanted to coordinate the restart.
- 22 engineers had standing SSH access to prod via a shared bastion, key-based, no session recording, no JIT elevation.
- Staging and prod shared a Redis cluster, isolated only by key prefixing in app code. One prefix bug away from crossing environments.
- Flow logs existed but weren't identity-aware. No way to answer "which service account ran this query" because the connection pool masked the caller.
None of this was an active exploit. It was a security posture resting entirely on the perimeter holding and on 22 people never losing an SSH key. That's a single point of failure wearing a defense-in-depth costume.
The zero trust guarantees we targeted
Zero trust isn't a product, it's a checklist of verifiable guarantees, independent of network position:
- Every inter-service request carries verifiable identity, not just a source IP.
- Access is granted per request based on policy, not permanently based on network location.
- Credentials are short-lived and scoped to minimum necessary action.
- All access is logged with enough identity context to answer "who did what" directly, not by inference.
We phased this into four independently shippable stages, each reducing blast radius before the next one started. Same philosophy as zero-downtime migrations: every stage leaves the system working and rollback-able.
Stage 1: segment the network
We split the flat VPC into trust tiers: public load balancers, app tier, data tier, and a separate management tier for CI/CD and bastion access. Security groups went from "allow internal" to explicit per-service allow-lists.
resource "aws_security_group_rule" "billing_ingress_from_scheduler" {
type = "ingress"
from_port = 8443
to_port = 8443
protocol = "tcp"
security_group_id = aws_security_group.billing.id
source_security_group_id = aws_security_group.scheduler.id
}
The billing service's security group went from "allow entire VPC CIDR" to four explicit ingress rules, one per legitimate caller, each scoped to its own port. This alone kills the "any instance reaches any instance" problem. It doesn't solve identity, but it shrinks attack surface immediately, which matters when the rest of the rollout takes weeks.
Stage 2: mTLS everywhere
We introduced Linkerd (picked over Istio for lower operational overhead at this team size) to handle mTLS automatically. Every service got a SPIFFE-based identity from the mesh's CA, rotated every 24 hours, zero manual intervention. No app code changes, the sidecar handled the handshake.
This flips the trust model from "anyone on the internal network is trusted" to "only holders of a valid, short-lived certificate for an authorized identity are trusted," regardless of subnet. A compromised container can't call the billing API just by being on the network anymore. It needs a valid workload identity scoped to allowed routes.
Stage 3: kill the shared credential
The single shared DB user got replaced with per-service IAM-based auth, short-lived tokens refreshed every 15 minutes via RDS IAM auth. Each service's DB role was scoped to only the schemas and operations it actually used, verified by replaying three months of query logs against the proposed grants before cutover.
We found two services using the shared user for ad hoc admin queries unrelated to their function, leftover from a developer's debugging session 18 months prior that never got cleaned up. We only caught this because we audited real query logs instead of trusting the documented access model. Worth remembering next time you're told "access is scoped correctly" without evidence.
Stage 4: just-in-time access, real segmentation
Standing SSH got replaced with a JIT access system: engineers request time-boxed access (default 45 minutes) through a Slack-integrated approval flow, backed by short-lived SSH certs signed by an internal CA instead of static keys. All sessions recorded. Shared bastion retired entirely.
Staging and production Redis moved to physically separate clusters with real network segmentation, killing the key-prefix-as-isolation anti-pattern for good. Every service-to-service call now logs the SPIFFE identity of both caller and callee, so "who did what" is a query, not a guess.
Takeaway
If you can't answer "what can a compromised container reach" right now, that's the actual finding, not a hypothetical breach. Fix it in stages, verify identity instead of network position, and make credentials expire before someone has to remember to rotate them.
Full writeup with more detail: Zero trust networking: an infrastructure security hardening case study
Originally published on binadit.com
Top comments (0)