Skip to content
Skillpedia
Misc35k · #5455

analyzing-kubernetes-audit-logs

Lets your agent read activity logs in Kubernetes systems. It detects dangerous actions and helps create rules to find attacks.

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.

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.”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/analyzing-kubernetes-audit-logs/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/analyzing-kubernetes-audit-logs/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
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.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill analyzing-kubernetes-audit-logs

Or download just the file:

curl -L https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/main/skills/analyzing-kubernetes-audit-logs/SKILL.md -o SKILL.md
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:

  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

# 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

repo: mukul975/Anthropic-Cybersecurity-Skills

Popularity

GitHub stars
35k
Ranking position
#5455
License
Apache-2.0
Updated
8/31/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills