zn-gate for Cursor
Install zn's hooks for Cursor: they block reads of .env files with values and credential files, secrets pasted into prompts and MCP calls that carry a secret.
You need Node.js 18 or later. Paste each line in a terminal and press Enter after each one:
On Windows PowerShell, type npm.cmd, zn.cmd and npx.cmd instead of npm, zn and npx in every command on this page (PowerShell blocks the .ps1 versions by default, with "running scripts is disabled on this system"). More in Troubleshooting.
npm install -g zn-gate
zn hooks install cursor
There is no zn-gate plugin for Cursor since version 1.14.0: use zn hooks install cursor. The plugin's hooks started node by name, so a folder of your project on Cursor's PATH (such as node_modules/.bin) could run a program of the project in place of the real Node.js. If you added the zn-gate plugin in Cursor, remove it there (Customize).
On macOS and Linux, if npm install -g fails with EACCES, follow npm's guide to fixing permission errors.
Fix it without administrator rights:
mkdir -p ~/.npm-global && npm config set prefix ~/.npm-global
echo 'export PATH="$HOME/.npm-global/bin:$PATH"' >> ~/.zshrc
Bash users: write to ~/.bashrc instead of ~/.zshrc.
Then open a new terminal and run npx -y zn-gate init. A Node.js version manager such as nvm also avoids the problem.
Then restart Cursor.
What you get
- File reads and shell reads of
.envfiles with values and credential files are blocked. - A secret pasted into a prompt is blocked.
- MCP calls that carry a secret value are blocked.
Limits
- Shell output and file contents are not scrubbed; only MCP output is.
- Write protection is best effort.
- If the zn hook crashes, reads and prompts are blocked; other events run unchecked.
- Not tested on Windows.
To also check the MCP servers you use in Cursor, see Cursor.
Keep your .env values in the vault
The agent cannot read .env files with real values. Move the values into zn-gate's encrypted vault, and the file keeps markers such as __ZN_STRIPE_KEY__:
zn unlock # creates the vault the first time
zn env shadow .env
After this your own app also reads the markers: start it with zn-gate's run command once you allow it. env shadow tells you how to undo it. More: the vault.
Check that it works
In a new terminal, run zn-gate check. It should show OK for Cursor. What the output means.
Further reading
- Protect Claude Code, Codex CLI, Cursor or OpenCode with one command: what the one-command setup changes in each agent, how to check it and how to remove it.