-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cloudfront): Add new cloudfront_distributions_s3_origin_access_control
check to ensure OAC is configured in distributions
#4939
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4939 +/- ##
==========================================
+ Coverage 88.92% 88.97% +0.04%
==========================================
Files 953 957 +4
Lines 29237 29340 +103
==========================================
+ Hits 25999 26105 +106
+ Misses 3238 3235 -3
|
@@ -0,0 +1,32 @@ | |||
{ | |||
"Provider": "aws", | |||
"CheckID": "cloudfront_distributions_use_origin_access_control", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"CheckID": "cloudfront_distributions_use_origin_access_control", | |
"CheckID": "cloudfront_distributions_s3_origin_access_control", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you did not use moto here?
{ | ||
"Provider": "aws", | ||
"CheckID": "cloudfront_distributions_use_origin_access_control", | ||
"CheckTitle": "Check if CloudFront distributions use OAC.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"CheckTitle": "Check if CloudFront distributions use OAC.", | |
"CheckTitle": "Check if CloudFront distributions with S3 origin use OAC.", |
Please, update the metadata adding that is only for CloudFront distributions with S3 origins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, only check for CloudFront distributions with S3 origins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And iterate for the origins in each distribution
@@ -49,6 +49,14 @@ def _get_distribution_config(self, client, distributions, region) -> dict: | |||
try: | |||
for distribution_id in distributions.keys(): | |||
distribution_config = client.get_distribution_config(Id=distribution_id) | |||
oac = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed, since we already have the origins for each distribution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the Origin class please.
…o PRWLR-4451-ensure-cloud-front-distributions-use-origin-access-control-oac pull changes from master
…s-use-origin-access-control-oac
…s-use-origin-access-control-oac
cloudfront_distributions_use_origin_access_control
check to ensure OAC is configured in distributionscloudfront_distributions_s3_origin_access_control
check to ensure OAC is configured in distributions
Context
Without OAC, users might be able to access S3 content directly, bypassing CloudFront, which can expose sensitive data. OAC limits access to the S3 bucket exclusively through the CloudFront distribution, preventing direct access and offering better security controls compared to the older Origin Access Identity (OAI). This helps reduce the risk of unauthorized access to the S3 origin.
Description
The
cloudfront_distributions_s3_origin_access_control
check verifies whether OAC is enabled for CloudFront distributions with S3 origins. If OAC is not configured, the check fails, leaving the S3 content potentially vulnerable to direct access. This check ensures that access to the S3 bucket is properly restricted, allowing only traffic routed through the associated CloudFront distribution, enhancing security by enforcing best practices.Checklist
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.