Unrestricted Security Group Ingress on Uncommon Ports (2024)

  • Knowledge Base
  • Amazon Web Services
  • Amazon EC2
  • Unrestricted Security Group Ingress on Uncommon Ports

Trend Micro Cloud One™ – Conformity is a continuous assurance tool that provides peace of mind for your cloud infrastructure, delivering over 750 automated best practice checks.

Risk Level: High (act today)

Rule ID: EC2-034

Ensure that your Amazon EC2 security groups don't allow unrestricted access (i.e. 0.0.0.0/0 or ::/0) on uncommon ports in order to protect against attackers that use brute force methods to gain access to the EC2 instances associated with your security groups. An uncommon port can be any TCP/UDP port that is not included in the common service ports category, i.e. other than the commonly used ports such as 80 (HTTP), 443 (HTTPS), 20/21 (FTP), 22 (SSH), 23 (Telnet), 53 (DNS), 3389 (RDP), 25/465/587 (SMTP), 3306 (MySQL), 5432 (PostgreSQL), 1521 (Oracle Database), 1433 (SQL Server), 135 (RPC), and 137/138/139/445 (SMB/CIFS).

This rule can help you with the following compliance standards:

  • PCI
  • HIPAA
  • APRA
  • MAS
  • NIST4

For further details on compliance standards supported by Conformity, see here.

This rule can help you work with the AWS Well-Architected Framework.

This rule resolution is part of the Conformity .

Unrestricted Security Group Ingress on Uncommon Ports (1) Security

Allowing unrestricted inbound/ingress access to Amazon EC2 instances on uncommon TCP/UDP ports can increase opportunities for malicious activities such as hacking, data capture, and all kinds of attacks (brute-force attacks, Man-in-the-Middle attack, and Denial-of-Service attacks).

Audit

To determine if your Amazon EC2 security groups allow unrestricted ingress access on uncommon TCP/UDP ports, perform the following operations:

Using AWS Console

01 Sign in to the AWS Management Console.

02 Navigate to Amazon EC2 console at https://console.aws.amazon.com/ec2/.

03 In the navigation panel, under Network & Security, choose Security Groups.

04 Select the Amazon EC2 security group that you want to examine.

05 Choose the Inbound rules tab from the console bottom panel to access the inbound rules created for the selected group.

06 Check the configuration value available in the Source column for any inbound/ingress rules with uncommon ports (other than the ones listed in the rule description). If one or more rules have the Source value set to 0.0.0.0/0 or ::/0(i.e.**Anywhere), the selected Amazon EC2 security group allows unrestricted traffic to uncommon ports, therefore the access to the associated EC2 instance(s) is not secured.

07 Repeat steps no. 4 – 6 for each EC2 security group available within the current AWS region.

08 Change the AWS cloud region from the navigation bar and repeat the audit process for other regions.

Using AWS CLI

01 Run describe-security-groups command (OSX/Linux/UNIX) with predefined filters to expose the ID of each Amazon EC2 security group that allows unrestricted inbound access to all IPv4 addresses (i.e. 0.0.0.0/0). Replace the --filters parameter value with the Name=ip-permission.ipv6-cidr,Values='::/0' to expose the security groups that allow unrestricted inbound access to all IPv6 addresses (::/0):

aws ec2 describe-security-groups --region us-east-1 --filters Name=ip-permission.cidr,Values='0.0.0.0/0' --output table --query 'SecurityGroups[*].GroupId'

02 If the describe-security-groups command does not produce an output, there are no security groups that allow unrestricted inbound access in the selected AWS region. Otherwise, the command output should return a table with the requested security group ID(s):

--------------------------| DescribeSecurityGroups |+------------------------+| sg-01234abcd1234abcd || sg-0abcd1234abcd1234 |+------------------------+

03 Run describe-security-groups command (OSX/Linux/UNIX) using custom query filters to list all the inbound/ingress rules defined for the selected EC2 security group:

aws ec2 describe-security-groups --region us-east-1 --group-ids sg-01234abcd1234abcd --query 'SecurityGroups[*].IpPermissions[]'

04 The command output should return the requested configuration information:

[{"FromPort": 8040,"IpProtocol": "tcp","IpRanges": [{"CidrIp": "0.0.0.0/0"}],"Ipv6Ranges": [{"CidrIpv6": "::/0"}],"PrefixListIds": [],"ToPort": 8040,"UserIdGroupPairs": []}]

To identify any uncommon TCP/UDP ports, check the "FromPort" and "ToPort" attributes values. If one or more rules returned by the describe-security-groups command output are using uncommon ports (other than the ones listed in the rule description), the selected Amazon EC2 security group allows unrestricted traffic to uncommon ports, therefore the access to the associated EC2 instance(s) is not secured.

05 Repeat steps no. 3 and 4 for each EC2 security group available in the selected AWS region.

06 Change the AWS cloud region by updating the --region command parameter value and repeat steps no. 1 – 5 to perform the audit process for other regions.

Remediation / Resolution

