analyzing-kubernetes-audit-logs
What it does
This tool analyzes Kubernetes audit logs to find suspicious activities. It looks for unauthorized access, privilege escalation, and data theft attempts, helping to identify if your cluster has been compromised.
When to use it
- ✓When you suspect your Kubernetes cluster has been breached.
- ✓To investigate what an attacker did through the API server.
- ✓When creating detection rules to protect your cluster.
Skill link
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/analyzing-kubernetes-audit-logs/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Analyze the Kubernetes audit logs and tell me if there were any attempts to access secrets or create privileged pods.”
5 new skills a week. 1 minute to read.
How it works
The tool reads log files, which are like records of everything happening in Kubernetes. It looks for specific patterns that indicate dangerous actions, such as someone trying to get into a container or access sensitive information.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Analyzing Kubernetes Audit Logs
When to Use
- When investigating security incidents that require analyzing kubernetes audit logs
- 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 container security 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
Parse Kubernetes audit log files (JSON lines format) to detect security-relevant events including unauthorized access, privilege escalation, and data exfiltration.
import json
with open("/var/log/kubernetes/audit.log") as f:
for line in f:
event = json.loads(line)
verb = event.get("verb")
resource = event.get("objectRef", {}).get("resource")
user = event.get("user", {}).get("username")
if verb == "create" and resource == "pods/exec":
print(f"Pod exec by {user}")
Key events to detect:
- pods/exec and pods/attach (shell into containers)
- secrets access (get/list/watch)
- clusterrolebindings creation (RBAC escalation)
- Privileged pod creation
- Anonymous or system:unauthenticated access
Examples
# Detect secret enumeration
if verb in ("get", "list") and resource == "secrets":
print(f"Secret access: {user} -> {event['objectRef'].get('name')}")
FAQ
What are Kubernetes audit logs?
These are detailed records of all actions performed in your Kubernetes cluster, like who did what, when, and to which resource.
What is 'exec-into-pod'?
It's when someone uses a command to enter a container running within your cluster, which can be a form of intrusion.
What are SIEM detection rules?
These are configurations in security systems (SIEM) that alert when suspicious activities, identified from logs, occur.
Details
Original description by the author
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: audi
Popularity
- GitHub stars
- 35k
- Ranking position
- #7618
- License
- Apache-2.0
- Updated
- 8/31/2026
Comments
- …
More skills from this repository
abusing-dpapi-for-credential-access
35kGives your AI agent ready-made instructions for a specific task, so it does it better and faster.
abusing-shadow-credentials-for-privesc
35kTeaches your AI agent to write clear, well-structured text.
achieving-cmmc-level-2-compliance
35kHelps your agent prepare an environment for CMMC Level 2 compliance. It implements security requirements and manages necessary documentation.
acquiring-disk-image-with-dd-and-dcfldd
35kHelps your agent create exact copies of hard drives. This is useful for ensuring no information is lost or altered during investigations.
Similar skills
reverse-engineer-anything
422kHelps your agent look inside shipped apps and packages to explain features, compare versions, or guide a rebuild, using the REA tool.
1password
394kHelps your agent set up the 1Password CLI, sign in, and read or inject secrets without printing their values into chat.
healthcheck
394kHelps your agent audit the computer or server that runs OpenClaw for security risks, such as SSH, firewall, updates, and backups, then suggest safe fixes.