AWS Service Quotas Multi-Region GetServiceQuota Requests

Identifies when a single AWS resource is making GetServiceQuota API calls for the EC2 service quota L-1216C47A in more than 10 regions within a 30-second window. Quota code L-1216C47A represents on-demand instances which are used by adversaries to deploy malware and mine cryptocurrency. This could indicate a potential threat actor attempting to discover the AWS infrastructure across multiple regions using compromised credentials or a compromised instance.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2024/08/26"
  3maturity = "production"
  4updated_date = "2025/01/15"
  5
  6[rule]
  7author = ["Elastic"]
  8description = """
  9Identifies when a single AWS resource is making `GetServiceQuota` API calls for the EC2 service quota L-1216C47A in more
 10than 10 regions within a 30-second window. Quota code L-1216C47A represents on-demand instances which are used by
 11adversaries to deploy malware and mine cryptocurrency. This could indicate a potential threat actor attempting to
 12discover the AWS infrastructure across multiple regions using compromised credentials or a compromised instance.
 13"""
 14from = "now-9m"
 15language = "esql"
 16license = "Elastic License v2"
 17name = "AWS Service Quotas Multi-Region `GetServiceQuota` Requests"
 18references = [
 19    "https://www.sentinelone.com/labs/exploring-fbot-python-based-malware-targeting-cloud-and-payment-services/",
 20    "https://docs.aws.amazon.com/servicequotas/2019-06-24/apireference/API_GetServiceQuota.html",
 21]
 22risk_score = 21
 23rule_id = "19be0164-63d2-11ef-8e38-f661ea17fbce"
 24severity = "low"
 25tags = [
 26    "Domain: Cloud",
 27    "Data Source: AWS",
 28    "Data Source: Amazon Web Services",
 29    "Data Source: AWS Service Quotas",
 30    "Use Case: Threat Detection",
 31    "Tactic: Discovery",
 32    "Resources: Investigation Guide",
 33]
 34timestamp_override = "event.ingested"
 35type = "esql"
 36
 37query = '''
 38from logs-aws.cloudtrail-*
 39
 40// filter for GetServiceQuota API calls
 41| where event.dataset == "aws.cloudtrail" and event.provider == "servicequotas.amazonaws.com" and event.action == "GetServiceQuota"
 42
 43// truncate the timestamp to a 30-second window
 44| eval target_time_window = DATE_TRUNC(30 seconds, @timestamp)
 45
 46// pre-process the request parameters to extract the service code and quota code
 47| dissect aws.cloudtrail.request_parameters "{%{?service_code_key}=%{service_code}, %{?quota_code_key}=%{quota_code}}"
 48
 49// filter for EC2 service quota L-1216C47A (vCPU on-demand instances)
 50| where service_code == "ec2" and quota_code == "L-1216C47A"
 51
 52// keep only the relevant fields
 53| keep target_time_window, aws.cloudtrail.user_identity.arn, cloud.region, service_code, quota_code
 54
 55// count the number of unique regions and total API calls within the 30-second window
 56| stats region_count = count_distinct(cloud.region), window_count = count(*) by target_time_window, aws.cloudtrail.user_identity.arn
 57
 58// filter for resources making DescribeInstances API calls in more than 10 regions within the 30-second window
 59| where region_count >= 10 and window_count >= 10
 60
 61// sort the results by time windows in descending order
 62| sort target_time_window desc
 63'''
 64note = """## Triage and analysis
 65
 66> **Disclaimer**:
 67> This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.
 68
 69### Investigating AWS Service Quotas Multi-Region `GetServiceQuota` Requests
 70
 71AWS Service Quotas manage resource limits across AWS services, crucial for maintaining operational boundaries. Adversaries may exploit `GetServiceQuota` API calls to probe AWS infrastructure, seeking vulnerabilities for deploying threats like cryptocurrency miners. The detection rule identifies unusual multi-region queries for EC2 quotas, signaling potential credential compromise or unauthorized access attempts.
 72
 73### Possible investigation steps
 74
 75- Review the AWS CloudTrail logs to identify the specific user or role associated with the `aws.cloudtrail.user_identity.arn` field that triggered the alert. Determine if this user or role should have access to multiple regions.
 76- Examine the `cloud.region` field to identify which regions were accessed and verify if these regions are typically used by your organization. Investigate any unfamiliar regions for unauthorized activity.
 77- Check the AWS IAM policies and permissions associated with the identified user or role to ensure they align with the principle of least privilege. Look for any recent changes or anomalies in permissions.
 78- Investigate the source IP addresses and locations from which the `GetServiceQuota` API calls were made to determine if they match expected patterns for your organization. Look for any unusual or suspicious IP addresses.
 79- Review recent activity logs for the identified user or role to detect any other unusual or unauthorized actions, such as attempts to launch EC2 instances or access other AWS services.
 80- If a compromise is suspected, consider rotating the credentials for the affected user or role and implementing additional security measures, such as multi-factor authentication (MFA) and enhanced monitoring.
 81
 82### False positive analysis
 83
 84- Legitimate multi-region operations: Organizations with a global presence may have legitimate reasons for querying EC2 service quotas across multiple regions. To handle this, users can create exceptions for known accounts or roles that regularly perform such operations.
 85- Automated infrastructure management tools: Some tools or scripts designed for infrastructure management might perform multi-region `GetServiceQuota` requests as part of their normal operation. Users should identify these tools and exclude their activity from triggering alerts by whitelisting their associated user identities or ARNs.
 86- Testing and development activities: Developers or testers might intentionally perform multi-region queries during testing phases. Users can mitigate false positives by setting up temporary exceptions for specific time frames or user identities involved in testing.
 87- Cloud service providers or partners: Third-party services or partners managing AWS resources on behalf of an organization might generate similar patterns. Users should establish trust relationships and exclude these entities from detection by verifying their activities and adding them to an exception list.
 88
 89### Response and remediation
 90
 91- Immediately isolate the AWS account or IAM user identified in the alert to prevent further unauthorized access. This can be done by disabling the access keys or suspending the account temporarily.
 92- Conduct a thorough review of the AWS CloudTrail logs for the identified user or resource to determine the extent of the unauthorized activity and identify any other potentially compromised resources.
 93- Rotate all access keys and passwords associated with the compromised account or IAM user to prevent further unauthorized access.
 94- Implement additional security measures such as enabling multi-factor authentication (MFA) for all IAM users and roles to enhance account security.
 95- Notify the security operations team and relevant stakeholders about the potential compromise and the steps being taken to remediate the issue.
 96- If evidence of compromise is confirmed, consider engaging AWS Support or a third-party incident response team for further investigation and assistance.
 97- Review and update IAM policies and permissions to ensure the principle of least privilege is enforced, reducing the risk of future unauthorized access attempts."""
 98
 99[[rule.threat]]
100framework = "MITRE ATT&CK"
101[[rule.threat.technique]]
102id = "T1580"
103name = "Cloud Infrastructure Discovery"
104reference = "https://attack.mitre.org/techniques/T1580/"
105
106
107[rule.threat.tactic]
108id = "TA0007"
109name = "Discovery"
110reference = "https://attack.mitre.org/tactics/TA0007/"
...
toml

Disclaimer: This investigation guide was created using generative AI technology and has been reviewed to improve its accuracy and relevance. While every effort has been made to ensure its quality, we recommend validating the content and adapting it to suit your specific environment and operational needs.

AWS Service Quotas manage resource limits across AWS services, crucial for maintaining operational boundaries. Adversaries may exploit GetServiceQuota API calls to probe AWS infrastructure, seeking vulnerabilities for deploying threats like cryptocurrency miners. The detection rule identifies unusual multi-region queries for EC2 quotas, signaling potential credential compromise or unauthorized access attempts.

  • Review the AWS CloudTrail logs to identify the specific user or role associated with the aws.cloudtrail.user_identity.arn field that triggered the alert. Determine if this user or role should have access to multiple regions.
  • Examine the cloud.region field to identify which regions were accessed and verify if these regions are typically used by your organization. Investigate any unfamiliar regions for unauthorized activity.
  • Check the AWS IAM policies and permissions associated with the identified user or role to ensure they align with the principle of least privilege. Look for any recent changes or anomalies in permissions.
  • Investigate the source IP addresses and locations from which the GetServiceQuota API calls were made to determine if they match expected patterns for your organization. Look for any unusual or suspicious IP addresses.
  • Review recent activity logs for the identified user or role to detect any other unusual or unauthorized actions, such as attempts to launch EC2 instances or access other AWS services.
  • If a compromise is suspected, consider rotating the credentials for the affected user or role and implementing additional security measures, such as multi-factor authentication (MFA) and enhanced monitoring.
  • Legitimate multi-region operations: Organizations with a global presence may have legitimate reasons for querying EC2 service quotas across multiple regions. To handle this, users can create exceptions for known accounts or roles that regularly perform such operations.
  • Automated infrastructure management tools: Some tools or scripts designed for infrastructure management might perform multi-region GetServiceQuota requests as part of their normal operation. Users should identify these tools and exclude their activity from triggering alerts by whitelisting their associated user identities or ARNs.
  • Testing and development activities: Developers or testers might intentionally perform multi-region queries during testing phases. Users can mitigate false positives by setting up temporary exceptions for specific time frames or user identities involved in testing.
  • Cloud service providers or partners: Third-party services or partners managing AWS resources on behalf of an organization might generate similar patterns. Users should establish trust relationships and exclude these entities from detection by verifying their activities and adding them to an exception list.
  • Immediately isolate the AWS account or IAM user identified in the alert to prevent further unauthorized access. This can be done by disabling the access keys or suspending the account temporarily.
  • Conduct a thorough review of the AWS CloudTrail logs for the identified user or resource to determine the extent of the unauthorized activity and identify any other potentially compromised resources.
  • Rotate all access keys and passwords associated with the compromised account or IAM user to prevent further unauthorized access.
  • Implement additional security measures such as enabling multi-factor authentication (MFA) for all IAM users and roles to enhance account security.
  • Notify the security operations team and relevant stakeholders about the potential compromise and the steps being taken to remediate the issue.
  • If evidence of compromise is confirmed, consider engaging AWS Support or a third-party incident response team for further investigation and assistance.
  • Review and update IAM policies and permissions to ensure the principle of least privilege is enforced, reducing the risk of future unauthorized access attempts.

References

Related rules

to-top