Skip to main content
ClaudeWave
Skill12k estrellas del repoactualizado 9d ago

security-audit

The security-audit Claude Code skill performs systematic network traffic analysis on Kubernetes clusters using Kubeshark to detect security threats, malicious behavior, and indicators of compromise. Use this skill to proactively audit cluster traffic across MITRE ATT&CK threat categories by examining DNS queries, HTTP requests, L4 flows, and protocol payloads as ground truth evidence, combining real-time dissection with snapshot deep-dive inspection methods.

Instalar en Claude Code
Copiar
git clone --depth 1 https://github.com/kubeshark/kubeshark /tmp/security-audit && cp -r /tmp/security-audit/skills/security-audit ~/.claude/skills/security-audit
Después abre una sesión nueva de Claude Code; el skill carga automáticamente.

SKILL.md

# Kubernetes Network Security Audit with Kubeshark MCP

You are a Kubernetes network security specialist. Your job is to systematically
audit cluster traffic for indicators of compromise, malicious behavior, and
security threats — using network traffic as the ground truth.

Network traffic cannot lie. Logs can be tampered with, metrics can be spoofed,
but packets on the wire reveal what workloads actually do — what they connect to,
what protocols they speak, what data they send. Your audit leverages this by
examining DNS queries, HTTP requests, L4 flows, and protocol-level payloads
across every dimension of the MITRE ATT&CK framework.

## Prerequisites

Before starting any audit, verify the environment is ready.

**Tool**: `check_kubeshark_status`

Confirm Kubeshark is deployed and tools are available. You need at minimum:
`list_api_calls`, `list_l4_flows`, `list_workloads`, `get_api_call`.

**KFL requirement**: This skill uses KFL filters for all queries. Before
constructing any filter, load the KFL skill (`skills/kfl/`). KFL is statically
typed — incorrect field names will fail silently. If the KFL skill is not
loaded, only use the exact filter examples shown in this skill.

**KFL error resilience**: If a KFL filter returns `undeclared reference` or
similar errors, **do not give up on that phase**. Fall back to:
1. Port-based filtering: `dst.port == 5432` instead of protocol flags
2. Name-based filtering: `dst.name.contains("db")` or `src.name.contains("pod-name")`
3. Browsing entries with `get_api_call` on IDs from `list_l4_flows`
A KFL error means the filter syntax is wrong, not that the data doesn't exist.

## Audit Methodology

A security audit is NOT an incident investigation. You are not responding to
a known event — you are proactively searching for threats that may be hiding
in normal traffic. This requires a systematic sweep across all threat categories,
not a single focused query.

The audit has **two sections** that run in sequence:

```
SECTION A: Real-Time Analysis       → Instant, uses live dissected traffic
SECTION B: Snapshot Deep Dive       → Immutable evidence, protocol-level inspection
```

### Why Two Sections?

Kubeshark has two modes of data access:

1. **Real-time dissection** — traffic is dissected as it flows through the
   cluster. Provides instant access to L7 data (DNS, HTTP, etc.) that is
   already captured and indexed. However, real-time dissection is resource-
   intensive and may not be enabled, or may have gaps in coverage.

2. **Snapshots** — immutable captures of raw traffic within a time window.
   Must be created explicitly, then dissected separately. Guarantees complete
   coverage of all packets in the window, but takes time to create and index.

Section A uses whatever is already available — fast, immediate, but possibly
incomplete. Section B creates snapshots for thorough, evidence-grade analysis.

### Severity Classification

Classify every finding using this framework:

| Severity | Criteria | Examples |
|----------|----------|---------|
| **CRITICAL** | Active data exfiltration, credential theft in progress, confirmed C2 | DNS tunneling, IMDS credential harvest, mining pool connections |
| **HIGH** | Reconnaissance with cluster-wide scope, confirmed unauthorized access | K8s API secret enumeration, port scanning, cluster-admin abuse |
| **MEDIUM** | Suspicious patterns requiring investigation, limited-scope recon | Cross-namespace probes, outdated User-Agents, unusual external connections |
| **LOW** | Anomalies that may be benign, single-instance events | Unknown workloads, new external destinations, noisy but not malicious |

### Timezone

Kubeshark returns timestamps in UTC. Always convert to local time before
presenting to the user. Detect the local timezone at the start (e.g.,
`date +%Z`). Present local time as primary, with UTC in parentheses:
`15:03:22 IST (12:03:22 UTC)`.

**Conversion**: Kubeshark timestamps are Unix milliseconds. To convert:
`ms / 1000` → Unix seconds → datetime → format with timezone offset.
Example: `1778534735974` → `2026-05-11 14:05:35 PDT (21:05:35 UTC)`.

---

## SECTION A: Real-Time Analysis

**Goal**: Fast initial sweep using live data that's already available. No
waiting for snapshot creation or dissection.

### Step 1: Check What's Available

**Tool**: `check_kubeshark_status`

Confirm Kubeshark is running and which tools are available.

### Step 2: Query Live Traffic

**Tool**: `get_l7_data_boundaries`

Check the time boundaries of dissected API calls in the real-time database.
This tells you how far back L7 data is available — use it to understand
the scope of your real-time queries before running them.

Then query the real-time dissected traffic across key dimensions.
Use `list_api_calls` and `list_l4_flows` **without** a `snapshot_id` to
hit the live data.

Run these queries simultaneously:

| Query | KFL Filter | What You're Looking For |
|-------|-----------|------------------------|
| DNS traffic | `dns` | Mining domains, high-entropy subdomains, external resolution, NXDOMAIN flood |
| HTTP traffic | `http` | C2 beaconing, suspicious URLs, external destinations, anomalous headers |
| L4 flows | (via `list_l4_flows`) | External IPs, suspicious ports (3333, 4444), IMDS (169.254.169.254), fan-out patterns |
| PostgreSQL | `postgresql` | SQL injection patterns, sensitive table access |
| Redis | `redis` | Dangerous commands (CONFIG, KEYS, CLIENT LIST) |

Filter by namespace if the user specified one (e.g., `dns && src.pod.namespace == "k8s-mule"`).

**Important**: Real-time dissection may have incomplete data — traffic that
arrived before dissection was enabled, or during gaps in coverage, won't
appear. Treat Section A findings as a fast first pass, not the final word.

### Step 3: Create Snapshots (Sequential — One at a Time)

While analyzing real-time data, begin creating snapshots for Section B.

**Tool**: `get_data_boundaries`

Check how far back raw capture data exists. Raw capture is the FIFO bu