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
MediumAddress
SecurityCompliance 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
Remediation
Using Console
Using Console
To remediate “S3 Logs Should Have Encryption Enabled” for an AWS CodeBuild project via the AWS Console, you need to:
- Ensure the S3 bucket used for CodeBuild logs has default encryption enabled
- Ensure the CodeBuild project logging configuration uses that bucket (and, optionally, a KMS key)
1. Identify the S3 bucket used for CodeBuild logs
- Go to AWS Console → CodeBuild.
- In the left menu, click Build projects.
- Click on your CodeBuild project.
- Go to the Build details page → click Edit.
- Scroll down to the Logs section.
- Under S3 logs, note:
- Whether S3 logging is Enabled.
- The S3 bucket name and path prefix (this is the bucket you will configure).
2. Enable encryption on the S3 bucket
- Go to S3 in the AWS Console.
- Click on the bucket identified in step 1.
- Go to the Properties tab.
- Scroll to Default encryption and click Edit.
- Turn Enable on.
- 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.
- Server-side encryption with Amazon S3-managed keys (SSE-S3)
- Click Save changes.
3. (Optional) Ensure CodeBuild log config is consistent with KMS usage
If you chose SSE-KMS:- Stay in the S3 bucket’s Permissions tab.
- 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:DescribeKeyas needed). - If you used a customer managed key, go to AWS KMS → Customer 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
- Go back to CodeBuild → Build projects → select your project.
- Click Edit.
- 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.
- Click Update artifacts / Update / Save at the bottom (exact text may vary).
5. Validate
- Trigger a new build for that project.
- Go to the S3 bucket → Objects.
- Open a recent log object → under Properties, confirm:
- Server-side encryption is shown (either
SSE-S3orSSE-KMSwith the selected key).
- Server-side encryption is shown (either
Using CLI
Using CLI
To fix “S3 Logs Should Have Encryption Enabled” for an AWS CodeBuild project via AWS CLI, you must update the project’s
Check if you see
SSE-KMS (customer-managed KMS key):
4. Edit
In Notes:
You should now see
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
encryptionDisabled: true.2. (Optional but recommended) Enable default encryption on the S3 bucket
If your log bucket isn’t already encrypted, turn on default SSE-S3 or SSE-KMS.SSE-S3 (S3-managed keys):3. Get the full current project definition
You must provide the full project configuration toupdate-project, not just the logs.4. Edit project.json to fix logsConfig.s3Logs
In project.json, find logsConfig.s3Logs and set:statusmust be"ENABLED".locationisbucket-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.
5. Update the project using the modified JSON
6. Verify the change
"status": "ENABLED" and either no encryptionDisabled field or encryptionDisabled: false. The S3 bucket should also show encryption configuration via:Using Python
Using Python
To fix this for an AWS CodeBuild project using Python/boto3 you need to do two things:
Look for:You need:
This ensures that all new objects, including CodeBuild logs, are encrypted by default.
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.
- Ensure the S3 bucket used for CodeBuild logs has encryption enabled
- Ensure the CodeBuild project is configured to use encrypted S3 logs (i.e.,
encryptionDisabled=False)
1. Identify the CodeBuild project and its S3 log settings
First, find the project and its current S3 log configuration."status": "ENABLED""encryptionDisabled": false(or omitted; default is encrypted if bucket has default SSE)- The
locationbucket 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).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
encryptionDisabledis False or omitted
update_project API requires you to send a mostly complete project definition. The simplest way is:- Get existing project definition
- Modify it
- 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
Using Terraform
Using Terraform
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).
