AWS Lambda Function Deletion by Unusual User

Identifies when an unusual user deletes an AWS Lambda function. Deleting a function removes its code, configuration, versions, and aliases. Adversaries may delete functions to disrupt business operations and automated workflows, to destroy attacker-deployed backdoors and remove evidence after achieving their objective, or to inhibit incident response. Because function deletion is destructive and often irreversible without redeployment, deletions performed by unexpected principals or outside change windows should be reviewed. This is a New Terms rule that uses "cloud.account.id", "user.name", and "aws.cloudtrail.flattened.request_parameters.functionName" to alert on the first time a given identity in an account successfully deletes a specific Lambda function within the history window.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2026/06/18"
  3integration = ["aws"]
  4maturity = "production"
  5updated_date = "2026/09/28"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Identifies when an unusual user deletes an AWS Lambda function. Deleting a function removes its code, configuration,
 11versions, and aliases. Adversaries may delete functions to disrupt business operations and automated workflows, to
 12destroy attacker-deployed backdoors and remove evidence after achieving their objective, or to inhibit incident
 13response. Because function deletion is destructive and often irreversible without redeployment, deletions performed by
 14unexpected principals or outside change windows should be reviewed. This is a New Terms rule that uses
 15"cloud.account.id", "user.name", and "aws.cloudtrail.flattened.request_parameters.functionName" to alert on the first
 16time a given identity in an account successfully deletes a specific Lambda function within the history window.
 17"""
 18false_positives = [
 19    """
 20    Lambda functions are routinely deleted during application decommissioning, environment teardown, and
 21    infrastructure-as-code apply/destroy cycles. Verify whether the principal in `aws.cloudtrail.user_identity.arn` and
 22    the deleted function are expected for the workload, and whether the change aligns with an approved maintenance or
 23    deployment window. Known deployment roles and automation can be excluded after validation.
 24    """,
 25]
 26from = "now-6m"
 27index = ["logs-aws.cloudtrail-*"]
 28interval = "5m"
 29language = "kuery"
 30license = "Elastic License v2"
 31name = "AWS Lambda Function Deletion by Unusual User"
 32note = """## Triage and analysis
 33
 34### Investigating AWS Lambda Function Deletion by Unusual User
 35
 36Deleting an AWS Lambda function removes its code, configuration, published versions, and aliases. This can be a destructive action that disrupts serverless workloads and automation, or a cleanup step an adversary uses to remove a backdoor function and erase evidence after their objective is met.
 37
 38This rule uses a New Terms approach to detect the first time a given identity in an account successfully deletes a Lambda function (`DeleteFunction`). Investigate whether the principal and the deleted function are expected, and whether the deletion correlates with other suspicious activity.
 39
 40#### Possible investigation steps
 41
 42- Identify the actor in `aws.cloudtrail.user_identity.arn` and `aws.cloudtrail.user_identity.type`, and review `source.ip` and `user_agent.original` to determine how the deletion was performed (console, CLI, SDK, automation).
 43- Inspect `aws.cloudtrail.flattened.request_parameters.functionName` and map the function to its application, owner, and environment (prod, staging, dev).
 44- Determine whether the deletion aligns with an approved change, decommissioning, or infrastructure-as-code destroy operation by comparing `@timestamp` against deployment and change-management records.
 45- Correlate with recent activity by the same principal or access key, such as `CreateFunction`, `UpdateFunctionCode`, `AddPermission`, `CreateEventSourceMapping`, log-group deletions, or other destructive or evasive actions.
 46- Verify whether multiple functions were deleted in a short window, which may indicate broad disruption rather than a single planned change.
 47
 48### False positive analysis
 49
 50- Function deletions are common during decommissioning and infrastructure-as-code apply/destroy cycles. Deletions by approved deployment roles, CI/CD pipelines, or platform automation are expected. Tune on `aws.cloudtrail.user_identity.arn`, `user_agent.original`, or known automation roles after validation.
 51
 52### Response and remediation
 53
 54- If the deletion is unauthorized, restore the function from source control or an infrastructure-as-code definition and confirm its code, configuration, and execution role match a known-good state.
 55- Review CloudTrail for related destructive or evasive actions by the same actor and assess operational impact.
 56- Rotate or restrict credentials for the principal if compromise is suspected, and constrain `lambda:DeleteFunction` to a small set of trusted roles.
 57"""
 58references = [
 59    "https://docs.aws.amazon.com/lambda/latest/api/API_DeleteFunction.html",
 60    "https://docs.aws.amazon.com/lambda/latest/dg/logging-using-cloudtrail.html",
 61]
 62risk_score = 21
 63rule_id = "bb3ac0e3-2c9c-4069-a26d-75ca6a6e547b"
 64severity = "low"
 65tags = [
 66    "Domain: Cloud",
 67    "Data Source: AWS",
 68    "Data Source: Amazon Web Services",
 69    "Platform: AWS",
 70    "Data Source: AWS CloudTrail",
 71    "Service: AWS Lambda",
 72    "Tactic: Impact",
 73    "Rule Type: New Terms",
 74    "Resources: Investigation Guide",
 75    "Noise: Medium",
 76    "Performance: Fast",
 77]
 78timestamp_override = "event.ingested"
 79type = "new_terms"
 80
 81query = '''
 82data_stream.dataset: "aws.cloudtrail"
 83    and event.provider: "lambda.amazonaws.com"
 84    and event.action: (DeleteFunction or DeleteFunction20*)
 85    and event.outcome: "success"
 86    and user.name: (* and not AWSServiceRoleForLambdaReplicator)
 87    and aws.cloudtrail.flattened.request_parameters.functionName: *
 88    and not user_agent.original: (*Pulumi* or *Terraform*)
 89'''
 90
 91
 92[[rule.threat]]
 93framework = "MITRE ATT&CK"
 94[[rule.threat.technique]]
 95id = "T1485"
 96name = "Data Destruction"
 97reference = "https://attack.mitre.org/techniques/T1485/"
 98
 99[[rule.threat.technique]]
100id = "T1489"
101name = "Service Stop"
102reference = "https://attack.mitre.org/techniques/T1489/"
103
104
105[rule.threat.tactic]
106id = "TA0040"
107name = "Impact"
108reference = "https://attack.mitre.org/tactics/TA0040/"
109
110[rule.investigation_fields]
111field_names = [
112    "@timestamp",
113    "user.name",
114    "user_agent.original",
115    "source.ip",
116    "aws.cloudtrail.user_identity.arn",
117    "aws.cloudtrail.user_identity.type",
118    "aws.cloudtrail.user_identity.access_key_id",
119    "aws.cloudtrail.user_identity.session_context.session_issuer.arn",
120    "aws.cloudtrail.request_parameters",
121    "aws.cloudtrail.flattened.request_parameters.functionName",
122    "aws.cloudtrail.response_elements",
123    "event.action",
124    "event.outcome",
125    "cloud.account.id",
126    "cloud.region",
127]
128
129[rule.new_terms]
130field = "new_terms_fields"
131value = ["cloud.account.id", "user.name"]
132[[rule.new_terms.history_window_start]]
133field = "history_window_start"
134value = "now-5d"

Triage and analysis

Investigating AWS Lambda Function Deletion by Unusual User

Deleting an AWS Lambda function removes its code, configuration, published versions, and aliases. This can be a destructive action that disrupts serverless workloads and automation, or a cleanup step an adversary uses to remove a backdoor function and erase evidence after their objective is met.

This rule uses a New Terms approach to detect the first time a given identity in an account successfully deletes a Lambda function (DeleteFunction). Investigate whether the principal and the deleted function are expected, and whether the deletion correlates with other suspicious activity.

Possible investigation steps

  • Identify the actor in aws.cloudtrail.user_identity.arn and aws.cloudtrail.user_identity.type, and review source.ip and user_agent.original to determine how the deletion was performed (console, CLI, SDK, automation).
  • Inspect aws.cloudtrail.flattened.request_parameters.functionName and map the function to its application, owner, and environment (prod, staging, dev).
  • Determine whether the deletion aligns with an approved change, decommissioning, or infrastructure-as-code destroy operation by comparing @timestamp against deployment and change-management records.
  • Correlate with recent activity by the same principal or access key, such as CreateFunction, UpdateFunctionCode, AddPermission, CreateEventSourceMapping, log-group deletions, or other destructive or evasive actions.
  • Verify whether multiple functions were deleted in a short window, which may indicate broad disruption rather than a single planned change.

False positive analysis

  • Function deletions are common during decommissioning and infrastructure-as-code apply/destroy cycles. Deletions by approved deployment roles, CI/CD pipelines, or platform automation are expected. Tune on aws.cloudtrail.user_identity.arn, user_agent.original, or known automation roles after validation.

Response and remediation

  • If the deletion is unauthorized, restore the function from source control or an infrastructure-as-code definition and confirm its code, configuration, and execution role match a known-good state.
  • Review CloudTrail for related destructive or evasive actions by the same actor and assess operational impact.
  • Rotate or restrict credentials for the principal if compromise is suspected, and constrain lambda:DeleteFunction to a small set of trusted roles.

References

Related rules

to-top