osqueryHunting query: tune before alertingAI coding agents on endpoints
AI agent transcripts or credential stores held open by an unexpected process
AI coding tools keep plaintext transcripts (which often contain pasted secrets and command output) and tokens on disk: ~/.claude/projects and history.jsonl, ~/.codex/sessions and auth.json, ~/.gemini/tmp and oauth_creds.json, ~/.copilot/session-state and providers.json, Cursor's state.vscdb (where LayerX found readable API keys and session tokens). This osquery snapshot lists processes other than the owning tools that have these files open. Schedule it frequently: short reads between snapshots are missed.
- Log source
- osquery on macOS / Linux (process_open_files joined with processes)
- Techniques
- AML.T0083 Credentials from AI Agent Configuration · AML.T0085 Data from AI Services · LLM02 Sensitive Information Disclosure · AML.T0055 Unsecured Credentials
- MITRE ATT&CK
- T1552.001Credentials In FilesT1005Data from Local System
- Reviewed
- 2026-11-10
Query
SELECT p.pid, p.name, p.path AS process_path, p.cmdline, p.uid, pof.path AS opened_file
FROM process_open_files pof
JOIN processes p USING (pid)
WHERE (pof.path LIKE '%/.claude/projects/%' OR pof.path LIKE '%/.claude/history.jsonl'
OR pof.path LIKE '%/.claude/.credentials.json'
OR pof.path LIKE '%/.codex/sessions/%' OR pof.path LIKE '%/.codex/history.jsonl'
OR pof.path LIKE '%/.codex/auth.json'
OR pof.path LIKE '%/.gemini/tmp/%' OR pof.path LIKE '%/.gemini/oauth_creds.json'
OR pof.path LIKE '%/.copilot/session-state/%' OR pof.path LIKE '%/.copilot/providers.json'
OR pof.path LIKE '%/Cursor/User/globalStorage/state.vscdb%')
AND p.name NOT IN ('claude', 'node', 'codex', 'gemini', 'copilot', 'Cursor', 'Cursor Helper',
'Cursor Helper (Plugin)', 'Cursor Helper (Renderer)')
AND p.path NOT LIKE '%/.local/share/claude/versions/%'; Expected false positives
- Backup, sync and indexing agents (Time Machine, Spotlight, Dropbox, EDR scanners)
- Editors or viewers the user opened on a transcript on purpose
- Other IDE extensions in the same editor process (CursorJacking abuses exactly this, so review rather than dismiss)
Sources
- Claude Code docs: The .claude directory (application data)
- Codex docs: Advanced configuration (state locations)
- GitHub Docs: Copilot CLI configuration directory
- Akamai (LayerX research): CursorJacking — API key theft by rogue extensions
- BoostSecurity Bagel: AI CLI probe (credential and history paths)
- osquery table specs (process_open_files, processes, shell_history, file)
Reviewed against vendor documentation, not tested in your environment. Defensive use only.