Insecure AWS EC2 VPC Security Group Ingress Rule Added

Identifies when a specified inbound (ingress) rule is added or adjusted for a VPC security group in AWS EC2. This rule detects when a security group rule is added that allows traffic from any IP address or from a specific IP address to common remote access ports, such as 22 (SSH) or 3389 (RDP). Adversaries may add these rules to allow remote access to VPC instances from any location, increasing the attack surface and potentially exposing the instances to unauthorized access.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2024/04/16"
  3integration = ["aws"]
  4maturity = "production"
  5min_stack_comments = "AWS integration breaking changes, bumping version to ^2.0.0"
  6min_stack_version = "8.9.0"
  7updated_date = "2024/05/28"
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12Identifies when a specified inbound (ingress) rule is added or adjusted for a VPC security group in AWS EC2. This rule
 13detects when a security group rule is added that allows traffic from any IP address or from a specific IP address to
 14common remote access ports, such as 22 (SSH) or 3389 (RDP). Adversaries may add these rules to allow remote access to
 15VPC instances from any location, increasing the attack surface and potentially exposing the instances to unauthorized
 16access.
 17"""
 18false_positives = [
 19    """
 20    Administrators may legitimately add security group rules to allow traffic from any IP address or from specific IP
 21    addresses to common remote access ports.
 22    """,
 23]
 24from = "now-60m"
 25index = ["filebeat-*", "logs-aws.cloudtrail-*"]
 26interval = "10m"
 27language = "kuery"
 28license = "Elastic License v2"
 29name = "Insecure AWS EC2 VPC Security Group Ingress Rule Added"
 30note = """
 31## Triage and Analysis
 32
 33### Investigating Insecure AWS EC2 VPC Security Group Ingress Rule Added
 34
 35This rule detects the addition of ingress rules to a VPC security group that allow traffic from any IP address (`0.0.0.0/0` or `::/0`) to sensitive ports commonly used for remote access, such as SSH (port 22) and RDP (port 3389). This configuration change can significantly increase the exposure of EC2 instances to potential threats, making it crucial to understand the context and legitimacy of such changes.
 36
 37#### Possible Investigation Steps:
 38
 39- **Identify the Actor**: Review the `aws.cloudtrail.user_identity.arn` and `aws.cloudtrail.user_identity.access_key_id` fields to identify who made the change. Investigate whether this actor has the necessary permissions and typically performs these actions.
 40- **Review the Request Details**: Examine the `aws.cloudtrail.request_parameters` to understand exactly what changes were made to the security group. Check for any unusual parameters that could suggest a misconfiguration or malicious intent.
 41- **Analyze the Source of the Request**: Look at the `source.ip` and `source.geo` fields to determine the geographical origin of the request. An external or unusual location could indicate compromised credentials.
 42- **Contextualize with Timestamp**: Use the `@timestamp` field to check when the change occurred. Modifications outside of typical business hours might warrant additional scrutiny.
 43- **Correlate with Other Activities**: Search for related CloudTrail events before and after this change to see if the same actor engaged in other potentially suspicious activities.
 44
 45### False Positive Analysis:
 46
 47- **Legitimate Administrative Actions**: Verify if the ingress rule change aligns with scheduled updates, maintenance activities, or legitimate administrative tasks documented in change management tickets or systems.
 48- **Consistency Check**: Compare the action against historical data of similar actions performed by the user or within the organization. Consistency with past legitimate actions might indicate a false alarm.
 49- **Verify through Outcomes**: Check the `aws.cloudtrail.response_elements` and the `event.outcome` to confirm if the change was successful and intended as per policy.
 50
 51### Response and Remediation:
 52
 53- **Immediate Review and Reversal if Necessary**: If the change was unauthorized, revert the security group rules to their previous state to close any unintended access.
 54- **Enhance Monitoring and Alerts**: Adjust monitoring systems to alert on similar security group changes, especially those that open access to well-known ports from any IP address.
 55- **Educate and Train**: Provide additional training to users with administrative rights on the importance of security best practices concerning security group management.
 56- **Audit Security Groups and Policies**: Conduct a comprehensive audit of all security groups and associated policies to ensure they adhere to the principle of least privilege.
 57- **Incident Response**: If there's an indication of malicious intent or a security breach, initiate the incident response protocol to mitigate any damage and prevent future occurrences.
 58
 59### Additional Information:
 60
 61For further guidance on managing security group rules and securing AWS environments, refer to the [Amazon VPC Security Groups documentation](https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html) and AWS best practices for security.
 62
 63"""
 64references = [
 65    "https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AuthorizeSecurityGroupEgress.html",
 66    "https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_AuthorizeSecurityGroupIngress.html",
 67    "https://www.linkedin.com/pulse/my-backdoors-your-aws-infrastructure-part-3-network-micha%C5%82-brygidyn/",
 68]
 69risk_score = 47
 70rule_id = "25e7fee6-fc25-11ee-ba0f-f661ea17fbce"
 71severity = "medium"
 72tags = [
 73    "Domain: Cloud",
 74    "Data Source: AWS",
 75    "Data Source: Amazon Web Services",
 76    "Data Source: AWS EC2",
 77    "Use Case: Threat Detection",
 78    "Tactic: Defense Evasion",
 79]
 80timestamp_override = "event.ingested"
 81type = "query"
 82
 83query = '''
 84event.dataset: "aws.cloudtrail"
 85    and event.provider: ec2.amazonaws.com
 86    and event.action: AuthorizeSecurityGroupIngress
 87    and event.outcome: success
 88    and aws.cloudtrail.flattened.request_parameters.cidrIp: ("0.0.0.0/0" or "::/0")
 89    and aws.cloudtrail.flattened.request_parameters.fromPort: (
 90        21 or 22 or 23 or 445 or 3389 or 5985 or 5986)
 91'''
 92
 93
 94[[rule.threat]]
 95framework = "MITRE ATT&CK"
 96[[rule.threat.technique]]
 97id = "T1562"
 98name = "Impair Defenses"
 99reference = "https://attack.mitre.org/techniques/T1562/"
100[[rule.threat.technique.subtechnique]]
101id = "T1562.007"
102name = "Disable or Modify Cloud Firewall"
103reference = "https://attack.mitre.org/techniques/T1562/007/"
104
105
106
107[rule.threat.tactic]
108id = "TA0005"
109name = "Defense Evasion"
110reference = "https://attack.mitre.org/tactics/TA0005/"

Triage and Analysis

Investigating Insecure AWS EC2 VPC Security Group Ingress Rule Added

This rule detects the addition of ingress rules to a VPC security group that allow traffic from any IP address (0.0.0.0/0 or ::/0) to sensitive ports commonly used for remote access, such as SSH (port 22) and RDP (port 3389). This configuration change can significantly increase the exposure of EC2 instances to potential threats, making it crucial to understand the context and legitimacy of such changes.

Possible Investigation Steps:

  • Identify the Actor: Review the aws.cloudtrail.user_identity.arn and aws.cloudtrail.user_identity.access_key_id fields to identify who made the change. Investigate whether this actor has the necessary permissions and typically performs these actions.
  • Review the Request Details: Examine the aws.cloudtrail.request_parameters to understand exactly what changes were made to the security group. Check for any unusual parameters that could suggest a misconfiguration or malicious intent.
  • Analyze the Source of the Request: Look at the source.ip and source.geo fields to determine the geographical origin of the request. An external or unusual location could indicate compromised credentials.
  • Contextualize with Timestamp: Use the @timestamp field to check when the change occurred. Modifications outside of typical business hours might warrant additional scrutiny.
  • Correlate with Other Activities: Search for related CloudTrail events before and after this change to see if the same actor engaged in other potentially suspicious activities.

False Positive Analysis:

  • Legitimate Administrative Actions: Verify if the ingress rule change aligns with scheduled updates, maintenance activities, or legitimate administrative tasks documented in change management tickets or systems.
  • Consistency Check: Compare the action against historical data of similar actions performed by the user or within the organization. Consistency with past legitimate actions might indicate a false alarm.
  • Verify through Outcomes: Check the aws.cloudtrail.response_elements and the event.outcome to confirm if the change was successful and intended as per policy.

Response and Remediation:

  • Immediate Review and Reversal if Necessary: If the change was unauthorized, revert the security group rules to their previous state to close any unintended access.
  • Enhance Monitoring and Alerts: Adjust monitoring systems to alert on similar security group changes, especially those that open access to well-known ports from any IP address.
  • Educate and Train: Provide additional training to users with administrative rights on the importance of security best practices concerning security group management.
  • Audit Security Groups and Policies: Conduct a comprehensive audit of all security groups and associated policies to ensure they adhere to the principle of least privilege.
  • Incident Response: If there's an indication of malicious intent or a security breach, initiate the incident response protocol to mitigate any damage and prevent future occurrences.

Additional Information:

For further guidance on managing security group rules and securing AWS environments, refer to the Amazon VPC Security Groups documentation and AWS best practices for security.

References

Related rules

to-top