dd-audit-key-compromise について
Audit Trail のデータから、侵害が疑われる Datadog API キーの活動を再構成する調査スキルです。イベントを時刻、接続元、エンドポイント、破壊的操作別に整理し、異常の兆候と対処方法を示します。
主な機能
- 01API キーの活動タイムライン
- 02GeoIP・ASN・IP の分析
- 03エンドポイントと HTTP メソッドの集計
- 04破壊的操作の確認
- 05異常の兆候とキー失効の案内
活用シーン
- 01API キー侵害の疑いを調査
- 02不審なリクエスト元を特定
- 03影響を受けたリソースや削除項目を確認
- 04キーの作成日時と作成者を特定
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ datadog-labs/ agent-skills --skill dd-audit-key-compromiseインストール後、Claude Code で/dd-audit-key-compromiseを入力して読み込まれたか確認します。
詳細
監査証跡:API キー侵害の調査
Datadog API キーで実行された操作、リクエストの発信元、影響を受けたリソースを再構成します。
前提条件
pup auth login # OAuth2 (recommended)
# or set DD_API_KEY + DD_APP_KEY with audit_logs_read scope
疑わしいキーのキー IDが必要です(キーの値ではありません)。Datadog の UI の Organization Settings > API Keys で確認するか、@metadata.api_key.id が表示されているコンテキストから確認してください。
調査ワークフロー
ステップ 1 — タイムラインを確認する
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
}]'
ステップ 2 — 地域/IP の内訳
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)'
ステップ 3 — エンドポイントの内訳
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)'
ステップ 4 — 破壊的な操作を確認する
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
}]'
ステップ 5 — キーが作成された日時と作成者を確認する
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
}]'
異常を示すフラグ
| シグナル | 重要な理由 |
|---|---|
| 組織で通常確認される基準にない国 | 予期しない地域から情報が持ち出された可能性があります |
| ASN がクラウド/VPN プロバイダー(AWS、Cloudflare、NordVPN など) | トラフィックがプロキシ経由で、発信元が隠されている可能性があります |
| モニター、ダッシュボード、ログパイプラインに対する DELETE アクション | 妨害行為の可能性があります |
| 短時間に集中したアクティビティ | 自動化されたスクレイピング、または大量の情報持ち出しの可能性があります |
| 営業時間外のアクティビティ | 時間外のアクセスです |
| 複数の IP から同時にキーが使用されている | キーが共有または窃取された可能性があります |
調査結果の出力形式
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
修復
Datadog の UI で取り消します:Organization Settings > API Keys > Revoke。
または API を使用します(manage_api_keys スコープが必要です):
pup api-keys delete KEY_ID
参考資料
コメント
Markdown 対応