SECURITY ENGINEERING · PART 10 · CLOUD SECURITY · NETWORK · 140 OF 229

Security Groups vs NACLs and Private Endpoints

Even though identity is the perimeter, network controls still cut off whole classes of attack. This episode covers cloud networking for security: VPCs and subnets, security groups versus network ACLs, keeping databases private, private endpoints that avoid the internet entirely, egress filtering to stop data exfiltration, and why "private by default" is the rule that prevents exposed-service breaches.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 9
  9. 10
  10. 11
  11. 12
  12. 13
  13. 14
  14. 15
  15. 16
  16. 17
  17. 18
  18. 19
  19. 20
  20. 21
  21. 22
  22. 23
  23. 24
  24. 25
  25. 26
  26. 27
  27. 28
  28. 29
  29. 30
  30. 31
  31. 32
  32. 33
  33. 34
  34. 35
  35. 36
  36. 37
  37. 38
  38. 39
  39. 40
  40. 41
  41. 42
  42. 43
  43. 44
  44. 45
  45. 46
  46. 47
  47. 48
  48. 49
  49. 50
  50. 51
  51. 52
  52. 53
  53. 54
  54. 55
  55. 56
  56. 57
  57. 58
  58. 59
  59. 60
  60. 61
  61. 62
  62. 63
  63. 64
  64. 106
  65. 107
  66. 108
  67. 109
  68. 110
  69. 111
  70. 112
  71. 113
  72. 114
  73. 115
  74. 116
  75. 117
  76. 118
  77. 119
  78. 120
  79. 121
  80. 122
  81. 123
  82. 124
  83. 125
  84. 126
  85. 127
  86. 128
  87. 129
  88. 130
  89. 131
  90. 132
  91. 133
  92. 134
  93. 135
  94. 136
  95. 137
  96. 138
  97. 139
  98. 140
  99. 141
  100. 142
  101. 143
  102. 144
1 / 10

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Private by default
  • security groups reference each other
  • NACLs as backup
  • private endpoints
  • filter egress

Notes

VPCs and subnets

The foundation is a VPC, your own isolated virtual network. You split it into subnets: public versus private. A public subnet can reach the internet and is where internet-facing things live, mainly load balancers. A private subnet has no direct internet path, and that is where your applications and databases belong. The goal is that almost everything lives private, and only a thin, deliberate layer is exposed. Most exposed-service breaches are something private placed where it should not be.

The basic layout
  • VPC: your isolated virtual network in the cloud
  • public subnet: can reach the internet (load balancers, gateways)
  • private subnet: no direct internet path (apps, databases)
  • the goal: almost everything lives private

Security groups

The main control you will use is the security group: a virtual firewall attached to each resource. It is stateful, so if you allow a request in, the reply is allowed out automatically. It is allow-only: you list what is permitted, and everything else is denied by default. Best practice is to reference other security groups rather than IP addresses, allow from the app group to the database group, so rules follow your architecture instead of brittle address ranges. This is your everyday network tool.

Security groups
  • a virtual firewall on each resource (instance, DB)
  • stateful: return traffic is allowed automatically
  • allow-only: you list what is permitted, deny is implicit
  • reference other groups: "allow from the app group", not IPs
  • the main tool you will use daily

Security groups vs NACLs

People often confuse security groups with network ACLs. A security group sits on the resource, is stateful, and is allow-only. A network ACL sits on the subnet, is stateless, meaning you allow both directions, and supports explicit deny as well as allow. ACLs are coarse and act as a backup layer, for example blocking a known-bad IP range across a whole subnet. In practice security groups do most of the work, and ACLs are an occasional, broad-strokes control.

SG vs network ACL
  • security group: on the resource, stateful, allow- only network ACL: on the subnet, stateless, allow AND deny
  • NACLs are coarse, a backup layer (e.g. block a bad IP range for a whole subnet)
  • security groups do most of the work

Private endpoints

A powerful but underused control is private endpoints. By default, when your workload talks to a managed cloud service like storage, that traffic may go out over the internet, even though both ends are in the same cloud. A private endpoint creates a private link from your VPC directly to the service, so traffic never touches the public internet. No public IP, a smaller attack surface, often lower cost. For sensitive flows, private endpoints are the difference between internal and internet-exposed.

Avoid the internet entirely
  • by default, reaching a cloud service (storage, DB) may go over the internet
  • private endpoints: a private link from your VPC to the service
  • traffic never leaves the cloud backbone
  • no public IP, smaller attack surface, often cheaper too

Egress filtering

