Tooluck logoTooluck
SKILL.md

analyzing-kubernetes-audit-logs

Agent skill frommukul975/Anthropic-Cybersecurity-Skills

Parses Kubernetes API server audit logs (JSON lines) to detect exec-into-pod, secret access, RBAC modifications, privileged pod creation, and anonymous API access, and builds SIEM detection rules from the event patterns. Use when investigating a suspected cluster compromise, reconstructing what an attacker did through the API server, or writing Kubernetes-specific detection content. Keywords: audit policy, audit log, kube-apiserver, exec into pod, RBAC change, anonymous access, detection rules. Do not use for syscall-level detection inside a running container - use detecting-container-runtime-threats-with-falco. '

How to install analyzing-kubernetes-audit-logs

install analyzing-kubernetes-audit-logs
# install the Anthropic-Cybersecurity-Skills pack with the skills CLI
npx skills add mukul975/Anthropic-Cybersecurity-Skills

# or add only this skill to Claude Code: copy the folder

skills/analyzing-kubernetes-audit-logs/

# into

~/.claude/skills/analyzing-kubernetes-audit-logs/ (all projects)

.claude/skills/analyzing-kubernetes-audit-logs/ (one project)

skills/analyzing-kubernetes-audit-logs/SKILL.md

Apache-2.0Full file
1# Analyzing Kubernetes Audit Logs
2
3
4## When to Use
5
6- When investigating security incidents that require analyzing kubernetes audit logs
7- When building detection rules or threat hunting queries for this domain
8- When SOC analysts need structured procedures for this analysis type
9- When validating security monitoring coverage for related attack techniques
10
11## Prerequisites
12
13- Familiarity with container security concepts and tools
14- Access to a test or lab environment for safe execution
15- Python 3.8+ with required dependencies installed
16- Appropriate authorization for any testing activities
17
18## Instructions
19
20Parse Kubernetes audit log files (JSON lines format) to detect security-relevant
21events including unauthorized access, privilege escalation, and data exfiltration.
22
23```python
24import json
25
26with open("/var/log/kubernetes/audit.log") as f:
27 for line in f:
28 event = json.loads(line)
29 verb = event.get("verb")
30 resource = event.get("objectRef", {}).get("resource")
31 user = event.get("user", {}).get("username")
32 if verb == "create" and resource == "pods/exec":
33 print(f"Pod exec by {user}")
34```
35
36Key events to detect:
371. pods/exec and pods/attach (shell into containers)
382. secrets access (get/list/watch)
393. clusterrolebindings creation (RBAC escalation)
404. Privileged pod creation
415. Anonymous or system:unauthenticated access
42
43## Examples
44
45```python
46# Detect secret enumeration
47if verb in ("get", "list") and resource == "secrets":
48…

Excerpt shown under the repository's Apache-2.0 license.

More skills in Anthropic-Cybersecurity-Skills

Keep exploring

Similar skill repositories

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates