Elastic low stable kql

GitHub Actions Workflow Run Rapidly Deleted

Detects when a GitHub Actions workflow run is deleted within 30 minutes of its creation. Adversaries who abuse Actions for execution or secret theft may delete short-lived runs afterward to remove job logs that show the malicious steps.

View Source

Detection Logic

FROM logs-github.audit-*
| WHERE event.module == "github" 
AND data_stream.dataset == "github.audit"
    
AND event.action IN (
      "workflows.created_workflow_run",
      "workflows.delete_workflow_run"
    )
| EVAL
    Esql.is_workflow_run_created = event.action == "workflows.created_workflow_run",
    Esql.is_workflow_run_deleted = event.action == "workflows.delete_workflow_run"
| STATS
    Esql.workflow_run_created_count = SUM(CASE(Esql.is_workflow_run_created, 1, 0)),
    Esql.workflow_run_deleted_count = SUM(CASE(Esql.is_workflow_run_deleted, 1, 0)),
    Esql.workflow_run_created_at = MIN(CASE(Esql.is_workflow_run_created, @timestamp, null)),
    Esql.workflow_run_deleted_at = MAX(CASE(Esql.is_workflow_run_deleted, @timestamp, null)),
    user.name = VALUES(user.name),
    github.actor_ip = VALUES(github.actor_ip),
    github.hashed_token = VALUES(github.hashed_token),
    github.programmatic_access_type = VALUES(github.programmatic_access_type),
    github.user_agent = VALUES(github.user_agent),
    github.data.workflow_run_id = VALUES(github.data.workflow_run_id)
  BY github.org, github.repo, github.data.workflow_id
| EVAL Esql.time_diff_seconds = DATE_DIFF(
    "second", Esql.workflow_run_created_at, Esql.workflow_run_deleted_at
  )
| WHERE Esql.workflow_run_created_count > 0
    
AND Esql.workflow_run_deleted_count > 0
    
AND Esql.time_diff_seconds >= 0
    
AND Esql.time_diff_seconds <= 1800
    
AND DATE_DIFF("minute", Esql.workflow_run_deleted_at, NOW()) <= 10
| KEEP
    Esql.workflow_run_created_at,
    Esql.workflow_run_deleted_at,
    Esql.time_diff_seconds,
    Esql.workflow_run_created_count,
    Esql.workflow_run_deleted_count,
    user.name,
    github.org,
    github.repo,
    github.actor_ip,
    github.hashed_token,
    github.programmatic_access_type,
    github.user_agent,
    github.data.workflow_id,
    github.data.workflow_run_id

False Positives

  • ⚠ Automation that deletes failed or temporary workflow runs shortly after execution. Review whether the workflow, repository, and actors are expected.

Field Validations

Loading…

Comments (0)

Loading comments...