analyzing-kubernetes-audit-logs — Claude Code skill: read k8s audit
Parses kube-apiserver audit logs in JSON lines and flags exec into pods, secret reads, RBAC edits and anonymous access.
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-kubernetes-audit-logs -a claude-codeWhat analyzing-kubernetes-audit-logs does
The skill walks a Kubernetes audit log line by line, parses each event as JSON and pulls out the verb, the resource and the username. Those fields drive the hunt: pods/exec and pods/attach, secrets reads through get/list/watch, new clusterrolebindings, privileged pods, calls from system:unauthenticated.
Inside are short Python snippets — open the log, loop over lines, print the user and the object. Event patterns you find can be turned into SIEM detection rules, so incident review and rule writing happen in the same pass. You need Python 3.8+ with the dependencies installed, plus a test or lab environment to run against.
This one covers the API server layer. For syscall-level detection inside a running container, reach for the Falco skill instead. Check that your audit policy actually records the events you care about — if pods/exec never lands in the log, there is nothing to search.
What it helps with
- trace who opened a shell in a pod via
pods/exec - spot secret enumeration across the cluster
- catch
clusterrolebindingscreated for privilege escalation - flag privileged pod creation
- turn API server event patterns into SIEM rules
Example prompts for the agent
- Parse
/var/log/kubernetes/audit.logand list everypods/execevent with its username - Find
secretsaccess in the audit log and group it by user - Draft a SIEM detection rule for
clusterrolebindingsand privileged pod creation
How to install analyzing-kubernetes-audit-logs
1Skills CLI (Vercel)
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-kubernetes-audit-logs -a claude-code2Manually: put the files in place
~/.claude/skills/analyzing-kubernetes-audit-logs/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/analyzing-kubernetes-audit-logs/
1Skills CLI (Vercel)
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-kubernetes-audit-logs -a codex2Manually: put the files in place
.agents/skills/analyzing-kubernetes-audit-logs/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-kubernetes-audit-logs -a cursor2Manually: put the files in place
.cursor/skills/analyzing-kubernetes-audit-logs/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install mukul975/Anthropic-Cybersecurity-Skills analyzing-kubernetes-audit-logs2Manually: put the files in place
.github/skills/analyzing-kubernetes-audit-logs/SKILL.md1Skills CLI (Vercel)
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-kubernetes-audit-logs -a gemini-cli2Platform CLI
gemini skills install https://github.com/mukul975/Anthropic-Cybersecurity-Skills --path skills/analyzing-kubernetes-audit-logsManually: put the files in place
.devin/skills/analyzing-kubernetes-audit-logs/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-kubernetes-audit-logs -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about analyzing-kubernetes-audit-logs
How do I install analyzing-kubernetes-audit-logs in Claude?
Run npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-kubernetes-audit-logs -a claude-code. The skill lands in ~/.claude/skills/analyzing-kubernetes-audit-logs/SKILL.md.
What does analyzing-kubernetes-audit-logs do?
It parses kube-apiserver audit logs in JSON lines and looks for exec into pods, secret access, RBAC changes, privileged pods and anonymous API calls. The event patterns feed SIEM detection rules.
Does it cover detection inside a running container?
No. It works at the API server level; syscall-level detection inside a container is handled by the Falco skill.
Source text
SKILL.md · Apache-2.0
---
name: analyzing-kubernetes-audit-logs
description: >-
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.
'
domain: cybersecurity
subdomain: container-security
tags:
- kubernetes-security
- container-security
- audit-log-analysis
- rbac
- privilege-escalation
- k8s-api-server
- threat-detection
version: '1.0'
author: mahipal
license: Apache-2.0
nist_csf:
- PR.PS-01
- PR.IR-01
- ID.AM-08
- DE.CM-01
mitre_attack:
- T1610
- T1613
- T1078
- T1552.007
---
# 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.
```python
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:
1. pods/exec and pods/attach (shell into containers)
2. secrets access (get/list/watch)
3. clusterrolebindings creation (RBAC escalation)
4. Privileged pod creation
5. Anonymous or system:unauthenticated access
## Examples
```python
# Detect secret enumeration
if verb in ("get", "list") and resource == "secrets":
print(f"Secret access: {user} -> {event['objectRef'].get('name')}")
```
© mahipal · Apache-2.0 · mukul975/Anthropic-Cybersecurity-Skills