Data Report · RedactSure Research
Chris Sowa · Founder, RedactSure
Published
Last updated
Is Cursor Safe to Use With Production Credentials?
No, not with the production keys most projects keep in a .env file: Cursor's documented controls gate the commands it runs and the files it may read, not what the model holds. Check which values the model receives, who approves the action that uses them, and what record the run leaves.

The deploy script fails, and the developer asks the coding agent to fix it; the script needs the AWS access key that sits in the project's .env file. The agent reads the file, runs the failing command, and from that point the key travels with the task: into the context, into the transcript and into whatever the model writes next. Cursor documents approvals for terminal commands and MCP connections, file exclusions through .cursorignore and a tool list limited to GitHub, link retrieval and web search, and each of those governs what the agent may do or where it may look (Cursor, Security, 2026). None of them decides whether a value the agent has already read stays out of the model's context.
The stakes are concrete for a team that keeps production keys in a working copy. A key that reaches a model can be repeated in a commit message, a screenshot, a support ticket or an outbound request, and the approval that covered the command covers none of those. The record is one repository whose .env holds an AWS access key pair and a deploy script that fails on a region it cannot find, and the question is what the model holds once a key is read. The same test applies to a coding agent that reads the tree: name the value, find the layer that could hold it, and ask what the model was shown before it acted.
Key findings
- For Cursor to be safe with a production key, the value would have to be replaced with a consistent token before the agent reads the file or the command output, with the real key released only at the destination a named person approved (Does Cursor's Privacy Mode Keep API Keys Out of the Model?).
- It would also require a named person approving each command that can use the key and a record that attributes the action to that person, which is what AWS's guidance asks of an audit log (AWS, 2026).
- Cursor's documentation does not state that values are substituted before the model receives them; its pages describe prompts on terminal commands and MCP connections, file exclusions, and run modes it calls "best-effort guardrails rather than a hard security boundary" (Cursor, Security, 2026).
- Cursor's ignore-files page says .cursorignore blocks "Code accessible by Agent, Tab, and Inline Edit," and that the terminal and MCP server tools "cannot block access to code governed by .cursorignore," which leaves the command line open on a file the rule covers (Cursor, Ignore, 2026).
- NVIDIA's sandbox documentation shows the custody design Cursor's pages do not describe: "The agent receives an opaque placeholder, not the real API key or access token," which keeps the key out of the agent's process and says nothing about a page a browser renders (NVIDIA, 2026).
What does a Cursor agent read when the project holds production credentials?
The record for this page is a repository whose .env file holds an AWS access key pair, and a deploy script that fails on a region it cannot find. The key reaches the task through two surfaces, and they answer to different controls.
The file tree is the first. Cursor says files in .gitignore and a default ignore list that includes .env are "automatically ignored," and it names .cursorignore as the file that blocks "Code accessible by Agent, Tab, and Inline Edit" (Cursor, Ignore, 2026). The page does not say which features that exclusion covers, so a project that keeps .env in the default list is relying on a property the vendor does not state (Does Cursor Read My .env File?). An entry in .cursorignore governs the agent's own reads, and a pattern such as .env. covers the variants a project accumulates.
The command line is the second surface, and a failing deploy script lives there. Cursor states that "the terminal and MCP server tools used by Agent cannot block access to code governed by .cursorignore," so the rule that covers the file does not cover a command that prints it (Cursor, Ignore, 2026). The same page adds that "complete protection isn't guaranteed due to LLM unpredictability."
This is where the control classes divide. A governed environment covers the page an agent renders, a dashboard, a console, a settings page or a sign-up form, and its substitution happens before any model reads that page. It does not cover the terminal, the IDE, the local filesystem, direct API calls or MCP. For this record, the render layer has nothing to substitute while the key sits in .env and a shell command prints it; the controls that matter there are the scope of the credential and the approval on the command.
Cursor's own controls act on the prompt and on the tool surface, deciding which files the model is offered and which commands may run. That is the layer where a production key in .env is exposed, and it is a different layer from the rendered page.
What does Cursor's approval prompt actually cover?
Cursor's agent security page says "By default, terminal commands need your approval" and "All MCP connections need your approval," so the prompt appears at the two routes the agent uses outside its own file reads (Cursor, Security, 2026).
The prompt governs one action at the moment it is proposed. It covers the command rather than the values the command inherits, so an approved command that prints the environment prints every value in it. It arrives after the model has read the script, the error output and the file tree, so a key that entered the context earlier stays there whatever the person answers.
Injection is why the order of events matters. OWASP's prompt injection entry explains that "Indirect prompt injections occur when an LLM accepts input from external sources, such as websites or files," and Greshake and colleagues showed the class can "enable adversaries to remotely (without a direct interface) exploit LLM-integrated applications" and "act as arbitrary code execution" (OWASP, 2025; Greshake et al., 2023). A dependency's error message is one such input, and a deploy task reads several in a row.
Keeping a person at each consequential command is the position Mitchell and colleagues argue for when they write that "fully autonomous AI agents should not be developed" (Mitchell et al., 2025). An approval is still a decision about an action, made by a person who can read the command before it runs.
The authority behind that decision is the person's, because a tether describes what the agent may reach and not what it holds (What Is a Tethered Agent?), and least privilege governs the actions and credentials an agent may use without governing the content of the page or file it reads (What Is Least Exposure?).
What do the vendors themselves say?
Cursor documents two prompts, one exclusion and a set of run modes, and its pages say where each applies (Cursor, Security, 2026).
| Dimension | Cursor, per its documentation | What a buyer should verify |
|---|---|---|
| Terminal commands | "By default, terminal commands need your approval" | Whether a run mode can clear them without a person |
| MCP connections | "All MCP connections need your approval" | Which tool servers are allowed, and who approves a new one |
| Run modes | "best-effort guardrails rather than a hard security boundary" | What the mode does when the model is wrong |
| Agent file access | .cursorignore blocks "Code accessible by Agent, Tab, and Inline Edit" | Which paths the project lists, and whether .env* is one |
| Default exclusions | .gitignore entries and a list including .env* are "automatically ignored" | Which features that exclusion covers |
| Terminal reach | The terminal and MCP tools "cannot block access to code governed by .cursorignore" | Whether a command can print a file the rule covers |
| Credential custody | Not described in the pages reviewed | What the model holds once a value is read |
The table separates what Cursor documents from what it leaves to the buyer. Each row is a statement about a gate or a rule, and each leaves the same question open: what the model received before the gate was reached. A file rule answers where the agent may look, and a prompt answers whether one command runs.
NVIDIA's sandbox documentation describes a design at the point of use: "The agent receives an opaque placeholder, not the real API key or access token," which keeps the value out of the agent's process and leaves open what a rendered page shows a model (NVIDIA, 2026). The sentence covers a credential handed to a process, and it applies at the point where a value is used.
AWS's guidance aims at the record: "audit logs attribute every action unambiguously to either an agent or a human actor," which is the property a reviewer needs when a person and an agent share one login (AWS, 2026). Attribution separates the two actors in a log, and it does not capture what either of them read before acting.
Cursor's ignore-files page carries its own limit: "while Cursor blocks ignored files, complete protection isn't guaranteed due to LLM unpredictability," which places the failure on the model's behavior, the part a file rule cannot govern (Cursor, Ignore, 2026).
Set side by side, the three vendors describe three different objects: an action, a process and a log. None of them describes what a rendered page shows the model.
What record does a Cursor run leave of what the agent read?
Cursor's pages describe approvals and exclusions and no session record of the model's input (Does Cursor Keep an Audit Log of What the Agent Did?). A team that wants to know what a run read has to build that record somewhere else, and the logs usually offered answer a different question.
GitHub's security log "lists all actions performed within the last 90 days" (GitHub, 2026). That is a record of what was done with an account: a token used, a repository changed, a workflow triggered. It cannot say which fields of a settings page were in the model's context when it chose the action, and it cannot separate a value the model read from a value it guessed.
Attribution answers who acted, and the context question is what the model held. The second needs a record written before the model acted, at the point the page was assembled, which is not where an account's own log is written.
That is the object a reviewer needs when a production key is exposed: the page the model was given, beside the approval and the name of the person who gave it, rather than a list of actions. A run that leaves the first and not the second can pass a log review and still have exposed the key.
The gap has a practical shape for this record. A repository, a deploy script and a key in .env produce a transcript, a command history and an account log, and only the transcript carries the values the model saw. A team can read it today and treat it as the only evidence it has.
What should a security team ask for in writing?
Three answers decide the question for a production key, and each can be requested in writing before a run. The first is coverage: which values does the model receive from a rendered screen, a console page that displays an access key or a settings page that shows a connection string. The second is approval: who is named for the command that can spend the key. The third is the record: what shows what the model held when it acted.
| Ask | What the answer decides | What Cursor documents |
|---|---|---|
| Which values does the model receive from a rendered screen? | Whether a console page hands the key to the model | No substitution or filter on a screen is described |
| Who approves a command that can use the key? | Whether a person sees the action before it runs | A prompt is on by default, and run modes change how often it appears |
| What record shows what the model read? | Whether the exposure can be reviewed afterward | No session or context record is described |
The operational answers are cheaper, and a team can apply them this week. Keep the key out of the working copy, because AWS recommends "relying on temporary credentials instead of creating long-term credentials such as access keys" (How Do I Let a Coding Agent Use AWS Without Giving It My Access Keys?). Give the credential a lifetime, which is what the OAuth best current practice requires when it states that "Refresh tokens for public clients MUST be sender-constrained or use refresh token rotation" (IETF, 2025).
Two habits cover the rest. List .env* in .cursorignore rather than trusting the default list, and keep auto-run modes off for a repository with production access. Test the terminal route with a dummy value before a real one: ask the agent to print the environment in a scratch repository, then read the transcript for values the task did not need. A team that runs that once knows more about this question than the documentation states.
What does a governed environment change?
A governed environment acts where a screen is rendered, before any model reads it. Values chosen by policy are replaced with consistent tokens for the whole run, so an agent working a deployment settings page sees AWS_KEY_01 and DEPLOY_PATH_02 where the key and the path sit, and the same token follows the value onto every page the run opens. Real values resolve only at an approved destination, at the moment of an approved action.
The same environment puts a named person in front of each consequential action and writes every screen as tokens, every action and every approval to a record that exports to the organization's own monitoring. That record answers the context question an actions log leaves open, because it shows what the model held when it acted.
The comparison with a coding agent's own controls shows where each sits: Cursor's gates are on the command and the tool server, and its rules are on which files the agent may read, while a render-layer control acts on the page the agent draws (RedactSure vs Cursor: 2026 Comparison & Alternative). A browser session that opens a cloud console carries the same question on a rendered page (Can Cursor's Browser Agent Log Into Your Accounts?).
For this record, the two layers answer different halves. The credential's scope answers the shell, because a command that inherits a key can use anything the key can do. The render layer answers the page, because a settings page that displays the key hands it to the model whatever the project's ignore rules say.
Coverage applies to supported workflows in applications that render in the governed environment, and the control is enforced outside the model where it is integrated, so the model receives tokens in place of the values and the team keeps whatever model it has chosen.
What the record shows
The control that answers this question sits between the value and the model: a value replaced with a consistent token before it reaches the context, the real value released at a destination a named person approved, and a record of what the model held when it acted. Cursor's pages describe the layers beside that one, from the terminal prompt and the MCP prompt to a file exclusion the terminal does not obey and run modes the vendor calls best-effort, and they say nothing about substitution before the model receives a value. The answer for a production key therefore depends on where the key lives. A key in a shell and a key on a rendered settings page fail differently, and only the first is fixed by scoping the credential. To test it, take one repository with a production key, ask the agent to fix a failing deploy, and compare three things afterward: the transcript, the command the person approved, and any log the account keeps. The values in the transcript that the task did not need are the exposure.
Methodology and limitations
This page rests on Cursor's agent security and ignore-files documentation, NVIDIA's sandbox guidance, AWS's audit guidance, an OAuth best-current-practice document, OWASP's prompt injection entry, a position paper on autonomous agents, one study of indirect prompt injection and GitHub's log documentation, together with existing RedactSure research. Public documentation read in full gives a sound view of where each product applies its control. Vendor pages were read between October 20, 2026 and October 22, 2026, and each Sources line carries the date for its page.
None of the products on this page was tested hands-on. "Not described in the pages reviewed" means the pages reviewed said nothing about a mechanism, not that the mechanism is absent; vendor features change, and the page carries its date. The example describes a record type, a repository with a production key and a failing deploy script, not an organization. Determinations about whether a workflow meets a contractual or regulatory requirement belong to counsel, assessors and the organization's own security and compliance officers.
Frequently asked questions
Is Cursor safe to use with production credentials?
No, not with a long-lived production key in a project's .env file. Cursor documents approvals on terminal commands and MCP connections, .cursorignore as the block for the agent's own file reads, and run modes it calls best-effort guardrails. None of those decides what the model holds once a command or a file exposes a value. The same key held in a role with a short session is a different question, and a better one to answer.
What does the model receive when the agent opens a file that holds the key?
Whatever the file contains, as context for the task, unless a rule keeps the file out or the value is replaced first. Cursor says .cursorignore blocks code accessible by the agent, and that .env* sits on the default ignore list. It does not say the default alone blocks the agent's reads, so a project relying on it is relying on an unstated property. The transcript is where that shows up first, because file contents and command output land in the same context.
Does the terminal approval protect the key?
No. The prompt gates the command, and the command inherits the environment, so an approved command can print any file the process can read. Cursor says the terminal cannot block access to code governed by .cursorignore. The prompt is still worth keeping, because it is the one point where a person sees what the agent proposes, and it answers who allowed the command rather than what the model held.
Does .cursorignore keep .env out of the model's context?
Only for the agent's own file reads, and only for the paths it lists. Cursor says .cursorignore blocks "Code accessible by Agent, Tab, and Inline Edit," and its patterns follow .gitignore syntax, so .env. covers the variants. The default list already includes .env, which leaves the entry useful for the files that pattern misses and for certainty about the agent route. It does not cover a terminal command or an MCP tool that reads the same file.
What record shows what a Cursor run read?
No session record is described in Cursor's pages. They document approvals and exclusions, not a record of the model's input. The logs around the work belong to other systems: GitHub's security log lists actions from the last 90 days, and AWS asks that audit logs attribute every action to an agent or a person. Both record actions, and neither shows which values were in the context when the action was chosen.
Who approves an action that spends a production key?
Whoever answers the prompt, and that is not always a named approver. Cursor's terminal and MCP prompts are on by default, and a run mode can let the agent proceed without them. An approval attached to whoever was at the keyboard is weaker than one attached to a named role for that action. The stronger form names the person, the action and the value in one record, and it is worth requesting before a production key enters the run.
How RedactSure Keeps a Production Key Out of the Model
A production key in a project file is read by the agent asked to fix a deploy, and the approvals reviewed here govern the command. Cursor says its terminal tools "cannot block access to code governed by .cursorignore."
The environment that enforces this is built by RedactSure, an AI agent controls, governance and data protection company.
Before: the agent opens the deployment settings page, and the model receives the key as the form renders it. Inside: the page draws AWS_KEY_01 and DEPLOY_PATH_02, the model works from them, and the platform lead approves the deploy that resolves the key. An ignore entry is a standing rule; for each task, RedactSure's Policy Planner proposes what the agent may see and what it may do.
RedactSure is deploying now with enterprise and government customers.
Everyone else controls where data can go. RedactSure controls what the AI can see.
See it on your own workflow
A key displayed once on a settings page stays in the model's context for the rest of the run. Bring a deploy workflow and see, with test values, what the model reads and who approves the release. Book a demo