Skip to main content

Triage and Remediation

Remediation

Using Console

Here’s how to enable artifact encryption for an AWS CodeBuild project using the AWS Management Console:

1. Identify the CodeBuild project

  1. Sign in to the AWS Management Console.
  2. Go to CodeBuild:
    Services → CodeBuild.
  3. In the left menu, click Build projects.
  4. Click the name of the project you need to fix.

2. Edit the project

  1. On the project details page, click Edit in the upper-right corner.
  2. Scroll down to the Artifacts section.

3. Ensure artifact type and location are set

  1. Under Artifacts, make sure:
    • Type is Amazon S3 (or another artifact type that supports encryption).
    • Bucket name is set to the S3 bucket where artifacts are stored.
If you don’t have a bucket yet, create one in S3 first, then return and select it.

4. Configure encryption

In the Artifacts section:
  1. Find Encryption key (sometimes labeled KMS key or similar).
  2. Choose one of:
    • Default AWS managed key for S3:
      Select aws/s3 or the default option shown, or
    • Customer managed key (CMK):
      • From the dropdown, select your KMS key ARN,
      • or paste the full key ARN from AWS KMS.
Make sure the KMS key policy allows CodeBuild and the IAM role used by the project to use the key (kms:Encrypt, kms:Decrypt, kms:GenerateDataKey at minimum for the project role).

5. Save changes

  1. Scroll to the bottom of the page.
  2. Click Update artifacts (if present) and/or Update / Save to apply the changes to the project.

6. (Optional) Verify in S3

  1. Go to S3 → select the bucket used for artifacts.
  2. Open PropertiesDefault encryption:
    • Ensure it is set to AWS KMS (or at least SSE-S3), and
    • Confirm it matches your expected encryption settings.
Note: The CodeBuild artifact encryption control is generally satisfied when an encryption key is configured for artifacts (and the bucket is not left unencrypted).
If you share the exact scanner/tool (e.g., Security Hub, Checkov, etc.), I can tailor the final check to what that tool expects.
Below are the minimal steps to turn on artifact encryption for an AWS CodeBuild project using the AWS CLI.

1. Identify the project and KMS key

Pick the project name and the KMS key you want to use (either an alias or key ARN):

2. Get the current project configuration

This file will be used as a base for the update.

3. Edit project.json to enable artifact encryption

Open project.json in an editor and construct an update-project payload.
You must supply the full configuration blocks required by update-project, not just the changed fields.
Create a new file update-project.json with content like:
Key parts for encryption:
  • "encryptionDisabled": false
  • "encryptionKey": "YOUR_KMS_KEY_ARN_OR_ALIAS"
Adjust all values (role, image, source, bucket, etc.) to match what you saw in project.json.If you previously had multiple artifacts (secondaryArtifacts), repeat the same properties for each artifact that should be encrypted.

4. Apply the update


5. Verify configuration

You should see:
  • encryptionDisabled = false
  • encryptionKey = your KMS key ARN/alias
To remediate “Artifact Encryption Should Be Enabled” for an AWS CodeBuild project using Python, you need to:
  1. Have (or create) a KMS key.
  2. Update the CodeBuild project’s artifacts (and any secondaryArtifacts) to:
    • encryptionDisabled = False (or omit it)
    • encryptionKey = <KMS key ARN or alias>
Below is a minimal, step‑by‑step guide with Python/boto3.

1. Prerequisites

  • boto3 installed:
  • AWS credentials configured (via aws configure, environment variables, or IAM role).

2. (Optional) Create a KMS Key in Python

If you don’t already have a KMS key you want to use:
You can then use either:
  • ARN of the key, or
  • alias/codebuild-artifacts as the encryption key value.

3. Update an Existing CodeBuild Project to Enable Artifact Encryption

This script:
  • Gets the current project configuration.
  • Reuses all existing fields.
  • Updates artifacts to enable encryption and set a KMS key.
  • Does the same for any secondaryArtifacts if present.

4. Notes / Checks

  • Ensure the CodeBuild service role has permission to use the KMS key:
    • KMS key policy should allow codebuild.amazonaws.com or the specific role ARN kms:Encrypt, kms:Decrypt, kms:GenerateDataKey*, kms:DescribeKey.
  • Verify encryption is enabled:
    • In the console: CodeBuild → Project → Artifacts → check KMS key configured.
    • Or via batch_get_projects and inspect artifacts["encryptionKey"] and artifacts["encryptionDisabled"].
This will remediate the “Artifact Encryption Should Be Enabled” finding programmatically for the project.
This matches the CLI fix by ensuring encryption_disabled is set to false on the primary artifacts block (and any secondary_artifacts blocks) in Terraform instead of via aws codebuild update-project. This change is in-place and does not force replacement of the CodeBuild project.For verification, terraform plan should show the aws_codebuild_project update changing artifacts[*].encryption_disabled (and any secondary_artifacts[*].encryption_disabled) from true (or omitted) to false.