Unusual City For an AWS Command

A machine learning job detected AWS command activity that, while not inherently suspicious or abnormal, is sourcing from a geolocation (city) that is unusual for the command. This can be the result of compromised credentials or keys being used by a threat actor in a different geography than the authorized user(s).

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2020/07/13"
 3maturity = "production"
 4min_stack_comments = "AWS integration breaking changes, bumping version to ^2.0.0"
 5min_stack_version = "8.9.0"
 6updated_date = "2023/10/24"
 7integration = ["aws"]
 8
 9[rule]
10anomaly_threshold = 50
11author = ["Elastic"]
12description = """
13A machine learning job detected AWS command activity that, while not inherently suspicious or abnormal, is sourcing from
14a geolocation (city) that is unusual for the command. This can be the result of compromised credentials or keys being
15used by a threat actor in a different geography than the authorized user(s).
16"""
17false_positives = [
18    """
19    New or unusual command and user geolocation activity can be due to manual troubleshooting or reconfiguration;
20    changes in cloud automation scripts or workflows; adoption of new services; expansion into new regions; increased
21    adoption of work from home policies; or users who travel frequently.
22    """,
23]
24from = "now-2h"
25interval = "15m"
26license = "Elastic License v2"
27machine_learning_job_id = "rare_method_for_a_city"
28name = "Unusual City For an AWS Command"
29note = """## Triage and analysis
30
31### Investigating Unusual City For an AWS Command
32
33CloudTrail logging provides visibility on actions taken within an AWS environment. By monitoring these events and understanding what is considered normal behavior within an organization, you can spot suspicious or malicious activity when deviations occur.
34
35This rule uses a machine learning job to detect an AWS API command that while not inherently suspicious or abnormal, is sourcing from a geolocation (city) that is unusual for the command. This can be the result of compromised credentials or keys used by a threat actor in a different geography than the authorized user(s).
36
37Detection alerts from this rule indicate an AWS API command or method call that is rare and unusual for the geolocation of the source IP address.
38
39#### Possible investigation steps
40
41- Identify the user account involved and the action performed. Verify whether it should perform this kind of action.
42    - Examine the user identity in the `aws.cloudtrail.user_identity.arn` field and the access key ID in the `aws.cloudtrail.user_identity.access_key_id` field, which can help identify the precise user context.
43    - The user agent details in the `user_agent.original` field may also indicate what kind of a client made the request.
44- Investigate other alerts associated with the user account during the past 48 hours.
45- Validate the activity is not related to planned patches, updates, or network administrator activity.
46- Examine the request parameters. These might indicate the source of the program or the nature of its tasks.
47- Considering the source IP address and geolocation of the user who issued the command:
48    - Do they look normal for the calling user?
49    - If the source is an EC2 IP address, is it associated with an EC2 instance in one of your accounts or is the source IP from an EC2 instance that's not under your control?
50    - If it is an authorized EC2 instance, is the activity associated with normal behavior for the instance role or roles? Are there any other alerts or signs of suspicious activity involving this instance?
51- Consider the time of day. If the user is a human (not a program or script), did the activity take place during a normal time of day?
52- Contact the account owner and confirm whether they are aware of this activity if suspicious.
53- If you suspect the account has been compromised, scope potentially compromised assets by tracking servers, services, and data accessed by the account in the last 24 hours.
54
55### False positive analysis
56
57- False positives can occur if activity is coming from new employees based in a city with no previous history in AWS.
58- Examine the history of the command. If the command only manifested recently, it might be part of a new automation module or script. If it has a consistent cadence (for example, it appears in small numbers on a weekly or monthly cadence), it might be part of a housekeeping or maintenance process. You can find the command in the `event.action field` field.
59
60### Related Rules
61
62- Unusual Country For an AWS Command - dca28dee-c999-400f-b640-50a081cc0fd1
63- Unusual AWS Command for a User - ac706eae-d5ec-4b14-b4fd-e8ba8086f0e1
64- Rare AWS Error Code - 19de8096-e2b0-4bd8-80c9-34a820813fff
65- Spike in AWS Error Messages - 78d3d8d9-b476-451d-a9e0-7a5addd70670
66
67### Response and remediation
68
69- Initiate the incident response process based on the outcome of the triage.
70- Disable or limit the account during the investigation and response.
71- Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
72    - Identify the account role in the cloud environment.
73    - Assess the criticality of affected services and servers.
74    - Work with your IT team to identify and minimize the impact on users.
75    - Identify if the attacker is moving laterally and compromising other accounts, servers, or services.
76    - Identify any regulatory or legal ramifications related to this activity.
77- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords or delete API keys as needed to revoke the attacker's access to the environment. Work with your IT teams to minimize the impact on business operations during these actions.
78- Check if unauthorized new users were created, remove unauthorized new accounts, and request password resets for other IAM users.
79- Consider enabling multi-factor authentication for users.
80- Review the permissions assigned to the implicated user to ensure that the least privilege principle is being followed.
81- Implement security best practices [outlined](https://aws.amazon.com/premiumsupport/knowledge-center/security-best-practices/) by AWS.
82- Take the actions needed to return affected systems, data, or services to their normal operational levels.
83- Identify the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
84- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
85
86## Setup
87
88The AWS Fleet integration, Filebeat module, or similarly structured data is required to be compatible with this rule.
89"""
90references = ["https://www.elastic.co/guide/en/security/current/prebuilt-ml-jobs.html"]
91risk_score = 21
92rule_id = "809b70d3-e2c3-455e-af1b-2626a5a1a276"
93severity = "low"
94tags = ["Domain: Cloud", "Data Source: AWS", "Data Source: Amazon Web Services", "Rule Type: ML", "Rule Type: Machine Learning", "Resources: Investigation Guide"]
95type = "machine_learning"