People lock down inbound traffic but leave outbound wide open. Attackers rely on open egress to send your data out and reach their command-and-control servers. So filter egress too: restrict outbound traffic to known destinations, using an egress proxy or firewall to allowlist where workloads may connect. This stops data exfiltration and limits what a compromised workload can do, since it cannot phone home or reach the internet freely. Outbound control is a quietly powerful defence.

Outbound matters too
  • most rules focus on inbound; outbound is often wide open
  • attackers use open egress to exfiltrate data and reach command-and-control servers
  • restrict outbound to known destinations
  • egress proxy or firewall for allowlisting
  • also limits a compromised workload

Private by default

All of this reduces to one rule: private by default. Nothing is reachable from the internet unless there is a clear, deliberate reason. Databases, caches and internal APIs are always private. The only public surface is a load balancer in front of your web tier. No data store ever has a public IP. And because mistakes happen, you continuously scan for anything unexpectedly public, which is what the posture tools in coming episodes do. Private by default prevents the exposed-service breaches from episode two.

The core rule
  • nothing is public unless there is a clear reason
  • databases, caches, internal APIs: always private
  • expose only via a load balancer or gateway
  • no public IPs on data stores
  • scan for anything unexpectedly public (CSPM, next episodes)

Common mistakes

Mistakes. A database in a public subnet with a public IP, reachable from anywhere. A security group open to the whole internet on sensitive ports like the database or SSH, which scanners find instantly. Wide-open outbound traffic that lets a compromise exfiltrate freely. Rules written by IP address that drift, instead of referencing security groups. No private endpoints for sensitive flows. And relying on network controls alone while neglecting identity, when you need both.

Avoid these
  • a database in a public subnet with a public IP
  • security group open to 0.0.0.0/0 on sensitive ports
  • wide-open outbound/egress
  • rules by IP that drift, not by security group
  • no private endpoints for sensitive data flows
  • relying on network alone, not identity too

Say it like this

In the interview: I design networks private by default. Applications and databases live in private subnets with no internet path, and only a load balancer is public. I use security groups that reference each other rather than IP addresses, with network ACLs as a coarse subnet-level backup. I use private endpoints so sensitive traffic never crosses the internet, and I filter egress to stop exfiltration and command-and-control callbacks. And I treat network security as defence in depth alongside identity.

In the interview
  • "Private by default: apps and databases in private subnets, only a load balancer public.
  • Security groups referencing
  • each other, not IPs; NACLs as a coarse backup. Private
  • endpoints so sensitive traffic
  • avoids the internet, and egress
  • filtering to stop exfiltration.
  • Defence in depth with IAM."

Interview questions

Q1What is the difference between a security group and a network ACL?

A security group is a stateful, allow-only firewall attached to individual resources, where return traffic is permitted automatically. A network ACL is a stateless firewall at the subnet level supporting both allow and deny rules. Security groups do most of the work; ACLs are a coarse backup layer.

Q2What is a VPC and why split it into public and private subnets?

A VPC is your isolated virtual network in the cloud. Public subnets can reach the internet and host internet-facing resources like load balancers, while private subnets have no direct internet path and host applications and databases, keeping most resources unreachable from outside.

Q3Why reference security groups instead of IP addresses in rules?

Because referencing another security group (for example, allow traffic from the app group to the database group) makes rules follow the architecture and update automatically as resources change, avoiding brittle, drifting IP-based rules.

Q4What are private endpoints and why use them?

Private endpoints create a private link from your VPC directly to a managed cloud service, so traffic never traverses the public internet. They remove the need for public IPs, reduce attack surface, and keep sensitive data flows internal.

Q5Why is egress (outbound) filtering important?

Attackers use open outbound access to exfiltrate data and reach command-and-control servers. Restricting outbound traffic to known destinations, often via an egress proxy or firewall, stops data exfiltration and limits what a compromised workload can do.

Q6What does "private by default" mean in cloud networking?

The principle that nothing is reachable from the internet unless there is a clear, deliberate reason. Databases, caches and internal APIs stay private, only a load balancer or gateway is public, and no data store has a public IP. It prevents most exposed-service breaches.

Q7Why do network controls still matter if identity is the perimeter?

Because they provide defence in depth: a resource with no internet path cannot be reached from outside regardless of permissions, cutting off entire classes of attack before identity is even evaluated. Network and identity controls are complementary, not alternatives.

Q8How do databases end up exposed to the internet?

Usually by being placed in a public subnet with a public IP, or behind a security group open to 0.0.0.0/0 on the database port. Internet-wide scanners find these quickly, so databases should always be private with tightly scoped security groups.