Control: CodeBuild project plaintext environment variables should not contain sensitive AWS values
Description
Ensure authentication credentials AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY do not exist within AWS CodeBuild project environments. Do not store these variables in clear text. Storing these variables in clear text leads to unintended data exposure and unauthorized access.
Usage
Run the control in your terminal:
powerpipe control run aws_compliance.control.codebuild_project_plaintext_env_variables_no_sensitive_aws_values
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run aws_compliance.control.codebuild_project_plaintext_env_variables_no_sensitive_aws_values --share
SQL
This control uses a named query:
with invalid_key_name as ( select distinct arn, name from aws_codebuild_project, jsonb_array_elements(environment -> 'EnvironmentVariables') as env where env ->> 'Name' ilike any(array['%AWS_ACCESS_KEY_ID%', '%AWS_SECRET_ACCESS_KEY%', '%PASSWORD%']) and env ->> 'Type' = 'PLAINTEXT')select a.arn as resource, case when b.arn is null then 'ok' else 'alarm' end as status, case when b.arn is null then a.title || ' has no plaintext environment variables with sensitive AWS values.' else a.title || ' has plaintext environment variables with sensitive AWS values.' end as reason , a.region, a.account_idfrom aws_codebuild_project as a left join invalid_key_name b on a.arn = b.arn;