Triage and analysis

Investigating Unusual City For an AWS Command

CloudTrail logging provides visibility on actions taken within an AWS environment. By monitoring these events and understanding what is considered normal behavior within an organization, you can spot suspicious or malicious activity when deviations occur.

This rule uses a machine learning job to detect an AWS API command that while not inherently suspicious or abnormal, is sourcing from a geolocation (city) that is unusual for the command. This can be the result of compromised credentials or keys used by a threat actor in a different geography than the authorized user(s).

Detection alerts from this rule indicate an AWS API command or method call that is rare and unusual for the geolocation of the source IP address.

Possible investigation steps

  • Identify the user account involved and the action performed. Verify whether it should perform this kind of action.
    • Examine the user identity in the aws.cloudtrail.user_identity.arn field and the access key ID in the aws.cloudtrail.user_identity.access_key_id field, which can help identify the precise user context.
    • The user agent details in the user_agent.original field may also indicate what kind of a client made the request.
  • Investigate other alerts associated with the user account during the past 48 hours.
  • Validate the activity is not related to planned patches, updates, or network administrator activity.
  • Examine the request parameters. These might indicate the source of the program or the nature of its tasks.
  • Considering the source IP address and geolocation of the user who issued the command:
    • Do they look normal for the calling user?
    • If the source is an EC2 IP address, is it associated with an EC2 instance in one of your accounts or is the source IP from an EC2 instance that's not under your control?
    • If it is an authorized EC2 instance, is the activity associated with normal behavior for the instance role or roles? Are there any other alerts or signs of suspicious activity involving this instance?
  • Consider the time of day. If the user is a human (not a program or script), did the activity take place during a normal time of day?
  • Contact the account owner and confirm whether they are aware of this activity if suspicious.
  • If you suspect the account has been compromised, scope potentially compromised assets by tracking servers, services, and data accessed by the account in the last 24 hours.

False positive analysis

  • False positives can occur if activity is coming from new employees based in a city with no previous history in AWS.
  • Examine the history of the command. If the command only manifested recently, it might be part of a new automation module or script. If it has a consistent cadence (for example, it appears in small numbers on a weekly or monthly cadence), it might be part of a housekeeping or maintenance process. You can find the command in the event.action field field.
  • Unusual Country For an AWS Command - dca28dee-c999-400f-b640-50a081cc0fd1
  • Unusual AWS Command for a User - ac706eae-d5ec-4b14-b4fd-e8ba8086f0e1
  • Rare AWS Error Code - 19de8096-e2b0-4bd8-80c9-34a820813fff
  • Spike in AWS Error Messages - 78d3d8d9-b476-451d-a9e0-7a5addd70670

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • Disable or limit the account during the investigation and response.
  • Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
    • Identify the account role in the cloud environment.
    • Assess the criticality of affected services and servers.
    • Work with your IT team to identify and minimize the impact on users.
    • Identify if the attacker is moving laterally and compromising other accounts, servers, or services.
    • Identify any regulatory or legal ramifications related to this activity.
  • Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords or delete API keys as needed to revoke the attacker's access to the environment. Work with your IT teams to minimize the impact on business operations during these actions.
  • Check if unauthorized new users were created, remove unauthorized new accounts, and request password resets for other IAM users.
  • Consider enabling multi-factor authentication for users.
  • Review the permissions assigned to the implicated user to ensure that the least privilege principle is being followed.
  • Implement security best practices outlined by AWS.
  • Take the actions needed to return affected systems, data, or services to their normal operational levels.
  • Identify the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
  • Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).

Setup

The AWS Fleet integration, Filebeat module, or similarly structured data is required to be compatible with this rule.

References

Related rules

to-top