AWS Lambda Event Source Mapping Creation
Description
Identifies the creation of an AWS Lambda event source mapping, which connects an event source such as an Amazon SQS queue, an Amazon Kinesis or DynamoDB stream, an Amazon MSK or self-managed Apache Kafka topic, or an Amazon MQ broker to a Lambda function so the function is automatically invoked when new records arrive. Adversaries with "lambda:CreateEventSourceMapping" permissions can abuse this to establish stealthy, event-driven persistence and execution, or to continuously siphon records from a stream or queue into attacker-controlled function code. Because the function then runs on its own whenever the source produces events, this grants durable execution without any further interactive activity by the adversary.
Query · kuery
data_stream.dataset: "aws.cloudtrail"
and event.provider: "lambda.amazonaws.com"
and event.action: CreateEventSourceMapping*
and event.outcome: "success"
Investigation fields
Pivot points the source recommends for triage.
@timestampuser.nameuser_agent.originalsource.ipaws.cloudtrail.user_identity.arnaws.cloudtrail.user_identity.typeaws.cloudtrail.user_identity.access_key_idaws.cloudtrail.user_identity.session_context.session_issuer.arnaws.cloudtrail.request_parametersaws.cloudtrail.response_elementsevent.actionevent.outcomecloud.account.idcloud.region
Known false positives
- Application teams and infrastructure-as-code pipelines routinely create event source mappings to wire data pipelines, queue consumers, and stream processors to Lambda functions. Verify whether the principal in `aws.cloudtrail.user_identity.arn`, the function, and the event source are expected for the workload. Known deployment roles and automation can be excluded after validation.
Analyst notes
Investigating AWS Lambda Event Source Mapping Creation
AWS Lambda event source mappings poll an event source (Amazon SQS, Kinesis or DynamoDB streams, Amazon MSK or self-managed Kafka, or Amazon MQ) and invoke a target function as records arrive. Creating a mapping is a low-frequency, high-impact configuration change: it can establish event-driven persistence and execution, or quietly relay sensitive records from a stream or queue into attacker-controlled code.
This rule detects successful CreateEventSourceMapping calls. Investigate whether the principal, the target function, and the event source are expected for the environment.
Possible investigation steps
- Identify the actor in
aws.cloudtrail.user_identity.arnandaws.cloudtrail.user_identity.type, and reviewsource.ipanduser_agent.originalto determine whether the call came from the console, CLI, SDK, or automation. - Inspect
aws.cloudtrail.request_parametersfor thefunctionName/functionArnand theeventSourceArnto identify the target function and the source queue, stream, topic, or broker. - Determine whether the target function and the event source belong to the same application and account, and whether the function code, role, and recent changes are trusted (correlate with
CreateFunction,UpdateFunctionCode, andAddPermission). - Review whether the event source contains sensitive data (for example a DynamoDB stream or SQS queue carrying business records) that the mapping could be used to exfiltrate.
- Pivot on the same principal and access key for other recent Lambda, IAM, or data-plane activity.
False positive analysis
- Event source mappings are a normal building block of serverless data pipelines and queue/stream consumers. Mappings created by approved deployment roles, CI/CD pipelines, or application teams are expected. Tune on
aws.cloudtrail.user_identity.arn,user_agent.original, or known automation roles after validation.
Response and remediation
- If the mapping is unauthorized, disable or delete it (
DeleteEventSourceMapping) and review the target function's code, configuration, and execution role. - Determine whether records were processed by the function while the mapping was active and assess potential data exposure.
- Rotate or restrict credentials for the principal that created the mapping if compromise is suspected, and constrain
lambda:CreateEventSourceMappingto a small set of trusted roles.