Skip to main content

Triage and Remediation

Remediation

Using Console

To enable privileged mode for an AWS CodeBuild project using the AWS Management Console:
  1. Sign in to the AWS Console
  2. Open CodeBuild
    • In the top search bar, type CodeBuild and select CodeBuild from the results.
  3. Select the Project
    • In the left menu, click Build projects.
    • Find your project in the list and click the project name.
  4. Edit the Project
    • On the project details page, in the top right, click Edit.
  5. Go to Environment Settings
    • Scroll to the Environment section.
    • Look for the Additional configuration or directly visible environment options (AWS occasionally shifts the layout).
  6. Enable Privileged Mode
    • Find the checkbox Privileged (sometimes labeled “Enable this flag if you want to build Docker images or use the Docker daemon”).
    • Check Privileged to enable privileged mode.
  7. Save Changes
    • Scroll to the bottom of the page.
    • Click Update build project (or Save changes, depending on UI).
  8. Verify
    • After saving, reopen the project’s details page.
    • Confirm under Environment that Privileged mode is shown as Enabled.
You can now run builds that require Docker-in-Docker or access to the Docker daemon inside the build container.
To enable privileged mode on an existing AWS CodeBuild project via AWS CLI, you must update the project’s environment configuration and set privilegedMode to true.

1. Get the existing project configuration

The file project.json will contain all current settings.

2. Extract the current environment block

You’ll see fields like type, image, computeType, environmentVariables, etc.

3. Modify environment to enable privilegedMode

Use jq to add/set "privilegedMode": true:

4. Update the project with the modified environment

You must pass all required environment fields back, not just privilegedMode.
If you also need to preserve/update other fields (e.g., serviceRole, source, artifacts, etc.), you can supply them too, for example:
(Include only the parameters relevant to your project; some optional fields may be omitted if not in use.)

5. Verify privileged mode is enabled

The output should be true.
To remediate this, you need to update each affected CodeBuild project and set environment.privilegedMode = True using the CodeBuild API (via boto3 in Python).Below is a minimal, complete example.

1. Install and configure boto3 (if not already)


2. Python script to enable privileged mode on one project

Note: Some optional parameters vary by SDK version; if any key is invalid in your environment, remove it from update_project. At minimum, you must pass name, source, artifacts, environment, and serviceRole.

3. Script to enable privileged mode for all projects that don’t have it

(Here we only use the minimum required fields to keep the example simple; add other fields as needed, following the first script.)
This will remediate the “Privileged Mode Should Be Enabled” finding by programmatically turning on privilegedMode for the CodeBuild project environment via Python.
This change updates the existing CodeBuild project in place; it does not force resource replacement. After editing, terraform plan should show an in-place update with privileged_mode changing from false (or omitted) to true for the environment block of aws_codebuild_project.THIS_PROJECT.