Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To enable privileged mode for an AWS CodeBuild project using the AWS Management Console:
-
Sign in to the AWS Console
- Go to: https://console.aws.amazon.com/
- Make sure you are in the correct Region where the CodeBuild project exists.
-
Open CodeBuild
- In the top search bar, type CodeBuild and select CodeBuild from the results.
-
Select the Project
- In the left menu, click Build projects.
- Find your project in the list and click the project name.
-
Edit the Project
- On the project details page, in the top right, click Edit.
-
Go to Environment Settings
- Scroll to the Environment section.
- Look for the Additional configuration or directly visible environment options (AWS occasionally shifts the layout).
-
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.
-
Save Changes
- Scroll to the bottom of the page.
- Click Update build project (or Save changes, depending on UI).
-
Verify
- After saving, reopen the project’s details page.
- Confirm under Environment that Privileged mode is shown as Enabled.
Using CLI
Using CLI
To enable privileged mode on an existing AWS CodeBuild project via AWS CLI, you must update the project’s environment configuration and set The file You’ll see fields like If you also need to preserve/update other fields (e.g., (Include only the parameters relevant to your project; some optional fields may be omitted if not in use.)The output should be
privilegedMode to true.1. Get the existing project configuration
project.json will contain all current settings.2. Extract the current environment block
type, image, computeType, environmentVariables, etc.3. Modify environment to enable privilegedMode
Usejq to add/set "privilegedMode": true:4. Update the project with the modified environment
You must pass all required environment fields back, not justprivilegedMode.serviceRole, source, artifacts, etc.), you can supply them too, for example:5. Verify privileged mode is enabled
true.Using Python
Using Python
To remediate this, you need to update each affected CodeBuild project and set
1. Install and configure
(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
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 fromupdate_project. At minimum, you must passname,source,artifacts,environment, andserviceRole.
3. Script to enable privileged mode for all projects that don’t have it
This will remediate the “Privileged Mode Should Be Enabled” finding by programmatically turning on
privilegedMode for the CodeBuild project environment via Python.Using Terraform
Using Terraform
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.
