Least Privilege Network Access
What you'll learn: How to design security group rules that grant only the minimum network access required, reducing your attack surface.
The Core Principle
Least privilege means giving users, systems, or services only the permissions they absolutely need—nothing more. When applied to network security groups, this means restricting access to:
- Specific sources (not "0.0.0.0/0" for everything)
- Minimal ports (only the ports your service actually uses)
- Necessary protocols (TCP, UDP, ICMP only when required)
Instead of opening port ranges like 1-65535 or allowing traffic from anywhere, you carefully identify exactly who needs access and what they need to do.
Real-World Analogy
Think of a building with many rooms. You wouldn't give every visitor a master key to every door. Instead, you give the janitor access to storage rooms, executives access to conference rooms, and guests access only to the lobby. Similarly, your web server might need port 443 open to the internet, but your database should only accept connections from your application servers—not from everywhere.
Applying Least Privilege
When creating security group rules:
- Identify the source: Use specific IP addresses or security group references instead of "anywhere"
- Specify exact ports: Open port 22 for SSH, not ports 20-25
- Document your rules: Note why each rule exists
- Review regularly: Remove rules that are no longer needed
For example, if only your office needs SSH access to a bastion host, restrict port 22 to your office's public IP address, not to 0.0.0.0/0 (the entire internet).
Key Takeaway: Always grant the minimum network access required—restrict security group rules to specific sources and the fewest ports necessary to reduce exposure to potential attacks.