AWS Builder Center
Understanding AWS Security Groups: A Cybersecurity Perspective

Understanding AWS Security Groups: A Cybersecurity Perspective

While learning AWS, I wanted to understand how traditional network security concepts apply to cloud infrastructure. This article explores Amazon VPC security groups, inbound and outbound rules, stateful filtering, and practical ways to reduce unnecessary network exposure.

Series: AWS Cybersecurity Learning Series (5 articles)

  1. …
  2. 4
    Understanding AWS Security Groups: A Cybersecurity Perspective This article

Understanding AWS Security Groups: A Cybersecurity Perspective

Coming from a cybersecurity background, I am familiar with the importance of firewalls and controlling network traffic. While learning AWS, I wanted to understand how these concepts are implemented within a cloud environment.
One service that caught my attention is Amazon Virtual Private Cloud (Amazon VPC), particularly its security groups. They act as virtual firewalls for controlling traffic to and from supported AWS resources.
In this article, I will explore how security groups work, how their rules are evaluated, and what I learned about configuring them with security in mind.

1. What Is an AWS Security Group?

An AWS security group controls the inbound and outbound traffic allowed for the resources it is associated with, such as an Amazon EC2 instance.
When a security group is attached to an EC2 instance, its rules help determine which network connections are permitted to reach the instance and which outbound connections are allowed.
For example, consider a web server that hosts a website. It might need to accept HTTP or HTTPS traffic from visitors, while administrative access should be restricted to authorized sources.
Rather than allowing every type of connection, we can define rules according to the application's actual requirements.

2. Understanding Inbound and Outbound Rules

Security groups have two main types of rules.
Inbound rules control traffic entering the associated resource.
Examples include:
  • HTTPS traffic on TCP port 443
  • HTTP traffic on TCP port 80
  • SSH connections on TCP port 22 from an authorized IP address
Outbound rules control traffic leaving the associated resource.
For example, a server might need to connect to an external API or retrieve software updates.
Each rule specifies details such as the protocol, port range, and source or destination. This allows network access to be restricted according to the requirements of a workload.
New security groups have no inbound rules by default, so inbound traffic is not permitted until rules are added. Their initial outbound rules normally allow all outbound traffic, which administrators can restrict when appropriate.

3. A Practical Example: Securing a Web Server

Imagine an EC2 instance hosting a website.
The server needs to accept HTTPS connections from visitors, but SSH administration should only be available from an authorized management IP address.
A simplified rule design could look like this:
DirectionProtocolPortSource or destination
InboundTCP4430.0.0.0/0
InboundTCP22Authorized administrator IP /32
OutboundAs requiredAs requiredDestinations needed by the application
Here, 0.0.0.0/0 represents all IPv4 addresses. Allowing it on port 443 can be appropriate for a publicly accessible website, but using it for SSH would expose the SSH service to connection attempts from anywhere on the IPv4 internet.
The SSH rule is therefore restricted to a specific administrator IP address. IPv6 access must also be considered separately if it is enabled.
The outbound rules should be designed around the application's requirements rather than automatically allowing unnecessary traffic.
The important lesson is that a port should be accessible only to the sources that need it.

4. What Does Stateful Filtering Mean?

One concept I found particularly useful while learning security groups is that they are stateful.
Suppose an EC2 instance receives an allowed HTTPS request from a visitor. The response traffic associated with that connection is automatically permitted by the security group, regardless of the outbound rules.
Similarly, when an instance initiates an allowed outbound connection, the response traffic is automatically permitted back into the instance.
This differs from a stateless firewall, where the return traffic must also satisfy the relevant rules independently.
Understanding this distinction helps explain why security group rules do not always need separate entries for response traffic.

5. Security Groups vs. Network ACLs

Another important distinction is between security groups and network access control lists (network ACLs).
Both help control network traffic within an Amazon VPC, but they operate differently.
FeatureSecurity groupsNetwork ACLs
ScopeAssociated resources or network interfacesSubnets
FilteringStatefulStateless
RulesAllow rules onlyAllow and deny rules
EvaluationAll applicable rules are consideredRules are evaluated in ascending order
Return trafficAutomatically permitted for allowed connectionsMust be explicitly allowed by applicable rules
Security groups are generally the primary mechanism for controlling access to resources in a VPC. Network ACLs can provide an additional layer of subnet-level control.
For example, a security group can restrict access to a particular EC2 instance, while a network ACL can provide additional traffic restrictions for the subnet containing that instance.
These controls complement each other rather than replacing the need to understand the network architecture.

6. Common Configuration Mistakes

While exploring network security, I found it useful to consider how seemingly convenient configurations can increase exposure.
Some examples include:
Allowing administrative ports from anywhere
Opening SSH (port 22) or RDP (port 3389) to all IPv4 addresses can expose remote administration services to unwanted connection attempts. Restrict these sources wherever possible.
Allowing more ports than necessary
A server that only needs to serve HTTPS traffic generally should not expose unrelated application or database ports to the internet.
Ignoring outbound access
Inbound restrictions alone do not describe the complete network security posture. Unnecessarily broad outbound permissions can also increase risk.
Reusing rules without reviewing requirements
Different applications have different connectivity needs. A rule appropriate for a public web server might be inappropriate for a database or an internal service.
Treating a security group as the entire security solution
Security groups are only one layer of protection. Application vulnerabilities, identity permissions, exposed credentials, and other security concerns still need to be addressed.

7. How I Want to Practise This

As I continue learning AWS, I want to explore security groups in a small test environment.
A useful exercise would be to configure a test EC2 instance with a deliberately simple set of rules and observe how connectivity changes.
For example:
  1. Allow HTTPS from an appropriate source.
  2. Restrict SSH to an authorized management IP address.
  3. Attempt connections from permitted and unpermitted sources.
  4. Review the rules and investigate unexpected connectivity results.
  5. Examine VPC Flow Logs, if enabled, to help understand observed network traffic.
This would help me connect the configuration shown in the AWS console with the network behavior I observe.
Any testing should be performed on resources I own or am authorized to access, with appropriate cost and security precautions.

Conclusion

Learning about AWS security groups has helped me connect familiar firewall concepts with the way network access is managed in cloud infrastructure.
The main lesson I took away is that network security is not simply about opening or closing ports. It involves understanding which resources need to communicate, which protocols and ports are required, and which sources should be permitted to connect.
Security groups provide a practical way to express these requirements in AWS. When combined with suitable network architecture, carefully scoped rules, and other security controls, they help reduce unnecessary network exposure.
As I continue this AWS cybersecurity learning series, I want to explore how network-level controls work alongside identity permissions, logging, and threat detection to build a more complete understanding of cloud security.

Series: AWS Cybersecurity Learning Series (5 articles)

  1. …
  2. 4
    Understanding AWS Security Groups: A Cybersecurity Perspective This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article