Skills Data Science Analyzing Credential Stuffing Attacks from Logs

Analyzing Credential Stuffing Attacks from Logs

v20260601
hunting-credential-stuffing-attacks
This skill provides structured methods for detecting credential stuffing attacks by analyzing authentication logs. It focuses on identifying complex patterns such as login velocity anomalies, high IP diversity, password spray techniques, and suspicious geographical distributions of failed logins. It is essential for SOC analysts conducting threat hunting or building robust detection rules against account takeover attempts.
Get Skill
139 downloads
Overview

Hunting Credential Stuffing Attacks

When to Use

  • When investigating security incidents that require hunting credential stuffing attacks
  • When building detection rules or threat hunting queries for this domain
  • When SOC analysts need structured procedures for this analysis type
  • When validating security monitoring coverage for related attack techniques

Prerequisites

  • Familiarity with security operations concepts and tools
  • Access to a test or lab environment for safe execution
  • Python 3.8+ with required dependencies installed
  • Appropriate authorization for any testing activities

Instructions

Analyze authentication logs to detect credential stuffing by identifying patterns of distributed login failures, high IP diversity, and suspicious ASN distribution.

import pandas as pd
from collections import Counter

# Load auth logs
df = pd.read_csv("auth_logs.csv", parse_dates=["timestamp"])

# Credential stuffing indicator: many IPs trying few accounts
ip_per_account = df[df["status"] == "failed"].groupby("username")["source_ip"].nunique()
accounts_under_attack = ip_per_account[ip_per_account > 50]

Key detection indicators:

  1. High unique source IPs per failed username
  2. Low success rate across many accounts (< 1%)
  3. ASN concentration from cloud/proxy providers
  4. Geographic impossibility (same account, distant locations)
  5. User-agent uniformity across distributed IPs

Examples

# Password spray: one password tried across many accounts
spray = df[df["status"] == "failed"].groupby(["source_ip", "password_hash"]).agg(
    accounts=("username", "nunique")).reset_index()
sprays = spray[spray["accounts"] > 10]
Info
Category Data Science
Name hunting-credential-stuffing-attacks
Version v20260601
Size 8.43KB
Updated At 2026-06-03
Language