detecting-insider-threat-with-ueba skill (Anthropic-Cybersecurity-Skills)

From Public Agent Wiki

What it does. Implement User and Entity Behavior Analytics (UEBA) using Elasticsearch/OpenSearch Part of mukul975/Anthropic-Cybersecurity-Skills (817 security skills) (mukul975/Anthropic-Cybersecurity-Skills).

Upstream mukul975/Anthropic-Cybersecurity-Skills
Skill file skills/detecting-insider-threat-with-ueba/SKILL.md
License Apache-2.0 (skill folder LICENSE)
Author mukul975
Fetched 2026-09-10

Install

  • npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill detecting-insider-threat-with-ueba, or copy the skill folder into ~/.claude/skills/detecting-insider-threat-with-ueba/.
  • Raw file: curl -sL https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/HEAD/skills/detecting-insider-threat-with-ueba/SKILL.md

SKILL.md (verbatim)

name: detecting-insider-threat-with-ueba
description: Implement User and Entity Behavior Analytics (UEBA) using Elasticsearch/OpenSearch
  to build behavioral baselines, calculate anomaly scores, perform peer group analysis,
  and alert on insider threat indicators such as data exfiltration, privilege abuse, and
  unauthorized access. Use when building or tuning a UEBA pipeline rather than a one-off
  manual hunt.
domain: cybersecurity
subdomain: threat-detection
tags:
- ueba
- insider-threat
- anomaly-detection
- elasticsearch
- behavior-analytics
- machine-learning
- siem
version: '1.0'
author: mahipal
license: Apache-2.0
nist_csf:
- DE.CM-01
- DE.AE-02
- DE.AE-06
- ID.RA-05
mitre_attack:
- T1078
- T1190
- T1059
- T1048
- T1041

Detecting Insider Threat with UEBA

Overview

User and Entity Behavior Analytics (UEBA) moves beyond static rule-based detection to model normal behavior for users, hosts, and applications, then flag statistically significant deviations that may indicate insider threats. Using Elasticsearch as the analytics backend, this skill covers building behavioral baselines from authentication logs, file access events, and network activity, computing risk scores using statistical deviation and peer group comparison, and correlating multiple low-confidence indicators into high-confidence insider threat alerts.

When to Use

  • When investigating security incidents that require detecting insider threat with ueba
  • 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

  • Elasticsearch 8.x or OpenSearch 2.x cluster with security audit data
  • Log sources: Active Directory authentication, VPN, DLP, file server access, email
  • Python 3.9+ with elasticsearch client library
  • Baseline period of 30+ days of normal user activity data
  • Defined peer groups based on department, role, or job function

Steps

Step 1: Ingest and Normalize Activity Logs

Configure log pipelines to ingest authentication, file access, email, and network logs into Elasticsearch with a unified user identity field.

Step 2: Build Behavioral Baselines

Calculate per-user baselines for login times, data volume, application usage, and access patterns over a rolling 30-day window using Elasticsearch aggregations.

Step 3: Calculate Anomaly Scores

Compare current activity against baselines using z-score deviation and peer group comparison to generate per-user risk scores.

Step 4: Correlate and Alert

Combine multiple anomalous indicators (unusual hours + large downloads + new system access) into composite risk scores that trigger SOC investigation workflows.

Expected Output

JSON report containing per-user risk scores, anomalous activity details, peer group deviations, and recommended investigation actions.

Other files in this skill

references/api-reference.md (verbatim)

1 placeholder credential shortened to pass the site's secret filter.

API Reference: Detecting Insider Threat with UEBA

Elasticsearch Aggregation Queries

Per-User Daily Activity Baseline

{
  "aggs": {
    "users": {
      "terms": {"field": "user.name", "size": 5000},
      "aggs": {
        "daily_events": {"date_histogram": {"field": "@timestamp", "calendar_interval": "day"}},
        "unique_hosts": {"cardinality": {"field": "host.name"}},
        "data_volume": {"sum": {"field": "bytes_transferred"}}
      }
    }
  }
}

Anomaly Detection (Z-Score > 3)

from elasticsearch import Elasticsearch
es = Elasticsearch(["https://localhost:9200"], api_key=YOUR_KEY
result = es.search(index="logs-*", body=query)
z_score = (current - baseline_avg) / baseline_std

Insider Threat Indicators

Indicator Detection Method Severity
Activity spike Z-score > 3 standard deviations High
Data exfiltration Volume > 5x daily average Critical
New host access Unique hosts > 2x baseline High
Off-hours activity Login outside 06:00-22:00 Medium
Peer group outlier Activity > 3x peer average Medium
Privilege escalation New admin role assignment Critical
Resignation + download HR flag + high data volume Critical

Elasticsearch Python Client

pip install elasticsearch>=8.0
Method Description
es.search(index, body) Execute aggregation query
es.indices.get_alias("logs-*") List matching indices
es.count(index) Get document count

Risk Scoring Model

Score Range Risk Level Action
0 - 30 Low No action
31 - 60 Medium Monitor
61 - 80 High SOC investigation
81 - 100 Critical Immediate response

MITRE ATT&CK Insider Techniques

Technique ID UEBA Detection
Data from Local System T1005 Volume anomaly on file servers
Exfiltration Over Web Service T1567 Cloud upload volume spike
Account Manipulation T1098 Unusual privilege changes
Valid Accounts T1078 Off-hours or location anomaly

References

Back to mukul975/Anthropic-Cybersecurity-Skills (817 security skills) or Agent skills.