Skip to main content

More Info:

Ensure that your AWS Cloudfront distributions have the Logging feature enabled in order to track all viewer requests for the content delivered through the Content Delivery Network (CDN).

Risk Level

Low

Address

Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • Essential 8
  • HITRUST CSF
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST CSF
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • PCI
  • SOC2
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • Securities and Exchange Board of India (SEBI) - Cloud Security Adoption Framework
  • StateRAMP
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration “Logging Should Be Enabled For CloudFront Distributions” for AWS using AWS console, follow the below steps:
  1. Login to the AWS Management Console and navigate to the CloudFront service.
  2. Click on the CloudFront distribution for which you want to enable logging.
  3. Click on the “Behaviors” tab and select the behavior for which you want to enable logging.
  4. Scroll down to the “Logging” section and click on “Edit”.
  5. Select “Yes” for “Enable Logging”.
  6. Choose the S3 bucket where you want to store the logs.
  7. Enter the prefix for the log files (optional).
  8. Click on “Yes, Edit” to save the changes.
Once you have completed the above steps, logging will be enabled for your CloudFront distribution and all the logs will be stored in the specified S3 bucket.

To remediate the misconfiguration “Logging should be enabled for CloudFront distributions” for AWS using AWS CLI, you can follow the below steps:
  1. Open the AWS CLI and run the following command to enable logging for a CloudFront distribution:
Note: Replace <distribution-id> with the ID of the CloudFront distribution for which you want to enable logging and replace <S3-bucket-name> and <S3-prefix> with the name of the S3 bucket and prefix where you want to store the logs.
  1. Verify that the logging is enabled for the CloudFront distribution by running the following command:
Note: Replace <distribution-id> with the ID of the CloudFront distribution for which you want to verify the logging.
  1. Ensure that the logging is working properly by checking the S3 bucket where the logs are stored.
By following the above steps, you can remediate the misconfiguration “Logging should be enabled for CloudFront distributions” for AWS using AWS CLI.
To remediate the misconfiguration of logging not being enabled for CloudFront distributions in AWS using Python, you can follow the below steps:
  1. Import the necessary AWS SDK modules for Python:
  1. Create an AWS CloudFront client object:
  1. Get a list of all the CloudFront distributions in your AWS account:
  1. For each distribution, check if logging is enabled or not:
  1. Replace ‘your-logging-bucket-name’ and ‘your-logging-prefix’ with the name of the S3 bucket and prefix where you want to store the CloudFront access logs.
  2. Run the Python script to enable logging for all the CloudFront distributions in your AWS account.
This will remediate the misconfiguration of logging not being enabled for CloudFront distributions in AWS.
This change enables CloudFront access logging to an S3 bucket and grants the delivery.logs.amazonaws.com service (CloudFront logs delivery) permission to write logs; it does not normally force distribution replacement, but will show as an in‑place update.To verify, terraform plan should show an in-place update (~) to aws_cloudfront_distribution.this adding/updating the logging_config block, plus creation (+) of the S3 bucket and its policy if they are new.

Additional Reading: