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.
Four things in reach
| Asset | Where it lives | What the docs say |
|---|---|---|
| Source and project secrets | Working directory, .env, config files | Claude 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 profiles | Even 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.jsonl | Plaintext; transcripts deleted after 30 days by default, history kept until you delete it [5] |
| Shell and network | The Bash or terminal tool | Runs 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_HISTORYto stop writing transcripts and prompt history, or pass--no-session-persistencewith-pin automation. - Deny reads of credential files with permission rules, so secrets are less likely to enter a transcript at all.
- Run
claude purgeto 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
- threatdeck scan Run the local scanner to list AI coding tools, MCP servers and literal secrets in their configs on your machine.
- Detection: transcripts opened by another process Hunt for unexpected processes reading agent transcripts or credential stores.
- Claude Code data-exposure sheet See where the tool stores data locally, its current advisories and minimum safe version.
Self-check
4 questionsPick an answer to see whether it is right and why. Only your score is saved, in this browser.
-
Claude Code writes tool results to a local plaintext transcript and deletes transcripts after
cleanupPeriodDays, which defaults to 30. File permissions are the only protection, so secrets a tool read are on disk until the sweep or a purge removes them. -
Read deny rules cover the built-in tools, recognised file commands like
catand redirection targets. Arbitrary subprocesses that open files themselves are outside them; only an OS-level sandbox stops every process. -
The sandbox restricts writes and network by default, but reads stay broad. You must add deny-read entries or credential protection for directories such as
~/.sshand~/.aws. -
Shorter retention limits how long transcripts exist, and deny rules keep credential files from being read into a transcript in the first place. Allow rules and model choice do not affect what is stored.
References
- MCP Local Server Security. Model Context Protocol, 2026-07-28.
- Configure permissions. Anthropic (Claude Code docs).
- Agent Security. Cursor docs.
- Sandboxing. Anthropic (Claude Code docs).
- Explore the .claude directory: application data. Anthropic (Claude Code docs).
- Data usage. Anthropic (Claude Code docs).