AWS IAM AdministratorAccess Policy Attached to Role
An adversary with access to a set of compromised credentials may attempt to persist or escalate privileges by
attaching additional permissions to compromised IAM roles. This rule looks for use of the IAM AttachRolePolicy
API operation
to attach the highly permissive AdministratorAccess
AWS managed policy to an existing IAM role.
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 compromised IAM roles. This rule looks for use of the IAM `AttachRolePolicy` API operation
14to attach the highly permissive `AdministratorAccess` AWS managed policy to an existing IAM role.
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 `AttachRolePolicy` API operation
20 to attach the `AdministratorAccess` policy to the target role.
21 """,
22]
23from = "now-6m"
24language = "esql"
25license = "Elastic License v2"
26name = "AWS IAM AdministratorAccess Policy Attached to Role"
27note = """## Triage and analysis
28
29### Investigating AWS IAM AdministratorAccess Policy Attached to Role
30
31The AWS IAM `AdministratorAccess` managed policy provides full access to all AWS services and resources.
32With access to the `iam:AttachRolePolicy` permission, a set of compromised credentials could be used to attach
33this policy to a compromised role 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)
34to look for use of the `AttachRolePolicy` 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:AttachRolePolicy` permission and that the `role.name` 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 role(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_AttachRolePolicy.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 = "dde13d58-bc39-4aa0-87fd-b4bdbf4591da"
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-* metadata _id, _version, _index
103| where event.provider == "iam.amazonaws.com" and event.action == "AttachRolePolicy" and event.outcome == "success"
104| dissect aws.cloudtrail.request_parameters "{%{?policyArn}=%{?arn}:%{?aws}:%{?iam}::%{?aws}:%{?policy}/%{policyName},%{?roleName}=%{role.name}}"
105| where policyName == "AdministratorAccess"
106| keep @timestamp, event.provider, event.action, event.outcome, policyName, role.name
107'''
108
109
110[[rule.threat]]
111framework = "MITRE ATT&CK"
112[[rule.threat.technique]]
113id = "T1098"
114name = "Account Manipulation"
115reference = "https://attack.mitre.org/techniques/T1098/"
116[[rule.threat.technique.subtechnique]]
117id = "T1098.003"
118name = "Additional Cloud Roles"
119reference = "https://attack.mitre.org/techniques/T1098/003/"
120
121[rule.threat.tactic]
122id = "TA0004"
123name = "Privilege Escalation"
124reference = "https://attack.mitre.org/tactics/TA0004/"
125
126[[rule.threat]]
127framework = "MITRE ATT&CK"
128[[rule.threat.technique]]
129id = "T1098"
130name = "Account Manipulation"
131reference = "https://attack.mitre.org/techniques/T1098/"
132[[rule.threat.technique.subtechnique]]
133id = "T1098.003"
134name = "Additional Cloud Roles"
135reference = "https://attack.mitre.org/techniques/T1098/003/"
136
137[rule.threat.tactic]
138id = "TA0003"
139name = "Persistence"
140reference = "https://attack.mitre.org/tactics/TA0003/"
Triage and analysis
Investigating AWS IAM AdministratorAccess Policy Attached to Role
The AWS IAM AdministratorAccess
managed policy provides full access to all AWS services and resources.
With access to the iam:AttachRolePolicy
permission, a set of compromised credentials could be used to attach
this policy to a compromised role for privilege escalation or as a means of persistence. This rule uses ES|QL
to look for use of the AttachRolePolicy
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:AttachRolePolicy
permission and that therole.name
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 role(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 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