Profile Applicability
- Level 1
Description:
The Instance Metadata Service (IMDS) provides metadata about an EC2 instance, such as instance ID, security groups, and public IP address. IMDSv2 is a more secure version of the Instance Metadata Service, requiring token-based authentication. This SOP ensures that Auto Scaling groups use IMDSv2 for enhanced security by preventing SSRF (Server Side Request Forgery) attacks and unauthorized access to sensitive metadata.
Rationale:
Security: IMDSv2 improves security by requiring a session token to access instance metadata, protecting against attacks like SSRF (Server Side Request Forgery), which can exploit the Instance Metadata Service to gain unauthorized access to sensitive instance data.
Best Practices: The AWS shared responsibility model ensures that AWS and customers both play a role in securing infrastructure. By enforcing IMDSv2, organizations can reduce the attack surface of their EC2 instances.
Compliance: Many security frameworks (e.g., SOC 2, PCI-DSS, HIPAA) require the use of secure metadata services to prevent unauthorized access to instance metadata.
Impact:
Pros:
Enhanced Security: Ensures that instance metadata can only be accessed with a valid token, mitigating SSRF attack risks.
Compliance: Meets security requirements for metadata access control, which helps with compliance for many standards.
Attack Surface Reduction: IMDSv2 significantly reduces the potential for metadata leaks or exploitation by unauthorized entities.
Cons:
Legacy Application Compatibility: Some legacy applications may not support IMDSv2. In such cases, they may require updates to support token-based authentication.
Operational Overhead: Ensuring that all instances use IMDSv2 may require additional monitoring and configuration management.
Default Value:
By default, IMDSv2 is not required for Auto Scaling group launch configurations unless explicitly enforced. EC2 instances default to using IMDSv1 unless modified to require IMDSv2.
Pre-requisite:
AWS IAM Permissions:
autoscaling:DescribeLaunchConfigurations
autoscaling:UpdateLaunchConfiguration
AWS CLI installed and configured.
Auto Scaling group is created with launch configurations.
Test Plan:
Using AWS Console:
Sign in to the AWS Management Console.
Navigate to Auto Scaling under Services.
In the Auto Scaling Console, select Launch Configurations from the left-hand menu.
Choose the launch configuration associated with your Auto Scaling group.
Under the Launch Configuration Details section, check the Instance Metadata Service Version.
If IMDSv2 is enabled, it will show IMDSv2 as the configured version.
If IMDSv2 is not enabled, it will show that IMDSv1 is the default.
If IMDSv2 is not enabled, follow the Implementation Steps to modify the launch configuration.
Using AWS CLI:
To check if IMDSv2 is enforced for a launch configuration, run:
aws autoscaling describe-launch-configurations --launch-configuration-names <launch-configuration-name> --query 'LaunchConfigurations[*].InstanceMetadataOptions.HttpTokens'
If the output returns "required", IMDSv2 is enabled. If it returns "optional", IMDSv2 is not required.
Implementation Steps:
Using AWS Console:
Sign in to the AWS Management Console and navigate to Auto Scaling.
In the Auto Scaling Console, select Launch Configurations from the left-hand menu.
Select the launch configuration that you want to modify.
Under the Launch Configuration Details section, click Edit.
In the Instance Metadata section, select Require IMDSv2.
Save the changes to ensure that IMDSv2 is required for all instances launched by this configuration.
Using AWS CLI:
To modify the launch configuration to require IMDSv2, use the following command:
aws autoscaling update-launch-configuration \ --launch-configuration-name <launch-configuration-name> \ --instance-metadata-options HttpTokens=required
Verify that the IMDSv2 requirement has been enabled:
aws autoscaling describe-launch-configurations --launch-configuration-names <launch-configuration-name> --query 'LaunchConfigurations[*].InstanceMetadataOptions.HttpTokens'
The output should return "required" to confirm that IMDSv2 is now required for the instances launched by the configuration.
Backout Plan:
Using AWS Console:
If requiring IMDSv2 causes issues, sign in to the AWS Management Console.
Navigate to EC2, then to Auto Scaling Groups
Select the Auto Scaling Group and go to the Launch Configuration section.
Set HttpTokens to optional and HttpEndpoint to enabled to revert to IMDSv1.
Save the changes and verify that the Auto Scaling Group Launch Configuration now allows IMDSv1.
Using AWS CLI:
To revert to IMDSv1, run:
aws autoscaling update-launch-configuration --launch-configuration-name <LAUNCH_CONFIG_NAME> --metadata-options "HttpTokens=optional, HttpEndpoint=enabled"
Verify that IMDSv1 is now allowed:
aws autoscaling describe-launch-configurations --launch-configuration-name <LAUNCH_CONFIG_NAME>