Lack of protection against deletion - EC2
Description
Instances do not have the termination/removal protection option enabled.
Impact
- Delete or terminate instances by accident.
- Lose of EBS data.
Recommendation
Ensure that instances have Termination Protection safety feature enabled.
Threat
External attacker with AWS credentials.
Expected Remediation Time
⌚ 30 minutes.
Score
Default score using CVSS 3.1. It may change depending on the context of the vulnerability.
Base
- Attack vector: N
- Attack complexity: L
- Privileges required: H
- User interaction: N
- Scope: U
- Confidentiality: N
- Integrity: N
- Availability: H
Temporal
- Exploit code madurity: P
- Remediation level: O
- Report confidence: C
Result
- Vector string: CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C
- Score:
- Base: 4.9
- Temporal: 4.4
- Severity:
- Base: Medium
- Temporal: Medium
Code Examples
Compliant code
The resource has correctly configured protection against deletion
Resources:
MyLaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateName: MyLaunchTemplate
LaunchTemplateData:
InstanceType: t2.micro
KeyName: MyKeyPair
DisableApiTermination: true
Non compliant code
The resource does not have any protection against deletion
Resources:
MyLaunchTemplate:
Type: AWS::EC2::LaunchTemplate
Properties:
LaunchTemplateName: MyLaunchTemplate
LaunchTemplateData:
InstanceType: t2.micro
KeyName: MyKeyPair
DisableApiTermination: false
resource "aws_launch_template" "foo" {
name = "foo"
...
cpu_options {
core_count = 4
threads_per_core = 2
}
disable_api_termination = false
}
Using the AWS CLI, verify that EC2 has protection against deletion using the following command
$ aws ec2 describe-instance-attribute
--region us-east-1
--instance-id {instance_id}
--attribute disableApiTermination
If the command output returns false, termination protection is not enabled for the selected instance
Requirements
Search for vulnerabilities in your apps for free with our automated security testing! Start your 21-day free trial and discover the benefits of our Continuous Hacking Machine Plan. If you prefer a full service that includes the expertise of our ethical hackers, don't hesitate to contact us for our Continuous Hacking Squad Plan.