• Home
  • Learn
  • DetectionHub
  • Ranking
  • About
  • Blog
  • Login
Easy·Updated on 2025-03-15

AWS Security Group Public Exposure of SSH Port 22

1,234
Submissions
67.5%
Pass Rate
5 minutes
Estimated Time
AWS

Description

In cloud environments, security groups manage both inbound and outbound network traffic.

Opening port 22 (SSH) to the public internet (0.0.0.0/0) significantly increases the risk of unauthorized remote access and is a common entry point for attackers targeting cloud hosts.

Cloud security best practices clearly recommend restricting SSH port exposure. However, due to configuration errors or automated scripts, port 22 may still be unintentionally exposed to the public. Promptly identifying and correcting such configurations is essential for mitigating potential threats and enhancing the security of cloud resources.

Challenge Objective

Write a detection rule to identify instances where the AuthorizeSecurityGroupIngress CloudTrail event is used to allow access to security group port 22 from unknown external IPs or from 0.0.0.0/0.

When writing detection queries, please ensure that the eventID field is included in the output results to facilitate subsequent validation.

Data Sample

Data source: CloudTrail. Example data:

{  "awsRegion": "ap-southeast-2",  "eventCategory": "Management",  "eventID": "fdf4b0b4-fb14-4237-af87-e97ba6360e1e",  "eventName": "AuthorizeSecurityGroupIngress",  "eventSource": "ec2.amazonaws.com",  "eventTime": "2025-06-11T08:30:06Z",  "eventType": "AwsApiCall",  "eventVersion": "1.10",  "managementEvent": true,  "readOnly": false,  "recipientAccountId": "438465128930",  "requestID": "79c4dd5e-5e7c-4b36-bb98-1a95382c3c46",  "requestParameters": {    "cidrIp": "0.0.0.0/0",    "fromPort": 22,    "groupId": "sg-06519ff9524185867",    "ipPermissions": {},    "ipProtocol": "tcp",    "toPort": 22  },  "responseElements": {    "_return": true,    "requestId": "79c4dd5e-5e7c-4b36-bb98-1a95382c3c46",    "securityGroupRuleSet": {      "items": [        {          "cidrIpv4": "0.0.0.0/0",          "fromPort": 22,          "groupId": "sg-06519ff9524185867",          "groupOwnerId": "438465128930",          "ipProtocol": "tcp",          "isEgress": false,          "securityGroupRuleArn": "arn:aws:ec2:ap-southeast-2:438465128930:security-group-rule/sgr-0932ae67cf102fcf1",          "securityGroupRuleId": "sgr-0932ae67cf102fcf1",          "toPort": 22        }      ]    }  },  "sourceIPAddress": "154.84.135.91",  "tlsDetails": {    "cipherSuite": "TLS_AES_128_GCM_SHA256",    "clientProvidedHostHeader": "ec2.ap-southeast-2.amazonaws.com",    "tlsVersion": "TLSv1.3"  },  "userAgent": "stratus-red-team_a830c203-b560-4c74-a5e5-f6cf5ffc1d26",  "userIdentity": {    "accessKeyId": "AKIAWMFUO5HRKBD6JQ6D",    "accountId": "438465128930",    "arn": "arn:aws:iam::438465128930:user/soclabs-test",    "principalId": "AIDAWMFUO5HRCBESZ467O",    "type": "IAMUser",    "userName": "soclabs-test"  }}

References

loading...

Fields

No fields found

0 fields selected

Preview Results