Detection: Lambda Function Granted Public Access
Overview
Detect when an AWS Lambda function was granted public access. Publicly accessible functions expose workloads to unauthorized invocations, increasing the risk of malicious exploitation, data breaches, or resource abuse. Restricting access to trusted users, roles, and services ensures security and cost efficiency.
References:
Usage
Run the detection in your terminal:
powerpipe detection run aws_cloudtrail_log_detections.detection.lambda_function_granted_public_access
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe detection run aws_cloudtrail_log_detections.detection.lambda_function_granted_public_access --share
SQL
This detection uses a named query:
select tp_timestamp as timestamp,string_split(event_source, '.')[1] || ':' || event_name as operation,request_parameters ->> 'functionName' 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 = 'lambda.amazonaws.com' and event_name like 'AddPermission%' and (request_parameters ->> 'principal') = '*' and error_code is null
order by event_time desc;