Amazon EC2

Instances Without IAM Role

This plugin ensures EC2 instances are using an IAM role instead of hard-coded AWS credentials.

Risk Level: Medium

Description

This plugin ensures EC2 instances are using an IAM role instead of hard-coded AWS credentials. IAM roles should be assigned to every instance so that they can access AWS resources seamlessly. It is recommended to use the IAM role as it is more secure than hard-coding AWS access keys into the application.

About the Service

Amazon EC2: Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the Amazon Web Services (AWS) Cloud. With the EC2 instance, you can launch as many virtual servers as you need, configure security and networking, and manage storage without worrying about the hardware needs of the process. Security Groups act as a firewall for an EC2 instance to control the incoming and outgoing traffic. You can read more about security groups here.

Impact

In absence of an IAM role attached to the instance, the instance can only be accessed by using the Access key to run an application on the EC2 server. The access keys are prone to get exposed. With IAM roles it can be avoided to share long-term credentials and protect your instances against unauthorized access.

Steps to Reproduce

Using AWS Console-

  1. Log In to your AWS Console.
  2. Open the EC2 Management Console. You can use this link (https://console.aws.amazon.com/ec2) to navigate directly if already logged in. 
  3. Move to the Instances in the Instances section from the left navigation pane.
  4. From the list of instances, choose one by clicking on its Instance ID.
  5. Check the IAM Role. If it is left blank, the vulnerability exists.
  6. Repeat steps 4 to 5 for all the instances you want to investigate.

Steps for Remediation

Attach an IAM role to the EC2 instance:

  1. Log In to your AWS Console.
  2. Open the EC2 Management Console. You can use this link (https://console.aws.amazon.com/ec2) to navigate directly if already logged in. 
  3. Move to the Instances in the Instances section from the left navigation pane.
  4. From the list of instances, choose the vulnerable instance by clicking on its Instance ID.
  5. Go to Actions menu > Security > Modify IAM role.
  6. Choose an IAM Role to add to the instance. Click on Save after doing the changes.
  7. Repeat the steps for all the vulnerable instances.