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