AWS IAM AdministratorAccess Policy Attached to Group
An adversary with access to a set of compromised credentials may attempt to persist or escalate privileges by
attaching additional permissions to user groups the compromised user account belongs to. This rule looks for use of
the IAM AttachGroupPolicy
API operation to attach the highly permissive AdministratorAccess
AWS managed policy
to an existing IAM user group.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2024/05/31"
3integration = ["aws"]
4maturity = "production"
5updated_date = "2024/10/09"
6min_stack_comments = "ES|QL rule type in technical preview as of 8.13."
7min_stack_version = "8.13.0"
8
9[rule]
10author = ["Elastic"]
11description = """
12An adversary with access to a set of compromised credentials may attempt to persist or escalate privileges by
13attaching additional permissions to user groups the compromised user account belongs to. This rule looks for use of
14the IAM `AttachGroupPolicy` API operation to attach the highly permissive `AdministratorAccess` AWS managed policy
15to an existing IAM user group.
16"""
17false_positives = [
18 """
19 While this can be normal behavior, it should be investigated to ensure validity.
20 Verify whether the user identity should be using the IAM `AttachGroupPolicy` API operation
21 to attach the `AdministratorAccess` policy to the user group.
22 """,
23]
24from = "now-6m"
25language = "esql"
26license = "Elastic License v2"
27name = "AWS IAM AdministratorAccess Policy Attached to Group"
28note = """## Triage and analysis
29
30### Investigating AWS IAM AdministratorAccess Policy Attached to Group
31
32The AWS IAM `AdministratorAccess` managed policy provides full access to all AWS services and resources.
33With access to the `iam:AttachGroupPolicy` permission, a set of compromised credentials could be used to attach
34this policy to the current user's groups for privilege escalation or as a means of persistence. This rule uses [ES|QL](https://www.elastic.co/guide/en/security/master/rules-ui-create.html#create-esql-rule)
35to look for use of the `AttachGroupPolicy` operation along with request_parameters where the policyName is `AdministratorAccess`.
36
37
38#### Possible investigation steps
39
40- Identify the account and its role in the environment.
41- Review IAM permission policies for the user identity.
42- Identify the applications or users that should use this account.
43- Investigate other alerts associated with the account during the past 48 hours.
44- Investigate abnormal values in the `user_agent.original` field by comparing them with the intended and authorized usage and historical data. Suspicious user agent values include non-SDK, AWS CLI, custom user agents, etc.
45- Contact the account owner and confirm whether they are aware of this activity.
46- Considering the source IP address and geolocation of the user who issued the command:
47 - Do they look normal for the calling user?
48 - 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?
49 - 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?
50- 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.
51 - Determine what other API calls were made by the user.
52 - Assess whether this behavior is prevalent in the environment by looking for similar occurrences involving other users.
53
54### False positive analysis
55
56- False positives may occur due to the intended usage of the IAM `AdministratorAccess` managed policy. Verify the `aws.cloudtrail.user_identity.arn` should have the `iam:AttachUserPolicy` permission and that the `target.userName` should be given full administrative access.
57
58### Response and remediation
59
60- Initiate the incident response process based on the outcome of the triage.
61- Disable or limit the account during the investigation and response.
62 - Rotate user credentials
63 - Remove the `AdministratorAccess` policy from the affected group(s)
64- Identify the possible impact of the incident and prioritize accordingly; the following actions can help you gain context:
65 - Identify the account role in the cloud environment.
66 - Assess the criticality of affected services and servers.
67 - Work with your IT team to identify and minimize the impact on users.
68 - Identify if the attacker is moving laterally and compromising other accounts, servers, or services.
69 - Identify any regulatory or legal ramifications related to this activity.
70- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified.
71 - Rotate secrets or delete API keys as needed to revoke the attacker's access to the environment.
72 - Work with your IT teams to minimize the impact on business operations during these actions.
73- Check if unauthorized new users were created, remove unauthorized new accounts, and request password resets for other IAM users.
74- Consider enabling multi-factor authentication for users.
75- Review the permissions assigned to the implicated user to ensure that the least privilege principle is being followed.
76- Implement security best practices [outlined](https://aws.amazon.com/premiumsupport/knowledge-center/security-best-practices/) by AWS.
77- Take the actions needed to return affected systems, data, or services to their normal operational levels.
78- Identify the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
79- 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).
80"""
81references = [
82 "https://docs.aws.amazon.com/IAM/latest/APIReference/API_AttachGroupPolicy.html",
83 "https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AdministratorAccess.html",
84 "https://hackingthe.cloud/aws/exploitation/iam_privilege_escalation/",
85]
86risk_score = 47
87rule_id = "df919b5e-a0f6-4fd8-8598-e3ce79299e3b"
88severity = "medium"
89tags = [
90 "Domain: Cloud",
91 "Data Source: AWS",
92 "Data Source: Amazon Web Services",
93 "Data Source: AWS IAM",
94 "Use Case: Identity and Access Audit",
95 "Tactic: Privilege Escalation",
96 "Tactic: Persistence",
97 "Resources: Investigation Guide",
98]
99timestamp_override = "event.ingested"
100type = "esql"
101
102query = '''
103from logs-aws.cloudtrail-* metadata _id, _version, _index
104| where event.provider == "iam.amazonaws.com" and event.action == "AttachGroupPolicy" and event.outcome == "success"
105| dissect aws.cloudtrail.request_parameters "{%{?policyArn}=%{?arn}:%{?aws}:%{?iam}::%{?aws}:%{?policy}/%{policyName},%{?groupName}=%{group.name}}"
106| where policyName == "AdministratorAccess"
107| keep @timestamp, event.provider, event.action, event.outcome, policyName, group.name
108'''
109
110
111[[rule.threat]]
112framework = "MITRE ATT&CK"
113[[rule.threat.technique]]
114id = "T1098"
115name = "Account Manipulation"
116reference = "https://attack.mitre.org/techniques/T1098/"
117[[rule.threat.technique.subtechnique]]
118id = "T1098.003"
119name = "Additional Cloud Roles"
120reference = "https://attack.mitre.org/techniques/T1098/003/"
121
122[rule.threat.tactic]
123id = "TA0004"
124name = "Privilege Escalation"
125reference = "https://attack.mitre.org/tactics/TA0004/"
126
127[[rule.threat]]
128framework = "MITRE ATT&CK"
129[[rule.threat.technique]]
130id = "T1098"
131name = "Account Manipulation"
132reference = "https://attack.mitre.org/techniques/T1098/"
133[[rule.threat.technique.subtechnique]]
134id = "T1098.003"
135name = "Additional Cloud Roles"
136reference = "https://attack.mitre.org/techniques/T1098/003/"
137
138[rule.threat.tactic]
139id = "TA0003"
140name = "Persistence"
141reference = "https://attack.mitre.org/tactics/TA0003/"
Triage and analysis
Investigating AWS IAM AdministratorAccess Policy Attached to Group
The AWS IAM AdministratorAccess
managed policy provides full access to all AWS services and resources.
With access to the iam:AttachGroupPolicy
permission, a set of compromised credentials could be used to attach
this policy to the current user's groups for privilege escalation or as a means of persistence. This rule uses ES|QL
to look for use of the AttachGroupPolicy
operation along with request_parameters where the policyName is AdministratorAccess
.
Possible investigation steps
- Identify the account and its role in the environment.
- Review IAM permission policies for the user identity.
- Identify the applications or users that should use this account.
- Investigate other alerts associated with the account during the past 48 hours.
- Investigate abnormal values in the
user_agent.original
field by comparing them with the intended and authorized usage and historical data. Suspicious user agent values include non-SDK, AWS CLI, custom user agents, etc. - Contact the account owner and confirm whether they are aware of this activity.
- 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?
- 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.
- Determine what other API calls were made by the user.
- Assess whether this behavior is prevalent in the environment by looking for similar occurrences involving other users.
False positive analysis
- False positives may occur due to the intended usage of the IAM
AdministratorAccess
managed policy. Verify theaws.cloudtrail.user_identity.arn
should have theiam:AttachUserPolicy
permission and that thetarget.userName
should be given full administrative access.
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.
- Rotate user credentials
- Remove the
AdministratorAccess
policy from the affected group(s)
- 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.
- Rotate secrets 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).
References
Related rules
- AWS IAM AdministratorAccess Policy Attached to Role
- AWS IAM SAML Provider Updated
- AWS IAM CompromisedKeyQuarantine Policy Attached to User
- AWS IAM Roles Anywhere Profile Creation
- AWS IAM Roles Anywhere Trust Anchor Created with External CA