Detection: CodeBuild Project Service Role Updated
Overview
Detect when an service role associated with an AWS CodeBuild project was updated. Unauthorized or unintended role changes can grant excessive permissions, disrupt build processes, or expose sensitive resources. Monitoring service role updates ensures permissions align with the principle of least privilege and safeguards the security of build environments.
References:
Usage
Run the detection in your terminal:
powerpipe detection run aws_cloudtrail_log_detections.detection.codebuild_project_service_role_updated
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe detection run aws_cloudtrail_log_detections.detection.codebuild_project_service_role_updated --share
SQL
This detection uses a named query:
select tp_timestamp as timestamp,string_split(event_source, '.')[1] || ':' || event_name as operation,request_parameters ->> 'name' as resource,user_identity.arn as actor,tp_source_ip as source_ip,tp_index as account_id,aws_region as region,tp_id as source_id,*
from aws_cloudtrail_logwhere event_source = 'codebuild.amazonaws.com' and event_name = 'UpdateProject' and (request_parameters ->> 'serviceRole') is not null and error_code is null
order by event_time desc;