AWS IAM Brute Force of Assume Role Policy

edit

Identifies a high number of failed attempts to assume an AWS Identity and Access Management (IAM) role. IAM roles are used to delegate access to users or services. An adversary may attempt to enumerate IAM roles in order to determine if a role exists before attempting to assume or hijack the discovered role.

Rule type: threshold

Rule indices:

  • filebeat-*
  • logs-aws*

Severity: medium

Risk score: 47

Runs every: 5m

Searches indices from: now-20m (Date Math format, see also Additional look-back time)

Maximum alerts per execution: 100

References:

Tags:

  • Elastic
  • Cloud
  • AWS
  • Continuous Monitoring
  • SecOps
  • Identity and Access

Version: 8

Rule authors:

  • Elastic

Rule license: Elastic License v2

Investigation guide

edit
## Triage and analysis

### Investigating AWS IAM Brute Force of Assume Role Policy

An IAM role is an IAM identity that you can create in your account that has specific permissions. An IAM role is similar
to an IAM user, in that it is an AWS identity with permission policies that determine what the identity can and cannot
do in AWS. However, instead of being uniquely associated with one person, a role is intended to be assumable by anyone
who needs it. Also, a role does not have standard long-term credentials such as a password or access keys associated
with it. Instead, when you assume a role, it provides you with temporary security credentials for your role session.

Attackers may attempt to enumerate IAM roles in order to determine if a role exists before attempting to assume or
hijack the discovered role.

#### Possible investigation steps

- Identify the user account that performed the action and whether it should perform this kind of action.
- Verify if the `RoleName` parameter contains a unique value in all requests or if the activity is potentially a brute
force attack.
- Verify if the user account successfully updated a trust policy in the last 24 hours.
- Examine whether this role existed in the environment by looking for past occurrences in your logs.
- Investigate other alerts associated with the user account during the past 48 hours.
- Contact the account and resource owners and confirm whether they are aware of this activity.
- 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?
- Examine the account's commands, API calls, and data management actions in the last 24 hours.
- 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

- Verify the roles targeted in the failed attempts, and whether the subject role previously existed in the environment.
If only one role was targeted in the requests and that role previously existed, it may be a false positive, since
automations can continue targeting roles that existed in the environment in the past and cause false positives (FPs).

### 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](https://aws.amazon.com/premiumsupport/knowledge-center/security-best-practices/) by AWS.
- Determine 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.

Rule query

edit
event.dataset:aws.cloudtrail and
  event.provider:iam.amazonaws.com and event.action:UpdateAssumeRolePolicy and
  aws.cloudtrail.error_code:MalformedPolicyDocumentException and event.outcome:failure

Framework: MITRE ATT&CKTM