SEC11-BP08 Regularly assess security properties of the pipelines
A pipeline holds the permissions to build and deploy your software, which makes it a high-value target. Apply the same security principles to the pipeline that you apply to any workload, with particular attention to separating permissions. Reassess the pipeline's security properties on a schedule.
Desired outcome:
-
Your pipelines follow the same security practices as any other workload in your environment.
-
You prevent the teams that use a pipeline from editing or bypassing the security tests it runs.
-
Each of your pipelines holds only the permissions needed for its deployments, granted through temporary credentials.
-
Your safeguards prevent a pipeline from deploying to the wrong environment.
-
Your pipelines emit state so you can validate the integrity of your build environments.
Common anti-patterns:
-
Builders can bypass the security tests in the pipeline.
-
Deployment pipelines hold overly broad permissions.
-
Pipelines are not configured to validate their inputs.
-
No one reviews the permissions attached to the CI/CD infrastructure on a regular basis.
-
Pipelines use long-lived or hardcoded credentials.
Benefits of establishing this best practice:
-
Confidence in the integrity of the software built and deployed through the pipelines increases.
-
You can stop a deployment when suspicious activity appears.
Level of risk exposed if this best practice is not established: High
Implementation guidance
Distinguish security of the pipeline from security through the pipeline. Security through a pipeline refers to the tests, scans, and gates a pipeline runs. If the pipeline itself is weakly secured, an unauthorized user who gains control of it can disable those controls and push whatever they want to production. Treat the pipeline as a workload and give it the same access controls, input validation, and permission review as the applications it deploys.
Separation of duties matters most in this aspect of pipeline security. If the team that writes the application can also edit the pipeline's security tests, then a person with that access operating under deadline pressure can weaken a failing check. Configure the pipeline so the people who use it cannot alter or bypass its security stages.
Permissions are the other major exposure. A pipeline needs enough access to deploy across environments, so an over-permissioned pipeline comprises a risk. Grant each pipeline only the permissions required by its deployments, and issue them through temporary credentials. Long-lived or hardcoded keys cannot be rotated quickly and are easily exposed.
IAM Access Analyzer policy generation builds least privilege policies from observed activity. Use it for the pipeline's own permissions, and as a pipeline step that checks the permissions of the workload being deployed. Add controls that prevent a pipeline from targeting the wrong environment, and validate pipeline inputs so malformed or harmful input cannot redirect the build.
As permissions accumulate, tools change, and new stages get added,
review the security properties of your CI/CD infrastructure on a
schedule. An
unused access analyzer reports which permissions your pipeline
roles have not used in a period you set, so the review works from
evidence. The
Deployment Pipeline Reference Architecture
Implementation steps
-
Start from a secure reference architecture: Base your pipelines on the Deployment Pipeline Reference Architecture
so security properties are built in rather than added later. -
Separate permissions so tests cannot be bypassed: Configure the pipeline so the teams that use it cannot edit or skip its security stages. Keep ownership of the security checks with a function independent of the application teams.
-
Grant least-privilege, temporary credentials: Use IAM Access Analyzer policy generation to build IAM policies with least privilege for the pipeline. Issue permissions through temporary credentials rather than long-lived keys.
-
Add environment and input safeguards: Configure controls that prevent deployment to the wrong environment, and validate pipeline inputs so malformed input cannot alter the build.
-
Integrate monitoring and alerting: Route pipeline events through Amazon EventBridge
to targets such as AWS Lambda or Amazon SNS so you are notified of abnormal activity and can stop a deployment. -
Review pipeline security on a cadence: Reassess the permissions and configuration of your CI/CD infrastructure on a schedule. Use an unused access analyzer to find permissions the pipeline no longer needs, and follow the security best practices for AWS CodePipeline.
Resources
Related best practices:
Related documents:
Related videos:
Related examples:
Related services: