CYBER SECURITY • CLOUD AND MODERN INFRASTRUCTURE SECURITY

Cloud Network Controls — Explain network controls in cloud (security groups, NACLs) conceptually

Understanding virtual firewalls that govern traffic flow in cloud environments at the instance and subnet level.

Historical Context & Motivation

Traditional data centers relied on physical firewalls, routers with access control lists, and demilitarized zones (DMZs) to segment and protect network traffic. These devices sat at well-defined perimeter boundaries, inspecting packets and enforcing policy through hardware appliances that administrators could physically rack, cable, and configure. When organizations began migrating workloads to cloud computing platforms in the late 2000s, the familiar perimeter dissolved: compute instances spun up in minutes, IP addresses were ephemeral, and the underlying physical network was entirely abstracted away. The question that confronted security engineers was straightforward yet profound — how do you enforce network segmentation and access control when you no longer own, or even see, the physical infrastructure?

2006
AWS Launches EC2
Amazon Web Services introduces Elastic Compute Cloud, enabling on-demand virtual machines. Early network isolation was rudimentary, motivating the need for software-defined network controls.
2009
VPC & Security Groups
AWS introduces Virtual Private Cloud (VPC), allowing customers to define logically isolated networks. Security Groups emerge as stateful, instance-level virtual firewalls, becoming the primary cloud network control.
2011
Network ACLs Added
AWS augments VPC with Network Access Control Lists (NACLs), providing stateless, subnet-level filtering. This gives architects a defense-in-depth layering model reminiscent of traditional firewall tiers.
2014–2018
Multi-Cloud Adoption
Microsoft Azure (Network Security Groups) and Google Cloud (VPC Firewall Rules) ship analogous constructs. The industry converges on a two-tier model — instance-level and subnet-level controls — as a de-facto standard.
2020+
Zero-Trust & Microsegmentation
Organizations layer cloud-native network controls with zero-trust architectures and microsegmentation strategies, using security groups and NACLs as foundational building blocks within broader identity-aware policies.

The central challenge this lesson addresses is: how do cloud providers virtualize the packet-filtering functions of traditional firewalls, and what conceptual distinctions between stateful and stateless controls shape the way you design secure cloud networks? Understanding these controls is essential for anyone deploying or securing infrastructure in AWS, Azure, or GCP.

Core Principles & Definitions

Cloud network controls rest on a small set of foundational ideas that mirror classical network security but adapt them to virtualized, software-defined environments. Before diving into implementation details, it is critical to internalize these principles because they govern every rule you write, every troubleshooting session you face, and every compliance audit you navigate.

1

Defense in Depth

Cloud architects layer multiple controls — security groups at the instance level and NACLs at the subnet level — so a misconfiguration in one layer does not expose the entire network. Each layer independently evaluates traffic.
2

Least Privilege

Rules should permit only the minimum traffic necessary for the workload to function. Security groups default to deny-all inbound; NACLs can be configured to deny everything except explicitly permitted flows.
3

Stateful vs. Stateless

A stateful control (security group) tracks connection state and automatically allows return traffic. A stateless control (NACL) evaluates each packet independently, requiring explicit inbound and outbound rules.
4

Implicit Deny

Both security groups and NACLs use an implicit deny — any traffic not matched by an explicit allow rule is silently dropped. This fail-closed behavior ensures unknown traffic never reaches a workload.
5

Rule Evaluation Order

Security groups evaluate all rules collectively (aggregate allow). NACLs evaluate rules by ascending rule number and stop at the first match. This difference fundamentally affects how you structure policies.
KEY TAKEAWAY
Think of security groups as the lock on your apartment door — they remember who was invited in and automatically let those guests leave. NACLs are like a building lobby security desk that checks every person's badge on the way in and on the way out, with no memory of prior visits. Layering both creates a building that is hard to enter even if one checkpoint fails.

Visual Explanation — Traffic Flow Through Cloud Network Controls

Inbound traffic from the internet first passes through the NACL at the subnet boundary, then through the Security Group attached to the instance. Each subnet has its own NACL, and each instance (or ENI) has its own Security Group. The dashed lines denote subnet boundaries within the VPC.

The diagram above illustrates the layered evaluation model. When a packet arrives from the internet destined for an EC2 instance in a public subnet, it first encounters the subnet's NACL. The NACL evaluates its rules in ascending numeric order and either allows or denies the packet — this evaluation is entirely stateless, meaning the NACL has no memory of prior packets in the same TCP connection. If the NACL permits the packet, it next reaches the security group associated with the instance's Elastic Network Interface (ENI). The security group evaluates all its rules collectively — if any rule matches, the packet is allowed through. Crucially, because the security group is stateful, the return traffic for this connection is automatically permitted without requiring an explicit outbound rule. This two-layer architecture provides defense in depth: even if a security group rule is overly permissive, a restrictive NACL can act as a coarse-grained safety net.

