# Secrets and API keys in Cline: keep credentials out of the agent's reach

Source: https://botpassword.com/agents/cline
Last checked: 2026-10-25

Cline is an open-source coding agent that runs as a VS Code extension and a CLI. It supports MCP over stdio, streamable HTTP and legacy SSE, configured in `cline_mcp_settings.json`. It reads `.clinerules` and `AGENTS.md`, and its `.clineignore` file is documented as a context filter, not an access-control boundary.

## MCP support

Yes. Transports: stdio, http, sse.

- global: `~/.cline/data/settings/cline_mcp_settings.json (CLI; override with CLINE_MCP_SETTINGS_PATH)`
- user: `cline_mcp_settings.json opened from the extension's MCP Servers > Configure tab (VS Code extension)`

## Environment variables and .env files

The `env` object of a stdio server passes variables such as API keys to that server. The documentation recommends storing secrets in environment variables but does not describe a substitution syntax for referencing them inside the settings file, and the pages reviewed do not describe `.env` loading.

## File access

Cline reads and edits files in the workspace after you approve actions, and runs shell commands. `.clineignore` (gitignore-style, project root) filters the initial file listing, automatic context gathering and search results, but explicit `@` mentions and shell commands can still read ignored files. Cline's docs say it "will be deprecated soon" and offer a `PreToolUse` hook script that blocks reads, edits and commands targeting matching paths. Hooks are disabled in CLI `--yolo` mode.

Deny or ignore files with: .clineignore (context filter) or a PreToolUse hook (enforced).

## Credential risks

- **Prompt-injection exfiltration through DNS.** Mindgard reported that instructions hidden in a source file could make Cline read environment variables, including API keys, and send them out through a `ping` command that needs no approval. Disclosed to the vendor on 27 August 2025 and published 18 November 2025.
- **`.clinerules` code execution.** The same Mindgard audit describes malicious Markdown placed in a project's `.clinerules` directory leading to code execution when the repository is opened and Cline is asked to analyse it.
- **`.clineignore` is not a security boundary.** Cline's documentation states that `@` mentions and shell commands can still read ignored files; only the hook-based approach is enforced.

## FAQ

### Where is Cline's MCP settings file?

In the CLI it is `~/.cline/data/settings/cline_mcp_settings.json`. In the VS Code extension, open the MCP Servers icon, go to Configure and choose "Configure MCP Servers" to open it.

### How do I stop Cline reading my .env file?

`.clineignore` only keeps files out of automatic context. For enforcement, Cline documents a `PreToolUse` hook that blocks reads, edits and commands targeting ignored paths.

### Does Cline read AGENTS.md?

Yes. Cline reads `AGENTS.md` from the project and `~/.agents/AGENTS.md` globally, along with `.clinerules`, `.cursorrules` and `.windsurfrules`.

### How do I give Cline an API key without it seeing the key?

Don't put the key in the prompt, in a file Cline can read, or in an environment variable it can print. Give it a tool that performs the authenticated step instead: a credential broker exposed over MCP or a CLI that injects the key into the command or HTTP request and returns only the result. BotPassword is that broker, through `bpw mcp` and the `bpw` CLI.

## Sources

- https://docs.cline.bot/mcp/configuring-mcp-servers
- https://docs.cline.bot/customization/clineignore
- https://docs.cline.bot/customization/cline-rules
- https://mindgard.ai/disclosures/cline-bot-ai-coding-agent-data-exfiltration-via-prompt-injection-and-dns
- https://mindgard.ai/disclosures/cline-bot-ai-coding-agent-code-execution-via-prompt-injection-and-toctou-script-invocation
