This rule focuses on ensuring that EC2 instances are utilizing IMDSv2 for improved security measures.
Rule | EC2 instances should use IMDSv2 |
Framework | AWS Foundational Security Best Practices |
Severity | ✔ High |
Rule Description:
AWS recommends that EC2 instances use IMDSv2 (Instance Metadata Service version 2) to enhance security. IMDSv2 provides advanced security features, such as improved access control and protection against certain types of attacks
By enabling IMDSv2, EC2 instances can prevent potential vulnerabilities and reduce the risk of unauthorized access to instance metadata.
Remediation Steps:
Follow the steps below to enable IMDSv2 for an EC2 instance:
1. Access the EC2 Management Console:
Log in to the AWS Management Console and navigate to the EC2 service.
2. Select the desired EC2 Instance:
Identify the EC2 instance for which you want to enable IMDSv2 and select it from the list.
3. Update the Instance Metadata Options:
In the details pane, click on the "Actions" button and select "Instance Settings" -> "View/Change Instance Metadata."
4. Enable IMDSv2:
Locate the "Enable IMDSv2" option and select it to enable IMDSv2 for the selected EC2 instance.
5. Save Changes:
Click on the "Save" button to apply the changes. The instance will now use IMDSv2.
Troubleshooting Steps:
In case you encounter any issues during the process or after enabling IMDSv2, follow these troubleshooting steps:
1. Verify IMDSv2 Configuration:
Confirm that IMDSv2 is enabled for the EC2 instance by checking the instance metadata. Run the following command:
curl http://169.254.169.254/latest/api/token -X PUT -H "X-aws-ec2-metadata-token-ttl-seconds: 60" -H "X-aws-ec2-metadata-token: true"
If the command returns a token, it means IMDSv2 is enabled. Otherwise, review the remediation steps to ensure everything was followed correctly.
2. Check for Error Messages:
If you encounter any errors while accessing the instance metadata, check for error messages in the response. The error message should provide information on the source of the problem.
3. Verify Instance Metadata Access:
If you are unable to retrieve metadata using IMDSv2, confirm that your instance's security group and network ACLs (Access Control Lists) allow outbound access to the EC2 metadata service (169.254.169.254).
4. Restart the EC2 Instance:
If the above troubleshooting steps do not resolve the issue, try restarting the EC2 instance. Sometimes, a simple restart can fix certain configuration problems.
If the problem still persists, consider reaching out to AWS support for further assistance.
Additional Considerations: