Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Rule: EC2 Instances Should Not Have a Public IP Address

This rule ensures that EC2 instances do not have a public IP address to improve security

RuleEC2 instances should not have a public IP address
FrameworkNIST 800-53 Revision 5
Severity
High

Rule Description

According to the NIST 800-53 Revision 5 security guidelines, EC2 instances should not have a public IP address. This rule ensures that instances are not directly accessible from the internet, reducing the risk of unauthorized access attempts and potential security breaches.

Instances with public IP addresses are more vulnerable to various types of attacks, including network scanning, brute-force attacks, and exploitation of known vulnerabilities. By disabling public IP addresses, organizations can enforce a more secure network architecture and minimize potential security risks.

Troubleshooting Steps

If an EC2 instance has a public IP address configured, follow the steps below to troubleshoot and rectify the issue:

  1. 1.

    Identify the instances with public IP addresses:

    • Go to the AWS Management Console and navigate to the EC2 dashboard.
    • Look for instances that have a public IP address assigned.
  2. 2.

    Confirm the necessity of a public IP address:

    • Determine if the instance requires internet connectivity.
    • Assess if a public IP address is needed for specific use cases such as web servers, DNS servers, or instances accessed by external clients.
  3. 3.

    Review network architecture and security groups:

    • Ensure that the instances are placed within appropriate private subnets.
    • Verify that associated security groups allow only necessary inbound and outbound traffic.
  4. 4.

    Consider alternative connectivity options:

    • Evaluate if instances can access the internet through a NAT gateway or NAT instance without a public IP address.
    • Determine if a VPN connection or Direct Connect can enable secure access to required resources without relying on public IP addresses.

Code Samples

The following code snippet demonstrates how to remove a public IP address from an EC2 instance using the AWS Command Line Interface (CLI):

aws ec2 modify-instance-attribute --instance-id <INSTANCE_ID> --no-associate-public-ip-address

Replace

<INSTANCE_ID>
with the actual ID of the EC2 instance that needs its public IP address removed. This CLI command will disassociate the public IP address from the instance.

Remediation Steps

To remove the public IP address from an EC2 instance, follow the steps below:

  1. 1.

    Connect to the AWS Management Console and navigate to the EC2 service.

  2. 2.

    Identify and select the EC2 instance:

    • Find the instance that has a public IP address assigned.
    • Select the checkbox next to the instance to enable the Actions menu.
  3. 3.

    Remove the public IP address:

    • Click on the "Actions" dropdown menu and choose "Networking" followed by "Change Source/Dest Check."
    • In the pop-up window, uncheck the "Source/Destination Check" box and click on "Save."
  4. 4.

    Validate the removal:

    • Wait for a few moments until the instance status becomes "running" again.
    • Verify that the instance no longer has a public IP address associated with it.

By following these steps, you have successfully removed the public IP address from the EC2 instance, aligning with the NIST 800-53 Revision 5 requirements for improved security.

Is your System Free of Underlying Vulnerabilities?
Find Out Now