nuclei-templates/cloud/aws/ec2/ec2-public-ip.yaml

56 lines
1.8 KiB
YAML
Raw Permalink Normal View History

id: ec2-public-ip
info:
name: Public IP on EC2 Instances
author: princechaddha
severity: unknown
description: |
Ensures Amazon EC2 instances, especially backend ones, do not use public IP addresses to minimize Internet exposure.
impact: |
Instances with public IP addresses are more vulnerable to Internet-based threats, compromising network security.
remediation: |
Restrict public IP assignment for EC2 instances, particularly for backend instances. Use private IPs and manage access via AWS VPC and security groups.
reference:
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html#concepts-public-addresses
tags: cloud,devops,aws,amazon,ec2,aws-cloud-config
variables:
region: "us-east-1"
flow: |
code(1)
for(let InstancesName of iterate(template.instances)){
set("ec2instance", InstancesName)
code(2)
}
self-contained: true
code:
- engine:
- sh
- bash
source: |
aws ec2 describe-instances --region $region --output json --query 'Reservations[*].Instances[*].InstanceId'
extractors:
- type: json
name: instances
internal: true
json:
- '.[].[]'
- engine:
- sh
- bash
source: |
aws ec2 describe-instances --region $region --instance-ids $ec2instance --query "Reservations[*].Instances[*].NetworkInterfaces[*].Association.IpOwnerId[] | []"
matchers:
- type: word
words:
- "amazon"
extractors:
- type: dsl
dsl:
- '"The Amazon Instance " + ec2instance + " uses public IP addresses"'
# digest: 4a0a00473045022100f1dcc6e7fab82b9688102b0f02fddc8c9930007bc885800ac26e4e5ea412ed670220667fdf2d67ebff9d4346a853856402dbd78197c727feae253e6629f53de0f957:922c64590222798bb761d5b6d8e72950