fix: added s3 origin comprobation in cloudfront_distributions_s3_origin_non_existent_bucket (#5545)

Co-authored-by: Hugo Pereira Brito <101209179+HugoPBrito@users.noreply.github.com>
This commit is contained in:
Prowler Bot
2024-10-28 16:47:40 +01:00
committed by GitHub
parent 60dc0457af
commit 92b95f66d7
3 changed files with 7 additions and 5 deletions
@@ -1,7 +1,7 @@
{
"Provider": "aws",
"CheckID": "cloudfront_distributions_s3_origin_non_existent_bucket",
"CheckTitle": "CloudFront distributions should not point to non-existent S3 origins.",
"CheckTitle": "CloudFront distributions should not point to non-existent S3 origins without static website hosting.",
"CheckType": [
"Software and Configuration Checks/Industry and Regulatory Standards/NIST 800-53 Controls"
],
@@ -10,7 +10,7 @@
"ResourceIdTemplate": "arn:partition:cloudfront:region:account-id:distribution/resource-id",
"Severity": "high",
"ResourceType": "AwsCloudFrontDistribution",
"Description": "This control checks whether Amazon CloudFront distributions are pointing to non-existent Amazon S3 origins. The control fails if the origin is configured to point to a non-existent bucket.",
"Description": "This control checks whether Amazon CloudFront distributions are pointing to non-existent Amazon S3 origins without static website hosting. The control fails if the origin is configured to point to a non-existent bucket.",
"Risk": "Pointing a CloudFront distribution to a non-existent S3 bucket can allow malicious actors to create the bucket and potentially serve unauthorized content through your distribution, leading to security and integrity issues.",
"RelatedUrl": "https://docs.aws.amazon.com/whitepapers/latest/secure-content-delivery-amazon-cloudfront/s3-origin-with-cloudfront.html",
"Remediation": {
@@ -19,9 +19,10 @@ class cloudfront_distributions_s3_origin_non_existent_bucket(Check):
non_existent_buckets = []
for origin in distribution.origins:
bucket_name = origin.domain_name.split(".")[0]
if not s3_client._head_bucket(bucket_name):
non_existent_buckets.append(bucket_name)
if origin.s3_origin_config:
bucket_name = origin.domain_name.split(".")[0]
if not s3_client._head_bucket(bucket_name):
non_existent_buckets.append(bucket_name)
if non_existent_buckets:
report.status = "FAIL"
@@ -54,6 +54,7 @@ class Test_cloudfront_s3_origin_non_existent_bucket:
id="S3-ORIGIN",
origin_protocol_policy="",
origin_ssl_protocols=[],
s3_origin_config={"OriginAccessIdentity": ""},
),
],
)