Webhook icon
Schedule icon
Script icon
Docker icon
If icon
SlackIncomingWebhook icon
Create icon
Switch icon
Log icon

Correlate Failed Teleport MFA Challenges and Escalate a Credential Stuffing Burst

Correlate bursts of failed Teleport MFA challenges per user, route contain or observe, and escalate with a Slack alert and a GitHub issue.

Categories
Infrastructure

How it works

  1. audit_events_webhook (io.kestra.plugin.core.trigger.Webhook, keyed with TELEPORT_AUDIT_WEBHOOK_KEY) accepts a batch of audit events from the Teleport auth service or from a log forwarder tailing its audit log, and hourly_mfa_sweep (io.kestra.plugin.core.trigger.Schedule, cron 0 * * * *) ships with disabled: true as a rehearsal that audits a bundled sample batch.
  2. audit_mfa_events (io.kestra.plugin.scripts.python.Script on the io.kestra.plugin.scripts.runner.docker.Docker runner, image python:3.12-slim) reads the webhook body, accepts a single event, an events array, or a bare array, and falls back to the bundled sample when the run came from the schedule. It classifies every authentication event as a failure, a success, or neutral (mfa_auth_challenge.create neither starts nor ends a streak), groups them per user, sorts them by time, and counts consecutive failures where each gap is at most window_minutes; a successful login resets that user's streak to zero.
  3. From the per-user streaks it derives risk_band, contain at or above mfa_failure_threshold, observe at or above observe_threshold, clear below it, and observe whenever the payload could not be parsed, an unreadable batch must never read as a clean one. risky_users, max_streak, event_count, and the thresholds are emitted through the outputs protocol.
  4. gate_on_mfa_risk (io.kestra.plugin.core.flow.If, condition risk_band == 'contain') fires the moment a streak reaches mfa_failure_threshold, posting escalate_to_oncall (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) with the risky users and opening open_incident_issue (io.kestra.plugin.github.issues.Create) against the repository field from the webhook body or its default.
  5. Every lower band falls to route_response (io.kestra.plugin.core.flow.Switch, cases keyed by the band value), where observe records log_for_review so trending streaks stay visible, clear records log_clear as evidence the correlation ran, and a defaults branch catches an unexpected band.
  6. The errors block alerts Slack when the parser or the container itself breaks.

What you get

  • A per-batch risk band, risk_band, risky_users, max_streak, event_count, and parse_error are flow outputs any downstream workflow can branch on.
  • A Slack alert naming the risky users and the exact streak that crossed the contain threshold, with the thresholds and window that produced it.
  • A GitHub incident issue carrying the same list, so containment becomes tracked work instead of an announcement that scrolls away.
  • An execution history that separates a real burst from a noisy batch, observe and clear runs keep their counts for trending.

Who it's for

  • Security engineers who watch a Teleport cluster and want failed MFA challenges correlated per user instead of grepped from the audit log.
  • Platform teams running Teleport as the privileged access gateway who treat a failure burst as an incident signal.
  • On-call responders who need the risky usernames and streak length in the channel before they open a dashboard.

Why orchestrate this with Kestra

Teleport writes every attempt to its audit log and stops there, so the correlation, the thresholds, and the response all live in somebody's shell history. Kestra makes that loop declarative, a keyed webhook for the event batch, a pinned Python container holding the correlation logic with its thresholds as inputs, a branch that separates contain from observe, and escalation into Slack and GitHub from the same versioned file, with execution history that proves what the batch looked like at the moment the verdict was made.

Prerequisites

  • A worker with Docker access, the correlation runs in python:3.12-slim.
  • A Teleport audit event source that can POST JSON batches, the auth service itself through an export plugin, or a log forwarder such as Vector or Fluent Bit.
  • A GitHub repository that allows issue creation with the provided token (classic PAT scope repo, or fine-grained Issues: write).
  • A Slack incoming webhook for the contain alert and for the failure alert.

Secrets

  • TELEPORT_AUDIT_WEBHOOK_KEY: key segment guarding the webhook URL, anyone holding it can post events.
  • GITHUB_TOKEN: token used by open_incident_issue to open the incident issue.
  • SLACK_WEBHOOK_URL: Slack incoming webhook URL used by escalate_to_oncall and by the errors block.

Quick start

  1. Add the three secrets to the Kestra namespace. The incident issue lands in acme/security-operations by default, so post an optional repository field (owner/repo) next to the events to aim it at a real one.
  2. Run the flow once with no payload. The bundled sample batch carries a six attempt failure burst for one user plus a successful login for another, so expect risk_band: contain, a Slack alert, and an issue naming the bursting user.
  3. POST your own batch to /api/v1/{tenant}/executions/webhook/{namespace}/teleport-session-and-mfa-failure-audit/{TELEPORT_AUDIT_WEBHOOK_KEY} with four mfa_auth_challenge.validate failures (codes ending in E) for the same user inside ten minutes and expect risk_band: observe, then add a fifth for contain.
  4. POST only successful user.login events and expect risk_band: clear with log_clear recorded.
  5. Enable hourly_mfa_sweep when you want the sample rehearsal to run hourly as a smoke test of the pipeline.

How to extend

  • Fan the risky users out with io.kestra.plugin.core.flow.Loop, one incident issue per user, so every account gets its own tracked containment.
  • Split the payload with io.kestra.plugin.core.flow.Switch on source when several clusters POST to the same endpoint and each needs its own thresholds.
  • Land risky_users and max_streak in a warehouse table with a JDBC query task to trend streaks across weeks instead of one batch at a time.
  • Tighten the response by posting io.kestra.plugin.email.MailSend to the identity team alongside the Slack alert when the band is contain.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.