standard
turbot/aws_cis
Get Involved
Version
Pipeline: 5.6 Ensure that EC2 Metadata Service only allows IMDSv2
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).
Allowing Version 1 of the service may open EC2 instances to Server-Side Request Forgery (SSRF) attacks, so Amazon recommends utilizing Version 2 for better instance security.
Remediation
From Console:
- Sign in to the AWS Management Console and navigate to the EC2 dashboard at (https://console.aws.amazon.com/ec2/)[https://console.aws.amazon.com/ec2/].
- In the left navigation panel, under the
INSTANCES
section, chooseInstances
. - Select the EC2 instance that you want to examine.
- Choose
Actions > Instance Settings > Modify instance metadata options
. - Ensure
Instance metadata service
is set toEnable
and setIMDSv2
toRequired
. - Repeat steps no. 1 – 5 to perform the remediation process for other EC2 Instances in the all applicable AWS region(s).
From 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>
- Repeat steps no. 1 – 3 to perform the remediation process for other EC2 Instances in the same AWS region.
- Change the region by updating
--region
and repeat the entire process for other regions.
Run the pipeline
To run this pipeline from your terminal:
flowpipe pipeline run aws_cis.pipeline.cis_v300_5_6
Use this pipeline
To call this pipeline from your pipeline, use a step:
step "pipeline" "step_name" { pipeline = aws_cis.pipeline.cis_v300_5_6 }
Params
Name | Type | Required | Description | Default |
---|---|---|---|---|
database | connection.steampipe | Yes | Database connection string. | connection.steampipe.default |
notifier | notifier | Yes | The name of the notifier to use for sending notification messages. | notifier.default |
notification_level | string | Yes | The verbosity level of notification messages to send. Valid options are 'verbose', 'info', 'error'. | info |
approvers | list(notifier) | Yes | List of notifiers to be used for obtaining action/approval decisions. | notifier.default |
Outputs
This pipeline has no outputs.
Tags
folder = CIS v3.0.0/5 Networking