How Cloud Network Controls Work — Rule Evaluation Deep Dive

Security Group Rule Evaluation

A security group acts as a virtual firewall for an individual instance (more precisely, for an Elastic Network Interface). It maintains a connection tracking table so that once a flow is established, return packets are allowed implicitly. Rules specify the protocol (TCP, UDP, ICMP, or All), the port range, and the source or destination — which can be a CIDR block or another security group ID. The evaluation model is aggregate allow: the engine considers all inbound rules together, and if the packet matches any one rule, it is permitted. There is no concept of rule ordering or explicit deny rules. If no rule matches, the implicit deny drops the packet. This design simplifies configuration but means that security groups cannot be used to block a specific IP while allowing a broader range — you must sculpt the CIDR blocks in your allow rules carefully.

NACL Rule Evaluation

A Network Access Control List (NACL) operates at the subnet boundary and is stateless — every packet is evaluated independently against the rule table, regardless of whether it belongs to an established connection. Each rule has a numeric priority (e.g., 100, 200, 300), and the engine processes rules from lowest number to highest, stopping at the first matching rule. This first-match semantics makes NACLs more expressive than security groups because you can insert a low-numbered deny rule (e.g., Rule 50: Deny 198.51.100.0/24) that takes precedence over a higher-numbered allow rule (e.g., Rule 100: Allow 0.0.0.0/0). The catch is complexity: because NACLs are stateless, you must define explicit outbound rules allowing return traffic, typically on ephemeral port ranges (1024–65535 for most operating systems).

Ephemeral Ports — A Common Pitfall
When a client initiates a TCP connection to port 443 on your web server, the server responds to the client on a random ephemeral port (typically in the range 1024–65535). Because NACLs are stateless, you must explicitly allow outbound traffic on this entire ephemeral range, or response packets will be silently dropped — even though the security group's stateful tracking would have allowed them. This is the single most common NACL misconfiguration.
Side-by-side comparison of rule evaluation. The security group (left, cyan border) evaluates all rules together and allows if any rule matches. The NACL (right, amber border) processes rules by ascending number and stops at the first match, enabling explicit deny entries such as Rule 50.

Security Groups vs. NACLs — Detailed Comparison

While both security groups and NACLs filter traffic, they differ along several important dimensions. The table below provides a comprehensive feature-by-feature comparison that every cloud security practitioner should internalize. These distinctions directly affect how you troubleshoot connectivity issues, how you satisfy compliance requirements, and how you architect multi-tier applications.

Feature comparison: Security Groups vs. NACLs
AttributeSecurity GroupNetwork ACL (NACL)
ScopeInstance (ENI) levelSubnet level
StatefulnessStateful — return traffic auto-allowedStateless — must allow return traffic explicitly
Rule TypesAllow rules onlyAllow and Deny rules
EvaluationAll rules evaluated; any match permitsRules processed in numeric order; first match wins
Default BehaviorDeny all inbound; allow all outboundDefault NACL allows all; custom NACLs deny all
AssociationMultiple SGs per instance; SG shared across instancesOne NACL per subnet; one NACL can span subnets
Source/Dest ReferenceCIDR blocks or other security group IDsCIDR blocks only
Typical Use CaseFine-grained instance-level controls; micro-segmentationCoarse-grained subnet guardrails; IP blocklisting

One of the most powerful features of security groups is the ability to reference another security group as a traffic source. For example, you can create a rule that says "allow TCP 3306 from sg-web-tier," which automatically permits database access from any instance associated with the web-tier security group, regardless of that instance's IP address. This abstraction decouples policy from ephemeral addressing and is a cornerstone of cloud-native microsegmentation. NACLs, by contrast, can only reference CIDR blocks, making them more suitable for broad, network-range policies like blocking an entire suspicious IP range.

Worked Example — Designing Controls for a Three-Tier Web Application

Consider a classic three-tier architecture deployed in AWS: a web tier in a public subnet, an application tier in a private subnet, and a database tier in another private subnet. The goal is to configure security groups and NACLs so that internet users can reach the web servers on HTTPS (port 443), the web servers can reach the application servers on port 8080, and the application servers can reach the database on port 5432 (PostgreSQL). No other traffic should be permitted.

