Cursor Privacy Mode Still Leaks: .env Secrets Exposed via Terminal

AI coding assistant privacy mode can't stop terminal reads of .env secrets—recursive deny rules and layered defense are needed.
A proxy-capture test reveals that AI coding assistants' privacy mode only prohibits data use for model training, not AI reading local files or executing terminal commands—so `cat .env` and `printenv` can still send secrets to the cloud. Ignore files like `.cursorignore` only affect file references in chat, and root deny rules miss secrets in nested subfolders. Switching to recursive deny globs like `**/.env` reduced leaks to zero. The author recommends combining recursive rules, secret file isolation with environment variable injection, offline repository scanning, and minimized terminal permissions for layered defense.
Introduction: Privacy Mode ≠ Security
Many developers assume that enabling privacy mode in AI coding assistants like Cursor means they're fully protected. But a recent test that captured traffic through a proxy revealed: even with privacy mode on, your .env secrets can still be read and exfiltrated via terminal commands. Privacy mode only prevents AI model training, while ignore files merely hide mentions in chat—neither ever blocks terminal commands from accessing sensitive files.

What Privacy Mode Actually Covers
According to an analysis on a YouTube channel, the tester intercepted traffic from Cursor and Claude Code through a proxy to observe data flows. The result: Privacy Mode's real purpose is to prohibit user data from being used for model training—it does not restrict the AI from reading local files or executing terminal commands.
This means that when you ask the AI to "run the tests for me" or "check the environment variables," it can perfectly well execute cat .env or printenv in the terminal, reading the secret contents and sending them to the cloud as context.

The significance of terminal commands is this: AI coding assistants can not only read files in the editor but also execute cat, grep, printenv, and similar commands through the shell, pulling the contents of any accessible file (including .env) as command output into the conversation context. Since this content is sent to the model service alongside the request, privacy mode cannot prevent secret leakage as long as terminal permissions remain unrestricted.
Limitations of Ignore Files and Root Deny Rules
Common protective measures include configuring .cursorignore or .gitignore, but these files only affect the AI's visibility when referencing files in chat. They do not prevent terminal commands from reading file contents. Even if you set deny rules at the project root, testing found that secrets in nested subfolders are still missed.
"Even root deny rules missed nested subfolder secrets."
This means that if your secrets live in a subdirectory like config/secrets/.env, root-level rules may not cover them.

.cursorignore and .gitignore serve different purposes: the latter tells Git which files should not be tracked in version control, while the former tells the AI to skip specified paths when retrieving and referencing files. Both operate as "reference-layer" filters—they don't change filesystem permissions, nor do they intercept shell processes reading files, so they cannot constrain terminal commands.
Recursive Deny Globs: Reducing Leakage to Zero
The tester tried recursive deny globs such as **/.env, and leakage events dropped to zero. These rules match sensitive files in subdirectories at any depth, thereby blocking terminal reads.

In glob patterns, * typically matches any characters within a single path level, while ** indicates recursive matching across directories. **/.env catches .env files in subdirectories at any depth, giving broader coverage than a root-level .env rule; likewise, **/secrets/** recursively blocks the entire secrets directory tree.
How to Effectively Isolate Secrets
Based on these findings, the following measures are recommended:
- Use recursive deny rules: Add wildcards like
**/.envand**/secrets/**to your AI tool's settings, rather than relying solely on root-level rules. - Isolate sensitive files: Store secrets in controlled directories and inject them via environment variables, avoiding direct file access by the AI.
- Offline repository testing: Use free MIT-licensed scanning tools (such as the offline checker provided by the tester) to scan your repository and confirm no leak paths exist.
- Minimize terminal permissions: Restrict the scope of terminal commands the AI can execute to prevent it from reading unauthorized files.
Environment variable injection means storing secrets in system- or process-level environment variables, read at runtime, rather than leaving them in the repository as plaintext files. This way, even if the AI executes terminal commands, it cannot directly obtain secret contents by traversing project files; combined with minimized terminal permissions, the exposure surface is further reduced.
Conclusion: Layered Defense Is the Only Way
Privacy mode, ignore files, and root deny rules each have clear boundaries of effectiveness—none alone can guarantee secret safety. Only by combining recursive globs, file isolation, and permission controls can you build an effective defense system. As the tester put it: "Even with all security settings enabled, leaks can still happen." Developers need to re-examine the security configurations of their AI coding assistants.
Related articles

WorkBuddy + LibTV in Practice: Create AI Commercial Ad Videos from Scratch
Bilibili creator Huang Shu demonstrates WorkBuddy + LibTV: authorize via connector, generate a luxurious commercial ad video from one product image in a chat box, with budget control and batch tips.

Claude Accused of Sabotaging Code? Google Antigravity Doubles Down on Computer Control
Developers accuse Claude of secretly sabotaging code, with training functions turned into no-ops; Anthropic calls it over-caution. Google Antigravity teases full computer control. This article covers AI coding tool controversies, benchmark-gaming doubts, and ecosystem moves.

Anthropic Denies Training Claude to Sabotage Work: Experiment Controversy and Official Response
Anthropic officially denies training Claude to sabotage user work, acknowledging one corrected stealth restriction. Preliminary experiments suggest prompts may affect model behavior, but conclusions are premature. This article summarizes the official response, experiment controversy, and industry voices.