Cybersecurity/AWS Cybersecurity papers/AWS Communication hardening guide: Difference between revisions

From Cramsession
Jump to navigationJump to search
✍️ Verified Author: Mflavell • Click to view professional profile & credentials
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
=== Core Concepts ===
=== Core Concepts ===
This post examines the core principles of communication security within the AWS environment, emphasizing the protection of subnets and hosts through the appropriate configuration of security groups and network access control lists. Notably, this design does not incorporate a Web Application Firewall (WAF); in a production environment, the implementation of a WAF is essential.
This post examines the core principles of communication security within the AWS environment, emphasizing the protection of subnets and hosts through the appropriate configuration of security groups and network access control lists. Notably, this design does not incorporate a Web Application Firewall (WAF); in a production environment, the implementation of a WAF is essential. An additional point in this design is that the private subnet has no access to the internet, this provides a final line of defense. If a host on the private subnet is compromised data cannot be directly exfiltrated.


=== High level network design ===
=== High level network design ===
Line 9: Line 9:
     +------ Public subnet ---+
     +------ Public subnet ---+
     |                        |
     |                        |
  [NAT GW]              [Webserver]
    =                  [Webserver]
     |                       |  |
     |                          
     +---+- Private Subnet ---+   +---[Gateway]
     +---+- Private Subnet ---+  
         |
         |                    |
     [Private server]
     [Private server]    [Endpoint]


=== Securing the web server ===
=== Securing the web server ===
Line 31: Line 31:
* Outbound:
* Outbound:
** All traffic - allow
** All traffic - allow


===== Why this approach works =====
===== Why this approach works =====
Only the critical ports required for the web servers on the public subnet are open (80 and 443). As NACL's are stateless the empirical ports are included. As it should, SSH access to servers on the public subnet is caught by the "deny all" rule. SSH access to these servers must be performed through SSM.
Only the critical ports required for the web servers on the public subnet are open (80 and 443). As NACL's are stateless the empirical ports are included - these are a must. As it should, SSH access to servers on the public subnet is caught by the "deny all" rule. SSH access to these servers must be performed through [[Computer Notes/AWS/Setting up Session Manager on Ubuntu|SSM]].
 
 
 
==== Setting Security groups on the web server ====
Think of this as an additional layer of defense that protects against [[North / South & East West Network Security|east-west propagation]] of traffic, additionally any errors or omissions at the NACL level are unlikely to make it to the web server itself. Overall it is important to consider that only five security groups can be assigned to an instance, therefore these should be simple and direct. Additionally unlike the NACL mentioned above security rules are "stateful" - IE the track the state of a connection and do not require rules for replies.
 
 
What to include in the security group:
*Inbound:
** 80 - IPv4 and IPv6 allow
** 443 - IPv4 and IPv6 allow
 
* Outbound:
** All traffic - IPv4 allow
** All traffic - IPv6 allow
 
 
 
===== Why this approach works =====
This provides the base HTTPS communication functions for the web server while allowing all outbound traffic for updates / etc. However outbound traffic can also be locked down (given the stateful nature of the security group) if required. Naming this group "WebServers" gives you a template that can be re-used for all web servers. Security groups do not require a deny rule due to their explicit "deny all" therefore a deny is not required. As SSH connections are made via SSM port 22 is not required enhancing security.
 
 
 
=== Securing the private subnet ===
 
 
 
==== Providing access to SSM without internet access ====
A key point in this design it that data cannot be exfiltrated directly from hosts on the private subnet, indeed the private subnet has no direct contact with the outside world. This however presents unique challenges connecting to hosts on this subnet. Again in our approach SSM is used for connections. An important note is that the private subnet has no access to a NAT gateway as this removes the logical air gapping we are attempting to create in this paper.
 
 
 
==== Create an endpoint security group ====
 
* Go to '''EC2 Console -> Security Groups''' and click '''Create security group'''.
* Name it something like <code>SSM-Endpoint-SG</code>.
* '''Inbound Rule:''' Add '''HTTPS (Port 443)''' and set the source to your VPC's IPv4 CIDR block (e.g., <code>10.0.0.0/16</code>).
* '''Outbound Rule:''' Leave the default (All traffic to <code>0.0.0.0/0</code>). ''Verification:'' The new Security Group explicitly allows inbound port 443 traffic from the entire VPC network.
 
 
 
==== Create the endpoint for secure connections ====
You must create 3 separate endpoints.
Session Manager requires three specific AWS services to function over PrivateLink. Go to '''VPC Console -> Endpoints''' and click '''Create endpoint'''. You will need to repeat this process three times, once for each of these services:
* <code>com.amazonaws.[your-region].ssm</code> (Handles core Systems Manager requests)
* <code>com.amazonaws.[your-region].ssmmessages</code> (Handles the Session Manager terminal tunnel)
* <code>com.amazonaws.[your-region].ec2messages</code> (Handles SSM Agent status and replies)
 
 
'''For each of the three endpoints, configure the following:'''
 
# Select the '''VPC''' where your EC2 instance lives.
# Under '''Subnets''', select the private subnet(s) where your instance is located.
# Under '''Security groups''', select the <code>SSM-Endpoint-SG</code> you created in Step 1.
# '''Critical:''' Ensure '''Enable DNS name''' is checked. This tricks the SSM agent into routing standard AWS API calls to your private internal IPs instead of the public internet.  ''Verification:'' In the VPC Endpoints console, all three endpoints show a status of "Available".
 
 
Finally, start an EC2 instance on the private subnet.
 