Configuring Security Groups and NACLs for a Three-Tier Architecture
1
Step 1 — Define Security Groups by TierCreate three security groups: sg-web, sg-app, and sg-db. Each SG starts with the default implicit deny on inbound and allow-all on outbound. Assign sg-web to web instances, sg-app to app instances, and sg-db to database instances.
Three empty security groups created and associated with their respective instances.
2
Step 2 — Configure sg-web Inbound RulesAdd an inbound rule: Protocol TCP, Port 443, Source 0.0.0.0/0 (all internet). This permits HTTPS from anywhere. Because security groups are stateful, the response traffic on the ephemeral port back to the client is automatically allowed — no outbound rule is needed for return traffic.
sg-web inbound: TCP 443 from 0.0.0.0/0 → ALLOW
3
Step 3 — Configure sg-app Inbound RulesAdd an inbound rule: Protocol TCP, Port 8080, Source sg-web. By referencing the web security group rather than a CIDR, the rule dynamically includes any instance in sg-web, even as instances scale in and out via auto-scaling. No internet traffic can reach sg-app because no rule allows 0.0.0.0/0.
sg-app inbound: TCP 8080 from sg-web → ALLOW
4
Step 4 — Configure sg-db Inbound RulesAdd an inbound rule: Protocol TCP, Port 5432, Source sg-app. This ensures only application-tier instances can reach the database. Web-tier instances cannot connect to the database directly because sg-web is not referenced.
sg-db inbound: TCP 5432 from sg-app → ALLOW
5
Step 5 — Configure NACL for the Public Subnet (Defense in Depth)On the NACL for the web tier's public subnet, add the following inbound rules: Rule 100 — Allow TCP 443 from 0.0.0.0/0; Rule 200 — Allow TCP 1024–65535 from 0.0.0.0/0 (for return traffic from outgoing connections the web server initiates). Add outbound rules: Rule 100 — Allow TCP 1024–65535 to 0.0.0.0/0 (ephemeral ports for HTTPS responses); Rule 200 — Allow TCP 8080 to 10.0.2.0/24 (the app subnet CIDR, so the web server can reach the app tier). The catch-all rule * denies everything else.
NACL provides subnet-level guardrails ensuring that even a misconfigured security group cannot open unexpected ports to the internet.
🔒 DESIGN PRINCIPLE
Always design security groups first — they are your precision scalpel. Then overlay NACLs as a safety net, like a circuit breaker that trips if the scalpel slips. In practice, many teams leave NACLs at their default (allow-all) and rely on security groups for fine-grained control. However, for compliance-sensitive workloads (PCI-DSS, HIPAA), explicitly configuring NACLs to deny broad categories of traffic demonstrates defense in depth to auditors.

Strengths, Limitations, and Cross-Provider Comparison

No single network control is a silver bullet. Security groups and NACLs each have distinct strengths and limitations that influence architectural decisions. Understanding these trade-offs allows you to choose the right tool — or combination of tools — for each layer of your cloud infrastructure.

Strengths and limitations of cloud network controls
DimensionStrengthsLimitations
Security GroupsStateful (simplifies rules), SG-to-SG references decouple policy from IPs, easy to manage at scale via IaC, multiple SGs per instance for composable policiesCannot create deny rules, limited to ~60 inbound + 60 outbound rules per SG (varies by provider), no logging by default (requires VPC Flow Logs), cannot filter by domain name
NACLsSupports explicit deny (IP blocklisting), subnet-wide enforcement, provides secondary layer independent of SGs, numbered rules offer ordered precedenceStateless (requires ephemeral port management), CIDR-only references, harder to maintain at scale, applies uniformly to all instances in the subnet

Cross-Provider Analogues

Cross-provider comparison of network control constructs
ConceptAWSAzureGCP
Instance-Level ControlSecurity GroupNetwork Security Group (NSG)VPC Firewall Rules (target tags/service accounts)
Subnet-Level ControlNACLNSG (can attach to subnet)VPC Firewall Rules (network tags)
StatefulnessSG: Stateful; NACL: StatelessNSG: StatefulFirewall Rules: Stateful
Deny RulesNACL onlyNSG supports Allow and DenyFirewall Rules support Allow and Deny
KEY TAKEAWAY
AWS's separation of stateful (SG) and stateless (NACL) controls is unique — Azure and GCP consolidate both behaviors into a single stateful construct with support for deny rules. When studying for cloud certifications or designing multi-cloud architectures, map the conceptual model (instance-level vs. subnet-level, allow vs. deny, stateful vs. stateless) rather than memorizing provider-specific names.

Connection to Advanced Network Security Architectures

Security groups and NACLs represent the foundational layer of cloud network security, but modern architectures extend well beyond these basic controls. As you advance in cloud security, you will encounter constructs that build on top of — or complement — these primitives to provide deeper inspection, broader policy expression, and stronger identity-awareness.

