Skip to main content
skill CX Codex

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.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-kubernetes-audit-logs -a claude-code
Open on GitHub

What 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 clusterrolebindings created 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.log and list every pods/exec event with its username
  • Find secrets access in the audit log and group it by user
  • Draft a SIEM detection rule for clusterrolebindings and 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-code

2Manually: put the files in place

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

Copy the whole skill folder; for one project use .claude/skills/analyzing-kubernetes-audit-logs/

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

Similar skills

All skills for Security →

From the same set90

testing-cors-misconfiguration Audits API endpoints for Cross-Origin Resource Sharing vulnerabilities during authorized penetration tests. It identifies weak Origin reflection and misconfigured credentials. CX Codex +1 463installs analyzing-linux-system-artifacts Walks an agent through Linux system artifacts after a breach: auth logs, cron and systemd persistence, shell history, SSH keys. Built for incident response. CX Codex +1 461installs analyzing-linux-elf-malware A skill that walks an agent through dissecting suspicious Linux ELF binaries: headers, strings, syscalls, Ghidra. Useful when a server or container looks compromised. CX Codex +1 457installs analyzing-disk-image-with-autopsy Guides forensic investigation of raw, E01, and AFF disk images using Autopsy and The Sleuth Kit. Helps extract metadata, recover deleted files, and build activity timelines. CX Codex +1 454installs analyzing-sbom-for-supply-chain-vulnerabilities Parses CycloneDX and SPDX SBOM files, matches components against the NVD CVE database through the NVD 2.0 API and builds a dependency graph. Useful when you need to size up third-party library risk. CX Codex +1 444installs abusing-dpapi-for-credential-access Guides extraction and decryption of Windows DPAPI secrets, including Credential Manager entries and browser data. Useful during authorized penetration tests after gaining host access. CX Codex +1 442installs analyzing-linux-kernel-rootkits This skill looks for kernel-level rootkits in Linux memory dumps and live systems. Use it during incident investigations and digital forensics. CX Codex +1 442installs analyzing-golang-malware-with-ghidra Walks an agent through Go binary analysis in Ghidra: buildinfo, pclntab, function names, dependencies. Useful when the sample is Go-compiled. CX Codex +1 441installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor