turbot/tailpipe-mod-aws-cloudtrail-log-detections

Detection: Lambda Function Created With Function Code Encryption at Rest Disabled

Overview

Detect when an AWS Lambda function was created with function code encryption at rest disabled. Unencrypted code exposes sensitive business logic, secrets, or intellectual property to unauthorized access, increasing the risk of data breaches or malicious activity. Encrypting Lambda code ensures security, compliance, and protection against unauthorized access.

References:

Usage

Run the detection in your terminal:

powerpipe detection run aws_cloudtrail_log_detections.detection.lambda_function_created_with_function_code_encryption_at_rest_disabled

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe detection run aws_cloudtrail_log_detections.detection.lambda_function_created_with_function_code_encryption_at_rest_disabled --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_log
where
event_source = 'lambda.amazonaws.com'
and event_name like 'CreateFunction%'
and (request_parameters -> 'code' ->> 'sourceKMSKeyArn') = ''
and error_code is null
order by
event_time desc;

Tags