Check provider logo

CodeBuild project does not use a user-controlled buildspec file

codebuild_project_user_controlled_buildspec

Severitymedium
Servicecodebuild
by Prowler

AWS CodeBuild projects are evaluated for use of a user-controlled buildspec, identified when the project references a repository file like *.yml or *.yaml. Projects using non file-based build instructions are treated as centrally managed.

Risk

Repository-controlled buildspecs let unreviewed changes run in CI, endangering integrity (tampered artifacts), confidentiality (secret leakage), and availability (resource abuse). Attackers can weaponize PRs to execute code and pivot via the build role.

Run this check with Prowler CLI

prowler aws --checks codebuild_project_user_controlled_buildspec

Recommendation

Adopt a centrally managed buildspec that contributors cannot modify.

  • Enforce protected branches and required reviews for build instructions
  • Apply least privilege to the build role and minimize secrets
  • Separate duties for pipeline admins vs code authors

Use vetted, versioned templates for defense in depth.

Remediation

Native IaC
Terraform
Other
  1. In the AWS Console, go to CodeBuild > Projects and open the target project
  2. Click Edit
  3. In Source, under Buildspec, select Insert build commands (not Use a buildspec file)
  4. Paste minimal inline YAML:
    version: 0.2
    
  5. Save

Source Code

Resource Type

AwsCodeBuildProject

References