Progression from foundational to advanced cloud network security controls
Basic ControlAdvanced ControlWhat It Adds
Security Groups (L3/L4 filtering)AWS Network Firewall / Azure Firewall (L7 filtering)Deep packet inspection, IDS/IPS signatures, domain-based filtering, TLS inspection
NACLs (CIDR-based deny)AWS WAF / Azure Front Door WAFApplication-layer (HTTP) rule sets, bot detection, geo-blocking, rate limiting
SG-to-SG references (identity via group)Service Mesh (Istio, Linkerd) / Zero-Trust mTLSWorkload identity via certificates, per-request authorization, encrypted service-to-service communication
VPC Flow Logs (passive logging)Cloud SIEM / Traffic MirroringReal-time anomaly detection, behavioral analytics, full packet capture for forensics

The concept of microsegmentation represents the logical evolution of security group policies. Instead of broadly segmenting by subnet (a "zone-based" approach), microsegmentation assigns unique policies to every individual workload, often combining security group rules with service mesh policies and identity-aware proxies. In a zero-trust architecture, the network is assumed hostile, and every communication must be authenticated, authorized, and encrypted — regardless of whether it originates from inside or outside the VPC. Security groups and NACLs remain the bedrock on which these advanced architectures are built, enforcing coarse network reachability while higher-layer controls handle identity and application-level authorization.

🚀 Looking Ahead
In subsequent modules, you will learn how Infrastructure as Code (Terraform, CloudFormation) automates security group and NACL provisioning, how VPC Flow Logs feed into SIEM platforms for threat detection, and how managed firewall services extend L3/L4 controls into full L7 inspection. The mental model you build here — layered, least-privilege, defense-in-depth — scales directly to those advanced topics.

Practice Problems

PROBLEM 1CONCEPTUAL
Explain why a security group does not need an explicit outbound rule to allow return traffic for an inbound HTTPS connection, whereas a NACL does. What fundamental property distinguishes the two?
PROBLEM 2BASIC CALCULATION
A NACL has the following inbound rules: Rule 100 — Allow TCP 443 from 0.0.0.0/0; Rule 150 — Deny TCP 443 from 192.168.1.0/24; Rule 200 — Allow TCP 22 from 10.0.0.0/8; Rule * — Deny All. A packet arrives on TCP port 443 from source IP 192.168.1.50. Is the packet allowed or denied? Explain by tracing the rule evaluation.
PROBLEM 3INTERMEDIATE
You have a web server in a public subnet and a database in a private subnet. The web server's security group (sg-web) allows inbound TCP 443 from 0.0.0.0/0. The database's security group (sg-db) allows inbound TCP 3306 from sg-web. The private subnet's NACL denies all inbound traffic except TCP 3306 from the public subnet's CIDR (10.0.1.0/24). You add a new application server in the public subnet (also in sg-web) that needs to query the database. Will it work without any changes? If not, what must you modify?
PROBLEM 4APPLIED
Your security team discovers that a botnet at IP range 203.0.113.0/24 is sending malicious traffic to your web servers. You need to block this range immediately while continuing to allow all other HTTPS traffic. Which control (security group or NACL) should you use, and how would you configure it? Justify your choice.
PROBLEM 5CRITICAL THINKING
A colleague argues that NACLs are unnecessary overhead — since security groups are stateful and easier to manage, they should be the only network control, and NACLs should be left at their default allow-all configuration. Construct a counterargument identifying at least three scenarios where NACLs provide value that security groups alone cannot deliver.

Summary — Cloud Network Controls

Cloud network controls replicate the packet-filtering functions of traditional firewalls in software-defined form. Security groups operate at the instance (ENI) level and are stateful, meaning they track connection state and automatically allow return traffic. They support only allow rules, evaluate all rules collectively (aggregate match), and can reference other security group IDs — enabling powerful microsegmentation patterns decoupled from IP addresses. NACLs operate at the subnet boundary and are stateless, requiring explicit rules for both directions of a flow and careful management of ephemeral ports.

The layering of these controls embodies the principle of defense in depth: security groups provide fine-grained, instance-level precision, while NACLs add a coarse-grained subnet-level safety net with the ability to explicitly deny traffic — a capability security groups lack. Both controls default to implicit deny, enforcing a fail-closed posture. Understanding the interplay between stateful and stateless evaluation, aggregate vs. first-match rule processing, and instance-level vs. subnet-level scope is essential for designing secure, compliant cloud architectures — and for diagnosing the connectivity issues that inevitably arise in production environments.

Varsity Tutors • Cyber Security • Cloud Network Controls — Explain network controls in cloud (security groups, NACLs) conceptually