Course contentsShow
← Security
Lesson 1820 of 3,05237. Cloud Security - Network ArchitectureFree lesson

Security Group Architecture and Rule Evaluation

How security groups attach to instances, default deny behavior, stateful connection tracking, and rule processing logic.

Security Group Architecture and Rule Evaluation

What you'll learn: How security groups attach to network interfaces, process rules with default-deny logic, and maintain stateful connections.

How Security Groups Attach

Security groups attach to elastic network interfaces (ENIs), not directly to instances. Each ENI can have up to five security groups. When you launch an instance, the default network interface automatically gets the security group you specify. This architectural choice means:

  • The same security group can protect multiple instances
  • An instance with multiple ENIs can have different security groups per interface
  • Security groups evaluate traffic before it reaches the operating system

Think of security groups as bouncers stationed at each network card—they decide who gets in or out before anyone reaches the door.

Default Deny and Stateful Behavior

Security groups follow implicit deny: if no rule explicitly allows traffic, it's blocked. Unlike network ACLs, you cannot write explicit deny rules—everything not permitted is automatically denied.

The critical feature is stateful connection tracking. When an outbound connection is allowed, the return traffic is automatically permitted, regardless of inbound rules. If your instance makes an HTTP request outbound, the response flows back in—no inbound rule needed.

Rule Processing Logic

Security groups evaluate rules with this logic:

  1. All rules are evaluated simultaneously (not sequentially like ACLs)
  2. If any rule permits the traffic, it's allowed
  3. Rules specify: protocol, port range, and source/destination (IP range or another security group)
  4. Most permissive rule wins

When you reference another security group as the source/destination, you're saying "allow traffic from any instance with that security group attached"—a powerful pattern for micro-segmentation.

Key Takeaway: Security groups are stateful, instance-level firewalls attached to ENIs that use default-deny logic and evaluate all rules simultaneously, automatically permitting return traffic for established connections.