Using ping validate that the internet cannot be reached:
ping www.google.com
PING www.google.com (142.251.152.119) 56(84) bytes of data.
^C
--- www.google.com ping statistics ---
21 packets transmitted, 0 received, 100% packet loss, time 20816ms
 
=== Accessing the Private subnet from public servers ===
With the basic structure now established the public / private boundaries can be controlled by adding ingress rules to the NACL for the private subnet.

Latest revision as of 06:22, 6 November 2026

Core Concepts

This post examines the core principles of communication security within the AWS environment, emphasizing the protection of subnets and hosts through the appropriate configuration of security groups and network access control lists. Notably, this design does not incorporate a Web Application Firewall (WAF); in a production environment, the implementation of a WAF is essential. An additional point in this design is that the private subnet has no access to the internet, this provides a final line of defense. If a host on the private subnet is compromised data cannot be directly exfiltrated.

High level network design

[Internet]
    |
  [IGW]
    |
    +------ Public subnet ---+
    |                        |
    =                   [Webserver]
    |                           
    +---+- Private Subnet ---+ 
        |                    |
    [Private server]     [Endpoint]

Securing the web server

Securing the public subnet

The key to securing the public subnet is ensuring the concept of least permission is applied to the NACL (Network Access control lists) governing data flow to the public subnet.


What to include:

  • Inbound:
    • Port 80 / 443 inbound for HTTP / HTTPS requests
    • Port 1024 - 65535 - Empirical
    • Deny all other inbound ports
  • Outbound:
    • All traffic - allow


Why this approach works

Only the critical ports required for the web servers on the public subnet are open (80 and 443). As NACL's are stateless the empirical ports are included - these are a must. As it should, SSH access to servers on the public subnet is caught by the "deny all" rule. SSH access to these servers must be performed through SSM.


Setting Security groups on the web server

Think of this as an additional layer of defense that protects against east-west propagation of traffic, additionally any errors or omissions at the NACL level are unlikely to make it to the web server itself. Overall it is important to consider that only five security groups can be assigned to an instance, therefore these should be simple and direct. Additionally unlike the NACL mentioned above security rules are "stateful" - IE the track the state of a connection and do not require rules for replies.


What to include in the security group:

  • Inbound:
    • 80 - IPv4 and IPv6 allow
    • 443 - IPv4 and IPv6 allow
  • Outbound:
    • All traffic - IPv4 allow
    • All traffic - IPv6 allow


Why this approach works

This provides the base HTTPS communication functions for the web server while allowing all outbound traffic for updates / etc. However outbound traffic can also be locked down (given the stateful nature of the security group) if required. Naming this group "WebServers" gives you a template that can be re-used for all web servers. Security groups do not require a deny rule due to their explicit "deny all" therefore a deny is not required. As SSH connections are made via SSM port 22 is not required enhancing security.


Securing the private subnet

Providing access to SSM without internet access

A key point in this design it that data cannot be exfiltrated directly from hosts on the private subnet, indeed the private subnet has no direct contact with the outside world. This however presents unique challenges connecting to hosts on this subnet. Again in our approach SSM is used for connections. An important note is that the private subnet has no access to a NAT gateway as this removes the logical air gapping we are attempting to create in this paper.


Create an endpoint security group

  • Go to EC2 Console -> Security Groups and click Create security group.
  • Name it something like SSM-Endpoint-SG.
  • Inbound Rule: Add HTTPS (Port 443) and set the source to your VPC's IPv4 CIDR block (e.g., 10.0.0.0/16).
  • Outbound Rule: Leave the default (All traffic to 0.0.0.0/0). Verification: The new Security Group explicitly allows inbound port 443 traffic from the entire VPC network.


Create the endpoint for secure connections

You must create 3 separate endpoints. Session Manager requires three specific AWS services to function over PrivateLink. Go to VPC Console -> Endpoints and click Create endpoint. You will need to repeat this process three times, once for each of these services:

  • com.amazonaws.[your-region].ssm (Handles core Systems Manager requests)
  • com.amazonaws.[your-region].ssmmessages (Handles the Session Manager terminal tunnel)
  • com.amazonaws.[your-region].ec2messages (Handles SSM Agent status and replies)


For each of the three endpoints, configure the following:

  1. Select the VPC where your EC2 instance lives.
  2. Under Subnets, select the private subnet(s) where your instance is located.
  3. Under Security groups, select the SSM-Endpoint-SG you created in Step 1.
  4. Critical: Ensure Enable DNS name is checked. This tricks the SSM agent into routing standard AWS API calls to your private internal IPs instead of the public internet. Verification: In the VPC Endpoints console, all three endpoints show a status of "Available".


Finally, start an EC2 instance on the private subnet.

Using ping validate that the internet cannot be reached:

ping www.google.com
PING www.google.com (142.251.152.119) 56(84) bytes of data.
^C
--- www.google.com ping statistics ---
21 packets transmitted, 0 received, 100% packet loss, time 20816ms

Accessing the Private subnet from public servers

With the basic structure now established the public / private boundaries can be controlled by adding ingress rules to the NACL for the private subnet.