Skip to main content
skill CX Codex

dd-audit-key-compromise — Claude Code skill: Datadog key audit

Traces what a suspicious Datadog API key did: when, from where, which endpoints, what got deleted. Useful the moment a key may have leaked.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add datadog-labs/agent-skills --skill dd-audit-key-compromise -a claude-code
npx skills add datadog-labs/agent-skills --skill key-compromise -a claude-code
Open on GitHub

What dd-audit-key-compromise does

The skill rebuilds the story from Audit Trail. It lays out a timeline of the key's events, groups requests by country, ASN and IP, and lists which endpoints were hit and with which methods. A separate step hunts for deletions across monitors, dashboards and log pipelines. One more query answers when the key was created and by whom.

Inside are five steps built on pup audit-logs search with jq shaping the JSON, plus a table of anomaly signals: a country outside the usual baseline, an ASN belonging to a cloud or VPN provider, a burst of activity in a short window, off-hours access, requests from several IPs at once. Output follows a fixed report layout with active periods, top endpoints and the affected resources.

You need to authenticate first: pup auth login over OAuth2, or DD_API_KEY and DD_APP_KEY carrying the audit_logs_read scope. The skill wants the key ID, not the key value — grab it under Organization Settings > API Keys. Revoking through pup api-keys delete KEY_ID needs the manage_api_keys scope, so without it you revoke by hand in the UI.

What it helps with

  • figure out what a leaked Datadog key managed to do
  • pin down the IPs and countries behind the requests
  • check whether monitors or dashboards were deleted
  • find out who created the suspect key and when
  • put together an incident report

Example prompts for the agent

  • Trace what the Datadog key with ID abc123 did over the last 90 days
  • Build a timeline of this key's requests and show where they came from
  • Check for deletions made with this key and suggest next steps

How to install dd-audit-key-compromise

1Skills CLI (Vercel)

npx skills add datadog-labs/agent-skills --skill dd-audit-key-compromise -a claude-code
npx skills add datadog-labs/agent-skills --skill key-compromise -a claude-code

2Manually: put the files in place

~/.claude/skills/key-compromise/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/key-compromise/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about dd-audit-key-compromise

How do I install dd-audit-key-compromise in Claude Code?

Run npx skills add datadog-labs/agent-skills --skill dd-audit-key-compromise -a claude-code. The skill lands in ~/.claude/skills/key-compromise/SKILL.md.

What does dd-audit-key-compromise do?

It pulls Audit Trail data for one key: a timeline of actions, a geo and IP breakdown, the endpoints called, any deletions, and remediation steps.

What does the skill need to run?

Authentication via pup auth login, or DD_API_KEY and DD_APP_KEY with the audit_logs_read scope. You also need the ID of the suspect key from Organization Settings > API Keys.

Source text

SKILL.md · MIT
---
name: dd-audit-key-compromise
description: Investigate a potentially compromised Datadog API key — timeline of actions, geo/IP breakdown, endpoints called, anomaly flags, and remediation steps.
metadata:
  version: "0.1.0"
  author: datadog-labs
  repository: https://github.com/datadog-labs/agent-skills
  tags: datadog,audit,security,api-key,compromise,dd-audit
  alwaysApply: "false"
---

# Audit Trail: API Key Compromise Investigation

Reconstruct what a Datadog API key did, where requests originated, and which resources were affected.

## Prerequisites

```bash
pup auth login   # OAuth2 (recommended)
# or set DD_API_KEY + DD_APP_KEY with audit_logs_read scope
```

You need the **key ID** of the suspect key (not the key value). Find it in Datadog UI under Organization Settings > API Keys, or from context showing `@metadata.api_key.id`.

## Investigation Workflow

### Step 1 — Establish timeline

```bash
pup audit-logs search --query "@metadata.api_key.id:KEY_ID" --from 90d --limit 200 -o json \
  | jq '[.data[] | {
      timestamp: .attributes.timestamp,
      action: .attributes.attributes.action,
      event: .attributes.attributes.evt.name,
      resource_type: .attributes.attributes.asset.type,
      resource_id: .attributes.attributes.asset.id,
      endpoint: .attributes.attributes.http.url_details.path,
      method: .attributes.attributes.http.method,
      ip: .attributes.attributes.network.client.ip,
      city: .attributes.attributes.network.client.geoip.city.name,
      country: .attributes.attributes.network.client.geoip.country.name,
      asn: .attributes.attributes.network.client.geoip.as.name
    }]'
```

### Step 2 — Geo/IP breakdown

```bash
pup audit-logs search --query "@metadata.api_key.id:KEY_ID" --from 90d --limit 500 -o json \
  | jq '[.data[] | {
      country: .attributes.attributes.network.client.geoip.country.name,
      asn: .attributes.attributes.network.client.geoip.as.name,
      ip: .attributes.attributes.network.client.ip
    }]
    | group_by(.country)
    | map({
        country: .[0].country,
        count: length,
        asns: [.[].asn] | unique,
        ips: [.[].ip] | unique
      })
    | sort_by(-.count)'
```

### Step 3 — Endpoint breakdown

```bash
pup audit-logs search --query "@metadata.api_key.id:KEY_ID" --from 90d --limit 500 -o json \
  | jq '[.data[] | {
      method: .attributes.attributes.http.method,
      path: .attributes.attributes.http.url_details.path
    }]
    | group_by(.path)
    | map({path: .[0].path, methods: [.[].method] | unique, count: length})
    | sort_by(-.count)'
```

### Step 4 — Destructive action check

```bash
pup audit-logs search --query "@metadata.api_key.id:KEY_ID @action:deleted" --from 90d -o json \
  | jq '[.data[] | {
      timestamp: .attributes.timestamp,
      resource_type: .attributes.attributes.asset.type,
      resource_id: .attributes.attributes.asset.id,
      ip: .attributes.attributes.network.client.ip,
      country: .attributes.attributes.network.client.geoip.country.name
    }]'
```

### Step 5 — When was the key created and by whom?

```bash
pup audit-logs search --query "@asset.type:api_key @asset.id:KEY_ID @action:created" --from 90d -o json \
  | jq '[.data[] | {
      created_at: .attributes.timestamp,
      created_by: .attributes.attributes.usr.email,
      creator_ip: .attributes.attributes.network.client.ip,
      creator_country: .attributes.attributes.network.client.geoip.country.name
    }]'
```

## Anomaly Flags

| Signal | Why it matters |
|--------|----------------|
| Country not in org's normal baseline | Possible exfiltration from unexpected region |
| ASN is a cloud/VPN provider (AWS, Cloudflare, NordVPN, etc.) | Proxied traffic; obscured origin |
| DELETE actions on monitors, dashboards, or log pipelines | Potential sabotage |
| Burst of activity in short window | Automated scraping or bulk exfiltration |
| Activity outside business hours | Off-hours access |
| Key used from multiple IPs simultaneously | Key shared or stolen |

## Investigation Output Format

```
Key ID: <key_id>
Created: <timestamp> by <user_email>
Active period: <first_seen> to <last_seen>
Total events: <N>

Origins:
  - <Country> (<ASN>): <N> events — [NORMAL / FLAG: first-time origin]

Endpoints called (top 5):
  - <METHOD> <path>: <N> calls

Destructive actions: <N> deletions — [resource types affected]

Recommended actions:
  1. Revoke the key immediately if not already done
  2. Review affected resources: [list]
  3. Check if any deleted resources need restoration
  4. Audit who else had access to this key
```

## Remediation

Revoke in Datadog UI: Organization Settings > API Keys > Revoke.

Or via API (requires `manage_api_keys` scope):
```bash
pup api-keys delete KEY_ID
```

## References

- [Audit Trail API](https://docs.datadoghq.com/api/latest/audit/)
- [API Keys management](https://docs.datadoghq.com/account_management/api-app-keys/)

© datadog-labs · MIT · datadog-labs/agent-skills

Similar skills

All skills for Security →

From the same set28

agent-observability-session-classify Evaluates user intent satisfaction in Datadog Agent Observability traces and sessions. Returns a compact yes, partial, or no verdict with a brief reason. CX Codex +1 529installs agent-observability-experiment-analyzer Analyze one LLM experiment or compare two, with exploratory and question-driven modes. Choose it when you need to inspect results or assess a candidate against a baseline. CX Codex +1 529installs service-remapping A skill for building Datadog APM service remapping rules: collapse noisy inferred entities, clean up auto-generated names, handle renames. CX Codex +1 478installs dd-audit-compliance-report Pulls Datadog Audit Trail events into an auditor-ready report mapped to SOC 2 and PCI DSS controls. CX Codex +1 477installs dd-audit-security-investigation Investigates security events in Datadog Audit Trail via pup. Pinpoints who deleted resources, altered permissions, or authenticated from suspicious locations. CX Codex +1 476installs dd-audit-cost-spike-investigation Correlates a Datadog usage spike with Audit Trail config changes, so you can see who changed what right before the bill jumped. CX Codex +1 473installs upgrade-browser-sdk-v7 Walks a project through the Datadog Browser SDK jump from v6 to v7: stale options, CDN paths, changed APIs. Useful when the upgrade breaks init. CX Codex +1 459installs k9-ownership-byod-setup Builds a Datadog ownership preferences CSV and walks you through uploading it. Useful when the Ownership Agent guesses the wrong resource owners. CX Codex +1 454installs

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