Does Cursor read your .env files?

Yes. Cursor's default .env* exclusion only applies to indexing, so the Agent can open the file. A .cursorignore blocks Agent file reads, but its own docs say it can't block the Agent's terminal or MCP tools, so cat .env still works.

The default list that isn't what it looks like

Cursor's ignore files docs list .env* under "Files ignored by default". In a February 2026 forum thread, a Cursor staff member explained that this list "only applies to indexing" and doesn't affect Agent tool calls, and called the docs section misleading. The same thread traced the change to version 2.5, whose changelog says the global ignore list is now empty by default. The thread auto-closed in March without a fix posted, and the docs still say the global list is empty by default.

What .cursorignore covers

A .cursorignore file in your project, or the global ignore list in settings, keeps files away from Agent file reads, Tab, Inline Edit and @ mentions. The docs suggest adding **/.env and **/.env.* to the global list yourself. Do that today. Then know its limits:

  • The terminal. The docs say the terminal and MCP server tools used by Agent cannot block access. An agent that runs cat .env, grep or your test suite reads the file through the shell. We haven't tested Cursor, but in our test of 202 agent runs, Claude Code and Codex both opened the .env through the shell when nothing told them not to.
  • No guarantee. The same page says complete protection isn't guaranteed because of LLM unpredictability.
  • Open tabs. One user reported that the Agent read an ignored file that was open in an editor tab. Cursor hasn't confirmed it, but closing .env tabs costs nothing.

Approvals and the sandbox

Reading and searching files never asks for approval, per Cursor's security docs. For terminal commands, the run modes page says Auto-review became the recommended default in 3.6 (May 2026): a classifier decides which commands run without asking. Cursor says plainly that Auto-review "is not a security boundary", and the classifier itself can read your files to decide. The "ask every time" option was deprecated in 3.5.

Cursor's sandbox restricts the network, but its default network mode allows a built-in list of domains, including GitHub and package registries, plus any you add. It also allows reads and writes inside the workspace, so a sandboxed command can still read a .env in the project.

Privacy Mode doesn't change this

Privacy Mode means your code is never used for training. Cursor still sends prompts and code context to model providers like OpenAI, Anthropic and Google, through its own backend, under zero data retention agreements, with exceptions for your own API keys and for some models that require retention. If the Agent reads your .env, its contents go to the model like any other file.

What actually keeps keys away from Cursor

  1. Add the global ignore patterns **/.env and **/.env.*. It blocks one common path, Agent file reads.
  2. Don't keep keys in the project. A file that isn't there can't be read by the Agent, the terminal or an MCP tool. Keep keys in the Keychain, a password manager or a secrets manager, and inject them when a command runs, through a tool that masks them in the command's output, since a program can still print a key the Agent then reads.
  3. Use test keys and the narrowest permissions available to limit what a key that reaches the model can do.
  4. Watch MCP configs. Cursor's mcp.json often holds tokens in plain text. See where MCP server API keys should live.