π AWS EC2 Instance IMDSv2 is not enabled π’
- Contextual name: π Instance IMDSv2 is not enabled π’
- ID:
/ce/ca/aws/ec2/instance-imdsv2
- Located in: π AWS EC2
Flagsβ
- π’ Policy with categories
- π’ Policy with type
- π’ Production policy
Our Metadataβ
- Policy Type:
COMPLIANCE_POLICY
- Policy Category:
SECURITY
Similar Policiesβ
- Cloud Conformity
- Internal
dec-x-b42fae78
Similar Internal Rulesβ
Rule | Policies | Flags |
---|---|---|
βοΈ dec-x-b42fae78 | 1 |
Logicβ
- π§ prod.logic.yaml π’
Descriptionβ
Descriptionβ
When enabling the Metadata Service on AWS EC2 instances, users have the option of using either Instance Metadata Service Version 1 (IMDSv1; a request/response method) or Instance Metadata Service Version 2 (IMDSv2; a session-oriented method).
Rationaleβ
Instance metadata is data about your instance that you can use to configure or manage the running instance. Instance metadata is divided into categories, for example, host name, events, and security groups.
When enabling the Metadata Service on AWS EC2 instances, users have the option of using either Instance Metadata Service Version 1 (IMDSv1; a request/response method) or Instance Metadata Service Version 2 (IMDSv2; a session-oriented method). With IMDSv2, every request is now protected by session authentication. A session begins and ends a series of requests that software running on an EC2 instance uses to access the locally-stored EC2 instance metadata and credentials.
... see more
Remediationβ
Remediationβ
Using AWS CloudFormationβ
- CloudFormation template (YAML):
AWSTemplateFormatVersion: '2010-09-09'
Description: Enforce IMDSv2 on a specified EC2 instance
Parameters:
InstanceId:
Type: String
Description: EC2 Instance ID to update with IMDSv2 enforcement
Resources:
EnforceIMDSv2:
Type: AWS::EC2::Instance
Properties:
InstanceId: !Ref InstanceId
MetadataOptions:
HttpTokens: requiredFrom Command Lineβ
- Run
the describe-instances
command using appropriate filtering to list the IDs of all the existing EC2 instances currently available in the selected region:aws ec2 describe-instances --region <region-name> --output table --query "Reservations[*].Instances[*].InstanceId"
- The command output should return a table with the requested instance IDs.
- Now run the
modify-instance-metadata-options
command using an instance ID returned at the previous step to update the Instance Metadata Version:aws ec2 modify-instance-metadata-options --instance-id <instance-id> --http-tokens required --region <region-name>
... [see more](remediation.md)