To update the inbound rule configuration for your Amazon EC2 security groups in order to restrict access to trusted entities only (i.e. authorized IP addresses and IP ranges, or other security groups), perform the following operations:

Using AWS CloudFormation

01 CloudFormation template (JSON):

{"AWSTemplateFormatVersion":"2010-09-09","Description":"Allow inbound access on uncommon ports to trusted entities only","Resources":{"CustomSecurityGroup" : {"Type" : "AWS::EC2::SecurityGroup","Properties" : {"GroupDescription" : "Custom security group","GroupName" : "custom-security-group","VpcId" : "vpc-1234abcd","SecurityGroupIngress" : [{"IpProtocol" : "tcp","FromPort" : 8040,"ToPort" : 8040,"CidrIp" : "10.0.0.35/32"}],"SecurityGroupEgress" : [{"IpProtocol" : "-1","FromPort" : 0,"ToPort" : 65535,"CidrIp" : "0.0.0.0/0"}]}}}}
See Also
Support

02 CloudFormation template (YAML):

AWSTemplateFormatVersion: '2010-09-09' Description: Allow inbound access on uncommon ports to trusted entities only Resources: CustomSecurityGroup: Type: AWS::EC2::SecurityGroup Properties: GroupDescription: Custom security group GroupName: custom-security-group VpcId: vpc-1234abcd SecurityGroupIngress: - IpProtocol: tcp FromPort: 8040 ToPort: 8040 CidrIp: 10.0.0.35/32 SecurityGroupEgress: - IpProtocol: "-1" FromPort: 0 ToPort: 65535 CidrIp: 0.0.0.0/0

Using Terraform (AWS Provider)

01 Terraform configuration file (.tf):

terraform {required_providers {aws = {source = "hashicorp/aws"version = "~> 3.27"}}required_version = ">= 0.14.9"}provider "aws" {profile = "default"region = "us-east-1"}resource "aws_security_group" "security-group" {name = "custom-security-group"description = "Custom security group"vpc_id = "vpc-1234abcd"# Allow inbound access on uncommon ports to trusted IPs/IP ranges onlyingress {from_port = 8040to_port = 8040protocol = "tcp"cidr_blocks = ["10.0.0.35/32"]}egress {from_port = 0to_port = 0protocol = "-1"cidr_blocks = ["0.0.0.0/0"]}}

Using AWS Console

01 Sign in to the AWS Management Console.

02 Navigate to Amazon EC2 console at https://console.aws.amazon.com/ec2.

03 In the navigation panel, under Network & Security, choose Security Groups.

04 Select the Amazon EC2 security group that you want to reconfigure (see Audit section part I to identify the right resource).

05 Select the Inbound rules tab from the console bottom panel and choose Edit inbound rules.

06 On the Edit inbound rules configuration page, change the traffic source for the inbound rule that allows unrestricted access through uncommon TCP/UDP ports, by performing one of the following actions:

  1. Select My IP from the Source dropdown list to allow inbound traffic only from your current IP address.
  2. Select Custom from the Source dropdown list and enter one of the following options based on your access requirements: The static IP address of the permitted host in CIDR notation (e.g. 10.0.0.35/32). The IP address range of the permitted network/subnetwork in CIDR notation, for example 10.0.5.0/24. The name or ID of another security group available in the same AWS cloud region.
  3. Choose Save rules to apply the configuration changes.

07 Repeat steps no. 4 – 6 to reconfigure other EC2 security groups that allow unrestricted access on uncommon TCP/UDP ports.

08 Change the AWS cloud region from the navigation bar and repeat the remediation process for other regions.

Using AWS CLI

01 Run revoke-security-group-ingress command (OSX/Linux/UNIX) using the ID of the Amazon EC2 security group that you want to reconfigure as the identifier parameter (see Audit section part II to identify the right resource), to remove the inbound rules that allow unrestricted access through uncommon TCP ports. Replace tcp with udp within the IpProtocol parameter value to remove the ingress rule that allows unrestricted access on uncommon UDP ports:

aws ec2 revoke-security-group-ingress --region us-east-1 --group-id sg-01234abcd1234abcd --ip-permissions IpProtocol=tcp,FromPort=8040,ToPort=8040,IpRanges=[{CidrIp="0.0.0.0/0"}],Ipv6Ranges=[{CidrIpv6="::/0"}] --query 'Return'

02 The command output should return true if the request succeeds. Otherwise, it should return an error:

true

03 Run authorize-security-group-ingress command (OSX/Linux/UNIX) to add the inbound rule removed at the previous step with a different set of parameters in order to restrict access to trusted entities only (IP addresses, IP ranges, or security groups). To create and attach custom inbound/ingress rules to the selected Amazon EC2 security group based on your access requirements, use one of the following options (the command does not produce an output):

  1. Add an inbound rule that allows traffic from an authorized static IP address via TCP port 8040 (uncommon port), using CIDR notation (e.g. 10.0.0.35/32). Replace tcp with udp within the --protocol command parameter value for rules with uncommon UDP ports:
    aws ec2 authorize-security-group-ingress --region us-east-1 --group-id sg-01234abcd1234abcd --protocol tcp --port 8040 --cidr 10.0.0.35/32
  2. Add an inbound/ingress rule that allows traffic from a trusted IP address range through TCP port 8040, using CIDR notation (for example, 10.0.5.0/24). Replace tcp with udp within the --protocol command parameter value for rules with uncommon UDP ports:
    aws ec2 authorize-security-group-ingress --region us-east-1 --group-id sg-01234abcd1234abcd --protocol tcp --port 8040 --cidr 10.0.5.0/24
  3. Add an inbound rule that allows traffic from another security group (e.g. sg-01234123412341234) available in the same AWS cloud region via TCP port 8040. Replace tcp with udp within the --protocol command parameter value for rules with uncommon UDP ports:
    aws ec2 authorize-security-group-ingress --region us-east-1 --group-id sg-01234abcd1234abcd --protocol tcp --port 8040 --source-group sg-01234123412341234

04 Repeat steps no. 1 – 3 to reconfigure other EC2 security groups that allow unrestricted access on uncommon TCP/UDP ports.

05 Change the AWS cloud region by updating the --region command parameter value and repeat steps no. 1 – 4 to perform the remediation process for other regions.

References

Publication date Jun 19, 2016

Related EC2 rules

  • Web-Tier Publicly Shared AMI (Security)
  • Security Group Naming Conventions (Security)
  • EC2 Desired Instance Type (Sustainability, security)
  • EC2 Instance Using IAM Roles (Security)

Unlock the Remediation Steps

Free 30-day Trial

Automatically audit your configurations with Conformity
and gain access to our cloud security platform.

Unrestricted Security Group Ingress on Uncommon Ports (2)

No thanks, back to article

You are auditing:

Unrestricted Security Group Ingress on Uncommon Ports

Risk Level: High

Unrestricted Security Group Ingress on Uncommon Ports (2024)
Top Articles
Binance Exchange Security 2024: Is Binance Still Safe?
Coinbase Global, Inc. (COIN) Stock Historical Prices & Data - Yahoo Finance
Play Retro Games Online - NES, SNES, GBA, GBC, NEO-GEO & More
The Eye Doctors North Topeka
Teacup Yorkie For Sale Up To $400 In South Carolina
Baldur’s Gate 3 difficulty settings and options
25X11X10 Atv Tires Tractor Supply
Joe Nichols Juab County Fair
Medfusion/Toa Portal
دانلود فیلم سرزمین باکره ها دیجی موویز
Pitco Foods San Leandro
Santa Ana Gang Map
5084414770
What is the difference between a T-bill and a T note?
Margie's Money Saver Hey Dudes
Why are we ticklish? Here’s what we know about our silliest defense mechanism.
Nick Jr Tv Passport
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Lake Compounce Family 4 Pack
Myapps Tesla Ultipro Sign In
Craigslist Farm Livestock For Sale
Tfcu El Paso Online Banking
Results from Form 1 of Page crazybutkool/crear_post.htm
Vacbanned Steam Hex
Williamsport Craigslist Farm And Garden
Waarom Singapore de slechtste race van dit jaar gaat worden voor Max Verstappen
Larry A.k.a Lvrd Pharaoh
Whitney Johns Feet
Craigslist General Labor Annapolis
Oscillates Like A Ship
Nashville Predators Wiki
Frequently Asked Questions | Pay Your Bill Online | Cape Fear Valley Health
Devotion Showtimes Near Maya Cinemas Delano
Ramsey County Recordease
Omni Id Portal Waconia
Tacoholic St Joseph
O'reilly's Lee Road
Sound Of Freedom Showtimes Near Rome Cinemas 8
A Closer Look at Woman With a Parasol by Claude Monet
Jin Wigs Thomaston Ga
Jesus Many Faces - He Was Born, Lived And Died As A Jew | From Jesus To Christ | FRONTLINE
Www Publix Org Oasis Schedule
Craigslist Murfreesboro Pets
L'Hôpital's rule - Conditions, Formula, and Examples
Sierra At Tahoe Season Pass Costco
Taylor Cole: What Only True Fans Know About The Hallmark Star - The List
Oro probablemente a duna Playa e nomber Oranjestad un 200 aña pasa, pero Playa su historia ta bay hopi mas aña atras
Hca Scheduler Login
Teresa Palmer Fansite
What is the Vintage Aesthetic | Aesthetics Wiki
Latest Posts
Article information

Author: Cheryll Lueilwitz

Last Updated:

Views: 5568

Rating: 4.3 / 5 (54 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Cheryll Lueilwitz

Birthday: 1997-12-23

Address: 4653 O'Kon Hill, Lake Juanstad, AR 65469

Phone: +494124489301

Job: Marketing Representative

Hobby: Reading, Ice skating, Foraging, BASE jumping, Hiking, Skateboarding, Kayaking

Introduction: My name is Cheryll Lueilwitz, I am a sparkling, clean, super, lucky, joyous, outstanding, lucky person who loves writing and wants to share my knowledge and understanding with you.