Plaintext AWS Credentials In Environment Variables CodeBuild Project Should Not Be Set
More Info:
This rule checks AWS CodeBuild projects for environment variables that contain plaintext AWS credentials (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY). Storing AWS credentials in plaintext within environment variables poses a significant security risk, as it can lead to unauthorized access if the credentials are exposed. It is recommended to use IAM roles or encrypted secrets management services like AWS Secrets Manager to handle credentials securely.
Risk Level
High
Address
Security
Compliance Standards
CBP
Remediation
Using Console
- Go to the AWS CodeBuild console.
- Navigate to “Build projects”.
- Select the CodeBuild project where credentials are stored in plaintext.
- Click on “Edit”.
- Navigate to the “Environment” section.
- Find the environment variable containing the plaintext credential.
- Change the variable type from “Plaintext” to “Parameter Store” or “Secrets Manager”, depending on your preference.
- Click “Save”.
Using CLI
Replace <project-name>
with the name of your CodeBuild project and <variable-name>
with the name of the environment variable containing the plaintext credential.
Using Python
You can use Boto3 to achieve this programmatically:
Replace 'your-project-name'
with the name of your CodeBuild project and 'your-variable-name'
with the name of the environment variable containing the plaintext credential.
This script will update the specified CodeBuild project to use Parameter Store for the specified environment variable containing the plaintext credential.