From flat network to zero trust: an infrastructure security hardening case study

Binadit Tech Team 27 November 2026 10 min read
From flat network to zero trust: an infrastructure security hardening case study

The situation

The client was a B2B SaaS platform running workforce scheduling software for mid-sized retail and hospitality chains. Around 40 engineers, roughly 9,000 paying seats, and a production environment that had grown organically over five years: a handful of large VPCs, a couple dozen EC2-style instances, managed databases, and a growing number of internal microservices that had been split out of a monolith over the previous eighteen months.

The trigger for the engagement was not a breach. It was a due diligence questionnaire from a prospective enterprise customer. The procurement team asked a simple question: if an attacker compromised one of your application containers, what else could they reach? Nobody on the engineering team could answer with confidence. That uncertainty was the actual problem, not any specific incident.

The network model in place was what most growing platforms end up with: a perimeter firewall at the VPC boundary, flat routing inside it, and an implicit assumption that anything already inside the network was trusted. Services authenticated to databases with static credentials. Internal API calls between services had no authentication at all, they relied on network location as proof of identity. This is a completely normal starting point. It is also the exact model that zero trust architecture exists to replace.

What we found during the audit

We ran a two-week technical audit before touching anything. The goal was to map actual traffic flows, not the architecture diagram the team believed was accurate. The two rarely match.

  • East-west traffic was completely unrestricted. Security groups controlled north-south traffic into the VPC reasonably well, but any instance inside the VPC could open a connection to any other instance on any port. A compromised worker node in the billing service could reach the customer database directly.
  • Service-to-service calls used no mutual authentication. Internal REST calls between the scheduling engine, the notification service, and the reporting pipeline were unauthenticated HTTP. Anything on the internal network could call these endpoints and receive a response.
  • Database credentials were long-lived and shared. A single application-level database user, with full read/write across all tables, was used by six different services. Credential rotation had not happened in over fourteen months because nobody wanted to coordinate the restart.
  • SSH access was broad. 22 engineers had standing SSH access to production hosts via a shared bastion, with key-based auth and no session recording. There was no just-in-time elevation, access was permanent until someone remembered to revoke it.
  • No segmentation between environments that shared infrastructure. Staging and production shared a Redis cluster for queue processing, separated only by key prefixing in application code. A bug in prefix logic, not a malicious actor, would have been enough to cross environments.
  • Logging existed but was not queryable for identity. VPC flow logs were enabled, but there was no way to answer "which service account made this database query" because the database connection pool masked the originating service.

None of this made the platform insecure in the sense of having an active exploit sitting open. But it meant the entire security posture rested on the outer perimeter holding, and on 22 people never making a mistake with their SSH keys. That is a single point of failure dressed up as defense in depth.

The approach we took and why

Zero trust is a description, not a product. The useful way to implement it is as a set of specific guarantees, verified independently of network location:

  • Every request between services carries verifiable identity, not just a source IP.
  • Access to any resource is granted per request, based on policy, not granted permanently based on network position.
  • Credentials are short-lived and scoped to the minimum required action.
  • All access is logged with enough identity context to answer "who did what" without inference.

We deliberately avoided a rip-and-replace approach. The platform had to keep shipping features during the migration, and a big-bang network redesign is exactly the kind of project that turns into a six-month outage risk. We phased the work in four stages, each independently shippable, each reducing blast radius before moving to the next.

This is the same philosophy we use for zero-downtime migrations generally: break the change into stages where each stage leaves the system in a working, rollback-able state. Security hardening that requires a maintenance window is a hard sell to engineering leadership, and usually unnecessary.

Implementation details

Stage 1: network segmentation

We split the flat VPC into subnets by trust tier: public-facing load balancers, application tier, data tier, and a separate management tier for CI/CD and bastion access. Security groups were rewritten from "allow internal" defaults to explicit allow-lists per service pair. The billing service's security group, for example, went from allowing all traffic from the VPC CIDR to a rule set with four explicit ingress sources, one per service that legitimately needs to call it, each on its specific port.

resource "aws_security_group_rule" "billing_ingress_from_scheduler" {n  type                     = "ingress"n  from_port                = 8443n  to_port                  = 8443n  protocol                 = "tcp"n  security_group_id        = aws_security_group.billing.idn  source_security_group_id = aws_security_group.scheduler.idn}

This alone eliminated the "any instance can reach any instance" problem. It does not solve identity, but it shrinks the attack surface before identity controls are even in place, which matters if the rollout takes weeks.

Stage 2: mutual TLS between services

