57 lines
1.6 KiB
YAML
57 lines
1.6 KiB
YAML
id: publicly-shared-ami
|
|
info:
|
|
name: Publicly Shared AMI
|
|
author: princechaddha
|
|
severity: medium
|
|
description: |
|
|
Checks if Amazon Machine Images (AMIs) are publicly shared, potentially exposing sensitive data.
|
|
impact: |
|
|
Public sharing of AMIs can lead to unauthorized access and compromise of sensitive information contained within these images.
|
|
remediation: |
|
|
Restrict AMI sharing to specific, trusted AWS accounts and ensure they are not publicly accessible.
|
|
reference:
|
|
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/sharingamis-explicit.html
|
|
metadata:
|
|
max-request: 2
|
|
tags: cloud,devops,aws,amazon,ami,aws-cloud-config
|
|
variables:
|
|
region: "us-east-1"
|
|
|
|
flow: |
|
|
code(1)
|
|
for(let AmiName of iterate(template.amis)){
|
|
set("ami", AmiName)
|
|
code(2)
|
|
}
|
|
|
|
self-contained: true
|
|
code:
|
|
- engine:
|
|
- sh
|
|
- bash
|
|
source: |
|
|
aws ec2 describe-images --region $region --owners self --output json --query 'Images[*].ImageId' --output json
|
|
|
|
extractors:
|
|
- type: json
|
|
name: amis
|
|
internal: true
|
|
json:
|
|
- '.[]'
|
|
|
|
- engine:
|
|
- sh
|
|
- bash
|
|
source: |
|
|
aws ec2 describe-images --region $region --image-ids $ami --owners self --query 'Images[*].Public'
|
|
|
|
matchers:
|
|
- type: word
|
|
words:
|
|
- "true"
|
|
|
|
extractors:
|
|
- type: dsl
|
|
dsl:
|
|
- 'ami + " AMI is publically shared"'
|
|
# digest: 4a0a0047304502202170a728aa9a257c4f5c57f8cbe604df3b4288eb8d54deeaf7e1c8961e392c4d022100c0f6fffcdfbf887cdf6b0bf253f5d468b33670e054ff2669b3dc4c2245560595:922c64590222798bb761d5b6d8e72950 |