Skip to main content

More Info:

This rule ensures that encryption is enabled for logs stored in Amazon S3 for an AWS CodeBuild project. Enabling encryption helps protect sensitive build logs from unauthorized access or tampering. It ensures that logs are encrypted while stored, providing an additional layer of security.

Risk Level

Medium

Address

Security

Compliance Standards

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

Triage and Remediation

Remediation

Using Console

To remediate “S3 Logs Should Have Encryption Enabled” for an AWS CodeBuild project via the AWS Console, you need to:
  1. Ensure the S3 bucket used for CodeBuild logs has default encryption enabled
  2. Ensure the CodeBuild project logging configuration uses that bucket (and, optionally, a KMS key)

1. Identify the S3 bucket used for CodeBuild logs

  1. Go to AWS ConsoleCodeBuild.
  2. In the left menu, click Build projects.
  3. Click on your CodeBuild project.
  4. Go to the Build details page → click Edit.
  5. Scroll down to the Logs section.
  6. Under S3 logs, note:
    • Whether S3 logging is Enabled.
    • The S3 bucket name and path prefix (this is the bucket you will configure).
If S3 logs are Disabled, turn them On and specify the desired S3 bucket. Then continue.

2. Enable encryption on the S3 bucket

  1. Go to S3 in the AWS Console.
  2. Click on the bucket identified in step 1.
  3. Go to the Properties tab.
  4. Scroll to Default encryption and click Edit.
  5. Turn Enable on.
  6. Choose one:
    • Server-side encryption with Amazon S3-managed keys (SSE-S3)
      • Simple and usually sufficient: select AES-256 (SSE-S3).
    • Server-side encryption with AWS KMS keys (SSE-KMS)
      • Choose AWS managed key or a customer managed KMS key.
  7. Click Save changes.
This ensures all new objects (including CodeBuild logs) written to this bucket are encrypted.

3. (Optional) Ensure CodeBuild log config is consistent with KMS usage

If you chose SSE-KMS:
  1. Stay in the S3 bucket’s Permissions tab.
  2. Make sure the KMS key policy allows CodeBuild and any IAM roles used by CodeBuild to use the key (kms:Encrypt, kms:Decrypt, kms:GenerateDataKey, kms:DescribeKey as needed).
  3. If you used a customer managed key, go to AWS KMSCustomer managed keys → select the key:
    • Under Key policy, ensure the CodeBuild service role is allowed to use the key.

4. Confirm/adjust CodeBuild project logging settings

  1. Go back to CodeBuildBuild projects → select your project.
  2. Click Edit.
  3. In the Logs section:
    • Under S3 logs, ensure Enabled is selected.
    • Verify the S3 bucket is the encrypted one you configured.
    • Optionally set S3 log prefix for organization.
  4. Click Update artifacts / Update / Save at the bottom (exact text may vary).

5. Validate

  1. Trigger a new build for that project.
  2. Go to the S3 bucketObjects.
  3. Open a recent log object → under Properties, confirm:
    • Server-side encryption is shown (either SSE-S3 or SSE-KMS with the selected key).
Your CodeBuild S3 logs are now encrypted, satisfying the “S3 Logs Should Have Encryption Enabled” requirement.
To fix “S3 Logs Should Have Encryption Enabled” for an AWS CodeBuild project via AWS CLI, you must update the project’s logsConfig.s3Logs to have encryptionDisabled=false (or omit it) and ensure the S3 bucket is encrypted.Below are minimal step‑by‑step CLI instructions.

1. Identify the CodeBuild project and inspect its log config

Check if you see encryptionDisabled: true.
If your log bucket isn’t already encrypted, turn on default SSE-S3 or SSE-KMS.SSE-S3 (S3-managed keys):
SSE-KMS (customer-managed KMS key):

3. Get the full current project definition

You must provide the full project configuration to update-project, not just the logs.

4. Edit project.json to fix logsConfig.s3Logs

In project.json, find logsConfig.s3Logs and set:
Notes:
  • status must be "ENABLED".
  • location is bucket-name[/optional/prefix].
  • encryptionDisabled: false (or remove the field) ensures encryption is enabled. CodeBuild will use SSE-S3 for objects it writes; the bucket policy/encryption settings will enforce SSE-S3 or SSE-KMS as configured.
Do not change other fields unless needed.

5. Update the project using the modified JSON


6. Verify the change

You should now see "status": "ENABLED" and either no encryptionDisabled field or encryptionDisabled: false. The S3 bucket should also show encryption configuration via:
To fix this for an AWS CodeBuild project using Python/boto3 you need to do two things:
  1. Ensure the S3 bucket used for CodeBuild logs has encryption enabled
  2. Ensure the CodeBuild project is configured to use encrypted S3 logs (i.e., encryptionDisabled=False)
Below are step‑by‑step instructions and an example Python remediation script.

1. Identify the CodeBuild project and its S3 log settings

First, find the project and its current S3 log configuration.
Look for:
You need:
  • "status": "ENABLED"
  • "encryptionDisabled": false (or omitted; default is encrypted if bucket has default SSE)
  • The location bucket to have default SSE.

2. Enable default encryption on the S3 bucket used for logs

If the S3 bucket doesn’t have default encryption, enable it (SSE-S3 or SSE-KMS).
This ensures that all new objects, including CodeBuild logs, are encrypted by default.

3. Ensure CodeBuild S3 logs are enabled and not marked as unencrypted

You now need to update the CodeBuild project so that:
  • S3 logs are ENABLED
  • encryptionDisabled is False or omitted
The update_project API requires you to send a mostly complete project definition. The simplest way is:
  1. Get existing project definition
  2. Modify it
  3. Call update_project

4. (Optional) Simple remediation script that just sets S3 log encryption

If you only want a focused script that:
  • Takes a project name and bucket
  • Ensures bucket encryption
  • Enables S3 logs with encryption
This aligns with the “S3 logs should have encryption enabled” control: logs are stored in an S3 bucket with default SSE, and the CodeBuild project is configured not to disable encryption.
This change does not replace the CodeBuild project; it updates the logs configuration in place, but note that logs_config is managed as a whole, so any existing CloudWatch/S3 log settings must be represented in this block or Terraform will remove them.To verify, terraform plan should show an in-place update (~) to aws_codebuild_project.THIS_PROJECT.logs_config.s3_logs.encryption_disabled changing from true (or null) to false (and any other log settings you added/updated).

Additional Reading: