AI Coding Agent Credential Store (Claude Code, Codex CLI)

Detects the OAuth token stores that AI coding agents keep on a developer's machine: Claude Code's .credentials.json (a claudeAiOauth object holding accessToken and refreshToken) and the OpenAI Codex CLI's auth.json (a tokens object holding id_token, access_token and refresh_token beside an OPENAI_API_KEY key). These files are plaintext, and the tokens in them act as the signed-in user: they spend the account's subscription and reach whatever the agent is connected to. Infostealers and npm supply-chain worms in 2026 collected both files. The pattern detects the file content, not a path, so it also fires when the JSON is pasted into a ticket, chat or repository.

Type
regex
Engine
boost_regex
Confidence
medium
Confidence justification
Medium confidence. The key names come from first-party source code (Anthropic's Claude Agent SDK for claudeAiOauth, accessToken and refreshToken; the open-source Codex CLI for auth.json), and the container keys are specific to these tools. The token values are opaque strings with no documented prefix, length or checksum, so the regex cannot validate them or tell an expired token from a live one, and the field names alone are common in other OAuth clients. Enforce tiers therefore require the tool-specific container or sibling keys.
Jurisdictions
global
Regulations
Criminal Code Act 1995 (Cth), Computer Fraud and Abuse Act, Computer Misuse Act 1990
Frameworks
CIS Controls, ISO 27001, NIST CSF, SOC 2
Data categories
credentials, security
Scope
narrow
Risk rating
8
Platform compatibility
Purview: Compatible, GCP DLP: Unsupported, Macie: Unsupported, Zscaler: Compatible, CrowdStrike DLP: Unsupported, Palo Alto: Unsupported, Netskope: Unsupported

Pattern

(?i)("(?:accessToken|refreshToken)"\s*:\s*"(?![<$]|[^"]{0,40}(?:your|xxxx|\*{3}|redacted|placeholder|changeme))[^"\s]{20,}")

Corroborative evidence keywords

claudeAiOauth, .credentials.json, auth.json, OPENAI_API_KEY, last_refresh, Claude Code, Codex

Proximity: 300 characters

Should match

Should not match

Known false positives

References