Kubernetes Pod Exec with Curl or Wget to HTTPS

Detects pod or attach exec API calls where the decoded request query implies curl or wget fetching an https URL. Attackers with permission to exec into workloads often run one-liners to stage tooling, pull scripts or binaries, or exfiltrate data over HTTPS—activity that should be rare compared to shells, debuggers, or expected health checks. The rule decodes the audit requestURI, reconstructs a readable command string from repeated command parameters, and applies noise filters for common cluster health and OIDC/JWKS endpoints so benign automation is less likely to alert.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2026/04/23"
  3integration = ["kubernetes"]
  4maturity = "production"
  5updated_date = "2026/08/18"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Detects pod or attach exec API calls where the decoded request query implies curl or wget fetching an
 11https URL. Attackers with permission to exec into workloads often run one-liners to stage tooling, pull
 12scripts or binaries, or exfiltrate data over HTTPS—activity that should be rare compared to shells, debuggers, or
 13expected health checks. The rule decodes the audit requestURI, reconstructs a readable command string from
 14repeated command parameters, and applies noise filters for common cluster health and OIDC/JWKS endpoints so
 15benign automation is less likely to alert.
 16"""
 17from = "now-6m"
 18interval = "5m"
 19language = "esql"
 20license = "Elastic License v2"
 21name = "Kubernetes Pod Exec with Curl or Wget to HTTPS"
 22note = """## Triage and analysis
 23
 24### Investigating Kubernetes Pod Exec with Curl or Wget to HTTPS
 25
 26Kubernetes audit logs record exec (and similar attach) calls on requestURI, including URL-encoded
 27command segments. This rule URL-decodes the URI, extracts the query portion into a single string, and 
 28flags curl or wget combined with https, excluding several common health, localhost, and OIDC/JWKS patterns.
 29
 30### Possible investigation steps
 31
 32- Confirm who may exec into the target namespace: review kubernetes.audit.user.username, groups, impersonation, and
 33  source.ip / user_agent.original (kubectl, CI, webhooks).
 34- Map the pod (kubernetes.audit.objectRef.name) and workload owner; retrieve the decoded URI from
 35  Esql.decoded_uri and the reconstructed Esql.executed_command in the alert.
 36- Search for adjacent audit events from the same identity: secret reads, additional execs, RBAC changes, or anonymous
 37  access.
 38- If malicious, revoke credentials used for exec, review RoleBindings for **`pods/exec`**, and inspect the pod
 39  filesystem or snapshot for dropped artifacts.
 40
 41### False positive analysis
 42
 43- Approved runbooks or support sessions may use kubectl exec with curl/wget to test egress or download vendor tools;
 44  document break-glass identities and tune exclusions.
 45- Some cluster components use HTTPS to **kubernetes.default.svc** or **.well-known** endpoints; the rule attempts to
 46  filter those—expand the exclusion list if your platform uses additional first-party URLs.
 47
 48### Response and remediation
 49
 50- Rotate any secrets accessible from the pod, cordon or delete the workload if compromised, and tighten RBAC so only
 51  required principals retain **`pods/exec`** on sensitive namespaces.
 52"""
 53references = [
 54    "https://attack.mitre.org/techniques/T1609/",
 55    "https://attack.mitre.org/techniques/T1105/",
 56]
 57risk_score = 73
 58rule_id = "c9d4e8f1-2a3b-4c5d-8e9f-0a1b2c3d4e5f"
 59severity = "high"
 60tags = [
 61    "Data Source: Kubernetes",
 62    "Data Source: Kubernetes API Server Audit Logs",
 63    "Domain: Kubernetes",
 64    "Platform: Kubernetes",
 65    "Use Case: Threat Detection",
 66    "Tactic: Execution",
 67    "Tactic: Command and Control",
 68    "Resources: Investigation Guide",
 69]
 70timestamp_override = "event.ingested"
 71type = "esql"
 72query = '''
 73FROM logs-kubernetes.audit_logs-* metadata _id, _index, _version
 74| WHERE kubernetes.audit.objectRef.subresource == "exec"
 75  AND kubernetes.audit.requestURI LIKE "*command=*"
 76| EVAL Esql.decoded_uri = URL_DECODE(kubernetes.audit.requestURI)
 77| GROK Esql.decoded_uri "%{DATA}/exec\\?%{DATA:raw_commands}&(?:container|stdin|stdout|stderr)=%{GREEDYDATA}"
 78| EVAL command = REPLACE(raw_commands, "command=", "")
 79| EVAL command = REPLACE(command, "&", " ")
 80| EVAL Esql.executed_command = REPLACE(command, "\\+", " ")
 81| WHERE Esql.executed_command IS NOT NULL 
 82  AND Esql.executed_command RLIKE """.*(curl.*https|wget.*https).*"""
 83  AND NOT Esql.executed_command RLIKE """.*(/api/v1/health|/healthz|/readyz|/livez|127\.0\.0\.1|localhost|/openid/v1/jwks|/openid-connect/certs|/.well-known/openid-configuration|/.well-known/jwks\.json|kubernetes\.default\.svc).*"""
 84| KEEP Esql.*, user.name, user_agent.original, event.*, source.ip, kubernetes.audit.*, _id, _version, _index, data_stream.namespace
 85'''
 86
 87[[rule.threat]]
 88framework = "MITRE ATT&CK"
 89
 90[[rule.threat.technique]]
 91id = "T1609"
 92name = "Container Administration Command"
 93reference = "https://attack.mitre.org/techniques/T1609/"
 94
 95[rule.threat.tactic]
 96id = "TA0002"
 97name = "Execution"
 98reference = "https://attack.mitre.org/tactics/TA0002/"
 99
100[[rule.threat]]
101framework = "MITRE ATT&CK"
102
103[[rule.threat.technique]]
104id = "T1105"
105name = "Ingress Tool Transfer"
106reference = "https://attack.mitre.org/techniques/T1105/"
107
108[rule.threat.tactic]
109id = "TA0011"
110name = "Command and Control"
111reference = "https://attack.mitre.org/tactics/TA0011/"

Triage and analysis

Investigating Kubernetes Pod Exec with Curl or Wget to HTTPS

Kubernetes audit logs record exec (and similar attach) calls on requestURI, including URL-encoded command segments. This rule URL-decodes the URI, extracts the query portion into a single string, and flags curl or wget combined with https, excluding several common health, localhost, and OIDC/JWKS patterns.

Possible investigation steps

  • Confirm who may exec into the target namespace: review kubernetes.audit.user.username, groups, impersonation, and source.ip / user_agent.original (kubectl, CI, webhooks).
  • Map the pod (kubernetes.audit.objectRef.name) and workload owner; retrieve the decoded URI from Esql.decoded_uri and the reconstructed Esql.executed_command in the alert.
  • Search for adjacent audit events from the same identity: secret reads, additional execs, RBAC changes, or anonymous access.
  • If malicious, revoke credentials used for exec, review RoleBindings for pods/exec, and inspect the pod filesystem or snapshot for dropped artifacts.

False positive analysis

  • Approved runbooks or support sessions may use kubectl exec with curl/wget to test egress or download vendor tools; document break-glass identities and tune exclusions.
  • Some cluster components use HTTPS to kubernetes.default.svc or .well-known endpoints; the rule attempts to filter those—expand the exclusion list if your platform uses additional first-party URLs.

Response and remediation

  • Rotate any secrets accessible from the pod, cordon or delete the workload if compromised, and tighten RBAC so only required principals retain pods/exec on sensitive namespaces.

References

Related rules

to-top