Suspicious Terraform Provider Execution and Network Connection
Description
Identifies an unsigned or untrusted Terraform provider binary launched by Terraform during init or plan from a user writable path outside the official registry.terraform.io provider cache, followed by an outbound network connection. Attackers may supply malicious provider binaries via typosquatted provider registries to establish access and download additional tooling, as observed in the KelpDAO incident.
Query · eql
sequence by process.entity_id with maxspan=1m
[process where event.action == "exec" and
process.name like "terraform-provider-*" and process.parent.name in ("terraform", "terraform.exe") and
process.executable like ("/Users/*", "/tmp/*", "/private/tmp/*", "?:\\Users\\*", "?:\\Users\\ProgramData\\*") and
(process.code_signature.trusted == false or process.code_signature.exists == false) and
process.parent.command_line like ("* init*", "*plan*") and
not process.command_line like (".terraform/providers/registry.terraform.io/*", ".terraform\\providers\\registry.terraform.io\\*") and
not process.executable like ("*/registry.terraform.io/*",
"*/registry.opentofu.org/*",
"*.terraform.d/plugins/terraform.local/Mastercard/*",
"*\\registry.terraform.io\\*",
"*\\registry.opentofu.org\\*",
"*.terraform.d\\plugins\\terraform.local\\Mastercard\\*")]
[any where
(event.category == "network" and event.action == "connection_attempted" and destination.domain != null and
not (process.name == "terraform-provider-aws" and destination.domain like "*.amazonaws.com") and
not (process.name == "terraform-provider-elasticstate" and destination.domain like "*.elastic.cloud")) or
(event.category == "dns" and dns.question.name != null and
not (process.name == "terraform-provider-aws.exe" and dns.question.name like "*.amazonaws.com") and
not (process.name == "terraform-provider-elasticstate.exe" and dns.question.name like "*.elastic.cloud"))
]