Skip to main content

More Info:

No security group should allow unrestricted inbound access to TCP port 25 (SMTP).

Risk Level

Medium

Address

Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • AWS Startup Security Baseline
  • AWS Well Architected Framework
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • FedRAMP
  • GDPR
  • HITRUST CSF
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST CSF
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • PCI
  • Reserve Bank of India (RBI) Cyber Security Framework
  • Reserve Bank of India (RBI) Master Direction – Information Technology Framework
  • SOC2
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

To remediate the unrestricted SMTP access issue in AWS, follow these steps:
  1. Open the AWS Management Console and navigate to the EC2 service.
  2. Select the EC2 instance that is allowing unrestricted SMTP access.
  3. Click on the “Security” tab and scroll down to the “Security groups” section.
  4. Click on the security group that is associated with the instance.
  5. Click on the “Inbound rules” tab.
  6. Locate the rule that allows SMTP traffic (port 25) with the source of “0.0.0.0/0” or ”::/0”.
  7. Click on the “Edit” button next to the rule.
  8. Change the source to a specific IP address range or security group that requires SMTP access.
  9. Click the “Save” button to apply the changes.
By following these steps, you have successfully remediated the unrestricted SMTP access issue in AWS.

To remediate this issue in AWS, you can follow the below steps using AWS CLI:
  1. Open the AWS CLI on your local machine or EC2 instance.
  2. Run the following command to list all the active SMTP settings in the AWS account:
  1. If the command output shows that the “SendingEnabled” parameter is set to “true”, then you need to disable it. Run the following command to disable SMTP access:
  1. After running the above command, verify that the “SendingEnabled” parameter is set to “false” by running the following command:
  1. If the “SendingEnabled” parameter is set to “false”, then SMTP access has been successfully restricted in your AWS account.
Note: This remediation will disable SMTP access for all users in your AWS account. If you need to enable SMTP access for specific users, you can create an IAM policy that allows SMTP access and attach it to their IAM user or role.
To remediate unrestricted SMTP access in AWS using Python, you can follow the steps below:
  1. Create a Python script to check for SMTP access:
  1. Once you have identified the security group(s) with unrestricted SMTP access, you can update the security group rules to restrict SMTP access to specific IP addresses or ranges.
Replace SECURITY_GROUP_ID with the ID of the security group that needs to be updated and ALLOWED_IP_ADDRESS with the IP address or range that should be allowed to access SMTP.
  1. Run the Python script to check for and remediate unrestricted SMTP access in AWS.
To apply the verified CLI remediation in Terraform, ensure there is no aws_vpc_security_group_ingress_rule (or inline ingress block, if you still use it) on this security group with:
  • ip_protocol = "tcp", from_port = 25, to_port = 25
  • and cidr_ipv4 = "0.0.0.0/0" (unrestricted IPv4) or cidr_ipv6 = "::/0" (unrestricted IPv6).
Delete those rule resources (or change their CIDRs to specific ranges as in the example). This permanently removes unrestricted SMTP ingress; if you had clients relying on open SMTP, their access will stop until you add more restrictive rules.This change does not replace the security group itself, but terraform plan should show the offending ingress rule(s) being destroyed (or updated from 0.0.0.0/0 / ::/0 to the new restricted CIDR).

Additional Reading: