Critical

IAM user can execute a Privilege Escalation by using PassRole and RunInstances

Security & Compliance
No items found.
Description

An IAM user can execute a privilege escalation by using PassRole and RunInstances to launch an EC2 instance with an IAM role that grants them elevated permissions. This can allow the user to perform actions that they are not authorized to do directly, such as modifying or deleting AWS resources, creating new users or roles, and more. The IAM user can first create a new IAM role or select an existing role with elevated permissions and attach a policy that allows them to assume that role. Then, they can launch a new EC2 instance using the RunInstances API and pass in the IAM role ARN using the --iam-instance-profile parameter. This will cause the instance to inherit the permissions of the IAM role, effectively giving the user elevated privileges. The user can then use the AWS CLI or SDK to interact with AWS resources using the privileges of the IAM role.

Remediation

f an IAM user is able to perform privilege escalation by using PassRole and RunInstances, it means they are able to pass a role to an EC2 instance and launch that instance with elevated permissions that they wouldn't normally have.

The following are some of the steps to remediate this issue:

  1. Review IAM policies: Review the policies that are associated with the user or group that has the ability to use PassRole and RunInstances. Make sure the policies are only granting the necessary permissions and are not too permissive.
  2. Remove unnecessary permissions: Remove any permissions that are not necessary for the user to perform their job function.
  3. Restrict the use of PassRole: Restrict the use of the PassRole permission to only the necessary users or roles. This can be done by modifying the policy associated with the IAM role or user.
  4. Limit access to sensitive resources: Limit access to sensitive resources such as EC2 instances or S3 buckets that the user is able to launch with elevated permissions.
  5. Monitor for unusual activity: Implement monitoring and alerting for unusual activity such as the creation of new EC2 instances with elevated permissions. This can help detect and respond to potential attacks before they can cause any harm.
  6. Rotate credentials regularly: It is recommended to rotate IAM user credentials regularly, especially in cases where there is a risk of compromise.

By following these steps, the risk of privilege escalation can be mitigated, and IAM users can be restricted to only the necessary permissions required for their job function.

Enforced Resources
Note: Remediation steps provided by Lightlytics are meant to be suggestions and guidelines only. It is crucial to thoroughly verify and test any remediation steps before applying them to production environments. Each organization's infrastructure and security needs may differ, and blindly applying suggested remediation steps without proper testing could potentially cause unforeseen issues or vulnerabilities. Therefore, it is strongly recommended that you validate and customize any remediation steps to meet your organization's specific requirements and ensure that they align with your security policies and best practices.