Enabling public network access to cloud resources can affect an organization’s ability to protect its data or internal operations from data theft
or disruption.
Depending on the component, inbound access from the Internet can be enabled via:
- a boolean value that explicitly allows access to the public network.
- the assignment of a public IP address.
- database firewall rules that allow public IP ranges.
Deciding to allow public access may happen for various reasons such as for quick maintenance, time saving, or by accident.
This decision increases the likelihood of attacks on the organization, such as:
- data breaches.
- intrusions into the infrastructure to permanently steal from it.
- and various malicious traffic, such as DDoS attacks.
Ask Yourself Whether
This cloud resource:
- should be publicly accessible to any Internet user.
- requires inbound traffic from the Internet to function properly.
There is a risk if you answered no to any of those questions.
Recommended Secure Coding Practices
Avoid publishing cloud services on the Internet unless they are intended to be publicly accessible, such as customer portals or e-commerce
sites.
Use private networks (and associated private IP addresses) and VPC peering or other secure communication tunnels to communicate with other cloud
components.
The goal is to prevent the component from intercepting traffic coming in via the public IP address. If the cloud resource does not support the
absence of a public IP address, assign a public IP address to it, but do not create listeners for the public IP address.
Sensitive Code Example
DMS and EC2 instances have a public IP address assigned to them:
AWSTemplateFormatVersion: 2010-09-09
Resources:
DMSInstance:
Type: AWS::DMS::ReplicationInstance
Properties:
PubliclyAccessible: true # sensitive, by default it's also set to true
EC2Instance:
Type: AWS::EC2::Instance
Properties:
NetworkInterfaces:
- AssociatePublicIpAddress: true # sensitive, by default it's also set to true
DeviceIndex: "0"
Compliant Solution
DMS and EC2 instances doesn’t have a public IP address:
AWSTemplateFormatVersion: 2010-09-09
Resources:
DMSInstance:
Type: AWS::DMS::ReplicationInstance
Properties:
PubliclyAccessible: false
EC2Instance:
Type: AWS::EC2::Instance
Properties:
NetworkInterfaces:
- AssociatePublicIpAddress: false
DeviceIndex: "0"
See