We introduced a service mesh (Linkerd, chosen over Istio for lower operational overhead given the team's size) to handle mTLS between internal services automatically. Every service got a SPIFFE-based identity issued by the mesh's certificate authority, rotated every 24 hours with no manual intervention. Application code did not need to change, the mesh sidecar handled the handshake.

This converted "any internal caller is trusted" into "only callers holding a valid, short-lived certificate for an authorized identity are trusted," independent of which subnet the traffic originated from. A compromised container can no longer just call the billing API by virtue of being on the network, it needs a valid workload identity, and that identity is scoped to only the routes its policy allows.

Stage 3: credential overhaul

The shared long-lived database user was replaced with per-service IAM-based database authentication using short-lived tokens, refreshed every 15 minutes via the AWS RDS IAM auth integration. Each service's database role was scoped to only the schemas and operations it actually used, verified by replaying three months of query logs against proposed grants before cutting over.

Two services had been using the shared user to run ad hoc administrative queries that had nothing to do with their function, an artifact of a developer debugging something eighteen months earlier and never cleaning it up. We would not have found this without auditing real query logs rather than trusting the documented access model.

Stage 4: access control and session visibility

Standing SSH access was replaced with a just-in-time access system: engineers request time-boxed access (default 45 minutes) through a Slack-integrated approval flow, backed by short-lived SSH certificates signed by an internal CA rather than static keys. All sessions are recorded. The shared bastion was retired entirely.

Staging and production Redis instances were split onto physically separate clusters with network segmentation enforcing the boundary, removing the key-prefix-as-isolation anti-pattern.

We also closed the logging gap: every service-to-service call now logs the SPIFFE identity of both caller and callee, and database audit logging was enabled at the RDS level, giving the security team a queryable record of which service account executed which statement. That single change turned "we think nothing happened" into "we can prove what happened" during the next audit cycle.

Results

The migration ran over nine weeks, phased as described, with zero unplanned downtime. Here is what changed, measured three months after full rollout:

MetricBeforeAfter
Services reachable from a single compromised container (lateral movement surface)All 14 internal servicesAverage of 2.3 per service (only direct dependencies)
Standing SSH access to production22 engineers, permanent0 permanent, time-boxed on request
Database credential lifetime14+ months, shared across 6 services15 minutes, scoped per service
Mean time to answer "who accessed X" during auditNot reliably answerableUnder 5 minutes via query logs
p95 service-to-service latency11ms14ms (mTLS handshake overhead)
Infrastructure cost deltabaseline+6% (mesh control plane, audit log storage)
Uptime during migrationn/a99.98%, no customer-facing incidents

The 3ms latency increase from mTLS was the one tradeoff worth discussing with engineering leadership up front rather than discovering it in production. It was acceptable here because the services in question are not on the hot path for user-facing page loads, they handle background scheduling and notification delivery. For a service where that latency would matter, such as a checkout API, we would have scoped the mesh rollout differently and measured TTFB impact before committing to the architecture.

The enterprise procurement questionnaire that triggered this project was answered six weeks after rollout completed, with concrete numbers rather than assurances. The deal closed. We cannot claim the hardening work was the only factor, but the security team on the buyer's side specifically cited the segmentation model and audit log granularity in their sign-off notes.

What we'd do differently next time

A few things we would change on a repeat engagement:

  • Start the query log audit earlier. We found the stray admin queries from the shared database user in stage 3, but that discovery would have been far less risky in stage 1, before any credential changes were scheduled. Auditing real usage patterns should come before any architecture decisions, not alongside them.
  • Budget more time for the mesh's observability learning curve. The platform team had never operated a service mesh before. The mTLS rollout itself was smooth, but the first two weeks of post-rollout on-call involved engineers misreading mesh-level connection errors as application bugs. A half-day internal training session before cutover, rather than after the first incident, would have saved real time.
  • Negotiate the latency tradeoff conversation before stakeholders see a dashboard change. The 3ms increase was expected and acceptable, but it still generated a Slack thread of concern when someone noticed it on a performance dashboard without context. Flagging expected, bounded regressions ahead of time avoids this kind of noise.
  • Decommission the old bastion host slower, not faster. We retired it in week 7. Two engineers had automation scripts with hardcoded references to it that broke silently. A two-week overlap period with both access paths live, monitored, and clearly labeled as deprecated would have caught this without the Monday morning scramble.

None of these change the overall approach. They are the kind of details that only show up when you have run this migration on a real production system with real engineers who have real habits built around the old model.

Where this fits into a broader security posture

Zero trust segmentation solves lateral movement and identity verification. It does not solve everything. Pair it with regular server hardening and attack surface reduction at the host level, since mTLS between services does nothing for an unpatched kernel vulnerability on the host itself. It also does not replace dependency hygiene, a vulnerable library inside an authenticated, properly segmented service is still a vulnerable library.

The pattern that mattered most in this engagement, and the one we would emphasize to any team considering similar infrastructure security hardening work, is sequencing. Segment the network first because it is low-risk and immediately reduces blast radius. Add identity second because it requires more coordination across teams. Fix credentials third because it touches every service's runtime configuration. Rebuild access control last because it is the most visible change to day-to-day engineering workflow, and teams tolerate it better once they have already seen the earlier stages ship without disruption.

Facing a similar challenge?

Flat trust models are common, not a sign of negligence. Most platforms grow into them gradually, one service at a time, until a procurement questionnaire or an audit forces the question nobody asked directly: what can a single compromised container actually reach?

Facing a similar challenge? Tell us about your setup and we will outline an approach.

Older vulnerabilities are surfacing faster. Read what changed, then review your own code.