threatdeck
Live 13:45 UTC ·

Learn / Securing AI coding assistants in an organisation

Lesson 1 of 69 minReviewed

What a coding agent can reach on a developer machine

Inventory the data, credentials and capabilities a coding agent inherits from the developer's account, including the plaintext transcripts it writes itself.

A coding agent such as Claude Code, Codex CLI, Gemini CLI or Cursor's agent is an ordinary process running under the developer's user account. The MCP project's guidance for local servers states the general rule: a process launched this way inherits your environment variables, can read anything your account can read and can open outbound connections anywhere, and none of that is governed by the protocol [1]. The agent and every command it runs sit in the same position.

What a coding agent can reach on a developer machine A coding agent runs as a process of the developer's user account. From there it reaches the repository and its .env files, credentials on disk such as ~/.ssh and ~/.aws, environment variables, its own plaintext transcripts under ~/.claude/projects, local MCP servers it launches, and the shell and network. Permission rules govern the agent's own tools; only an OS sandbox or container limits what child processes can read. Developer's user account: everything here is readable by default Coding agent CLI, IDE agent or extension Repository source · .env · rules files Credentials ~/.ssh · ~/.aws · tokens in env Transcripts plaintext JSONL, 30 days default Shell any command the user can run Local MCP servers child processes, same privileges Network fetch, push, exfiltrate Permission rules cover the agent's tools; a sandbox or container covers its child processes
The agent inherits the account's reach. Rules decide what it asks before doing; containment decides what it can touch.

Four things in reach

Default reach of a coding agent
AssetWhere it livesWhat the docs say
Source and project secretsWorking directory, .env, config filesClaude Code reads files in the working directory without asking [2]; Cursor's agent reads and searches files without approval [3]
Credentials~/.ssh, ~/.aws/credentials, tokens exported in shell profilesEven with Claude Code's sandbox on, reads are allowed across the machine by default, so these stay readable unless you deny them [4]
Transcripts and history~/.claude/projects/<project>/<session>.jsonl, ~/.claude/history.jsonlPlaintext; transcripts deleted after 30 days by default, history kept until you delete it [5]
Shell and networkThe Bash or terminal toolRuns anything the user can, subject to the tool's approval rules [2]

Transcripts are a data store nobody planned

Claude Code writes each session to a JSONL transcript: messages, tool calls and tool results, plus the system prompt, tool definitions and loaded instruction files. Anything that passes through a tool lands there, so if the agent reads a .env file or a command prints a token, the value is now on disk in plaintext with only file permissions protecting it [5]. Anthropic's data-usage page describes the same local cache: transcripts kept under ~/.claude/projects/ for 30 days by default to allow session resumption [6].

The documented ways to reduce exposure are [5]:

  • Lower cleanupPeriodDays (default 30, minimum 1) to shorten transcript retention.
  • Set CLAUDE_CODE_SKIP_PROMPT_HISTORY to stop writing transcripts and prompt history, or pass --no-session-persistence with -p in automation.
  • Deny reads of credential files with permission rules, so secrets are less likely to enter a transcript at all.
  • Run claude purge to delete a project's transcripts, memory and history entries after sensitive work.

Treat these directories as a credential store: exclude them from unmanaged backup and sync tools, and alert when a process other than the agent opens them.

Approval is not containment

Permission rules control the agent's own tools. Claude Code documents the edge precisely: Read and Edit deny rules cover its built-in file tools, file commands it recognises in Bash such as cat and head, and redirection targets, but not a command that reads files without naming them or a Python or Node script that opens files itself. For enforcement that applies to every process, the docs point to the OS sandbox [2]. Cursor says the same about its command allowlists: they are best-effort guardrails rather than a hard security boundary [3].

The next lesson looks at the approval and sandbox controls each tool offers and the ways they have failed.

Try it on ThreatDeck

Self-check

4 questions

Pick an answer to see whether it is right and why. Only your score is saved, in this browser.

  1. A Claude Code session read a .env file while debugging. Where is that value most likely to persist afterwards?
  2. You set a deny rule Read(./.env). Which action can still read the file?
  3. With Claude Code's Bash sandbox enabled and no extra configuration, what is true of ~/.aws/credentials?
  4. Which pair of changes most directly reduces secrets lingering in Claude Code transcripts?

References

  1. MCP Local Server Security. Model Context Protocol, 2026-07-28.
  2. Configure permissions. Anthropic (Claude Code docs).
  3. Agent Security. Cursor docs.
  4. Sandboxing. Anthropic (Claude Code docs).
  5. Explore the .claude directory: application data. Anthropic (Claude Code docs).
  6. Data usage. Anthropic (Claude Code docs).
Completing the self-check also marks the lesson complete. Saved in this browser only.

Following

Follow the vendors, products, AI tools, techniques and actors you care about. Matching stories, CVEs and exploited bugs are marked, a Following tab appears in the feed, and returning visits show what changed. Saved only in this browser.

Presets

Get updates

A personal RSS feed of new stories on everything you follow. Paste it into any feed reader, Slack or Teams RSS app.