Skip to content
redactsure
Book a demo

Explore.

Data Report · RedactSure Research
Chris Sowa · Founder, RedactSure
Published
Last updated

Does .cursorignore Stop the Agent From Reading Your API Keys?

Partly: .cursorignore blocks the agent's file access to the paths it lists, so a key file named there stays out of the agent's own reads. The rule does not reach a key printed by a test, kept in git history or shown on a rendered page, so treat it as hygiene and keep credentials off those routes.

A credential reference travels from a browser record through a bounded route to a separate API destination.

A coding agent now runs inside repositories that hold live credentials: a .env file for local services, a deploy key beside the build scripts, a cloud access key pasted into notes. The first fix is usually a line in .cursorignore, and Cursor's documentation supports it: the file blocks the agent's access to the paths it names (Cursor, Ignore, 2026). What a team often assumes next is that the credential is now out of the agent's reach. That assumption fails at the routes a file list does not touch.

The agent runs a test that prints the key, reads a log from the last deployment, or opens the vendor dashboard where the key is displayed. The value arrives in its context without any file being read. For example, a failing test prints a key that sits in a file .cursorignore lists, and the ignore entry does nothing about the printed copy. A path rule answers whether a named file may be opened by a tool; it says nothing about a value that comes through a command, a stored record or a page. That distinction decides where a team spends its effort, on longer ignore lists or on keeping real values out of the places an agent reads, and a team should settle it before an incident rather than after one.

Key findings

  • For a path rule to keep an API key out of a coding agent's context, every route to the value would have to pass through that rule; a test that prints the key, a commit that stored it and a page that renders it do not, which is why the value has to be replaced before any model reads it (What Is Render-Layer Tokenization?).
  • It would also require a named person approving each action that uses the credential and a record of what the model received, because a list of paths can show neither (What Is an AI Control Record?).
  • Cursor's documentation does not describe the terminal or MCP route as covered: it says those tools "cannot block access to code governed by .cursorignore", so a command the agent runs can still print a key from a listed file (Cursor, Ignore, 2026).
  • A USENIX Security 2026 paper reports that splitting content a rule would block across interactions and reassembling it from memory "achieves an average bypass success rate of 86.3%" against the access-control layer, not completion of the harmful task (USENIX Association, 2026).
  • Meta's Rule of Two holds that an agent should combine no more than two of untrusted input, sensitive data access, and state change or external communication, and a file list lowers the second only where a pattern matches (Meta AI, 2025).
  • Trustworthy agent automation "cannot be solved at a single layer of the stack", so a path rule and a control on what a model reads answer different layers rather than substituting for each other (DAPLab, 2026).

What does .cursorignore block, and what can the agent still read?

Cursor's ignore-files documentation describes one control and gives it a narrow scope. It blocks the agent's access to files at the paths the file lists: Cursor blocks "Code accessible by Agent, Tab, and Inline Edit" and "Code accessible via @ mention references" (Cursor, Ignore, 2026). Entries use .gitignore syntax, so .env covers every dotenv variant, config/* covers a folder, and an exclamation mark at the start of a pattern can reopen a path a broader pattern matched.

Two other settings sit beside it. Files in .gitignore and in a default ignore list that includes .env are "automatically ignored", and the page does not say which features that exclusion applies to, so the documentation does not establish that the default alone blocks the agent's own reads (Does Cursor Read My .env File?). That is why the practical instruction is to list .env in .cursorignore rather than rely on the default.

The scope statement that matters here is about the surface. A .cursorignore entry is a rule about stored files in the project, applied when one of Cursor's tools asks for a path; it is not a filter on what a page renders, and Cursor's documentation does not describe it as one. A governed environment works on the other surface: it covers what an agent reads and does on a rendered page, such as a dashboard, a console or a settings page, and it does not cover the terminal, the IDE, the local filesystem, direct API calls or MCP. A team needs to know which surface its credential is on before it decides either control is enough.

What can the agent still read outside the ignore file?

The record type for this page is a key printed to the terminal by a failing test. A developer runs the suite, one test fails on an expired token, and the assertion output includes the value it compared. The agent reads the command output to decide what to fix. No read of a listed path occurred, so .cursorignore had nothing to block, and Cursor states that the terminal and MCP server tools used by Agent "cannot block access to code governed by .cursorignore" (Cursor, Ignore, 2026).

The default approval does not close the gap. Cursor's agent security page says "By default, terminal commands need your approval", so a person can stop the command, but the approval is asked once, before the output exists, and an approved test run returns the printed key to the agent (Cursor, Agent, 2026). The same page says "All MCP connections need your approval", which gates the connection and not the values a tool returns through it.

Memory is the second opening. A check applied when the agent requests something does not decide what its memory holds later: a USENIX Security 2026 paper reports that content a rule would block can be "fragmented across interactions, stored in long-term memory in a benign-appearing form, and later reconstructed through memory retrieval", with an 86.3% average bypass of the access-control layer (USENIX Association, 2026). Can a Coding Agent Read My AWS Credentials File? describes the path rule for a credentials file and the same limit at the shell. The pattern for a buyer is to ask which routes carry values the path list never sees, and to test the output of a failing test as well as the file.

What do the vendors themselves say?

Cursor's documentation states the scope of its own control, which is the best place to start. The ignore-files page says .cursorignore blocks "Code accessible by Agent, Tab, and Inline Edit" and "Code accessible via @ mention references"; it says .gitignore entries and a default list that includes .env* are "automatically ignored" without naming the features that exclusion covers; and it says that "while Cursor blocks ignored files, complete protection isn't guaranteed due to LLM unpredictability" (Cursor, Ignore, 2026). The agent security page adds that "By default, terminal commands need your approval" and "All MCP connections need your approval", and it describes the run modes as "best-effort guardrails rather than a hard security boundary" (Cursor, Agent, 2026).

Dimension Cursor, per its documentation What a buyer should verify
Paths covered Files listed in .cursorignore, for the Agent, Tab, Inline Edit and @ mentions Whether the pattern covers the real filename and its variants
Defaults .gitignore entries and a default list including .env* are "automatically ignored" Which features that exclusion applies to, since the page does not say
Terminal and MCP The tools "cannot block access to code governed by .cursorignore" What a test or build command prints
Guarantee "complete protection isn't guaranteed due to LLM unpredictability" What the agent read before the rule was added
Actions Terminal commands and MCP connections need approval by default Who answers the prompt and what the output holds

Meta's Rule of Two makes the design limit explicit: until injection is reliably stopped, "agents must satisfy no more than two of the following three properties within a session", and the properties are untrusted input, sensitive data access, and state change or external communication (Meta AI, 2025). A coding agent reading a repository with a test that can print a key combines all three until the sensitive data is removed, and a file list removes it only where a pattern matches. A buyer should read the table as a description of one layer, not as a statement that the layer covers the run. The question is not whether the block works for a listed path, since the documentation is clear that it does, but which features and routes the same documentation places outside it.

Does a file rule cover a rendered screen, a build log or git history?

Three routes fail for different reasons, and separating them is the useful part of the review.

Git history is not a file the tool opens through the project path. A key committed last year remains in the object database, and a diff or a log view that includes it is text an agent can be given. A pattern in .cursorignore does not rewrite commits, and the terminal route that reads history is the route Cursor says its tools cannot block (Cursor, Ignore, 2026).

A build log is a file until it is a page. A log written into the workspace is readable unless a pattern covers it, and a CI system's log viewer is rendered in a browser, so the file layer is not where that value appears. The same holds for a vendor dashboard that shows an API key after it is created: the page is drawn from the server's response, the agent reads the rendered text, and a rule about stored files has no view of it.

The research record says why one layer is not enough. Columbia's DAPLab puts it plainly: "trustworthy agent automation cannot be solved at a single layer of the stack" (DAPLab, 2026). A control at the agent-tool interface is a stronger answer for tool traffic, and the authors of one 2026 study still report that "existing agentic security benchmarks are easily saturated by a simple approach" (Bhagwatkar et al., 2026), so a benchmark result does not describe a repository's history or a settings page. What Is Render-Layer Tokenization? sets out the page-side control, and What Is Least Exposure? the principle behind it: a value a task does not need is a value the model does not need.

Who approves the action that uses a key the agent read?

A path rule governs reading, and the run continues after the read. The same agent can call an API with the key, push a commit, open a pull request or change a setting on a page. Cursor's defaults put a decision in front of the terminal command and the MCP connection, and the agent security page describes the run modes as "best-effort guardrails rather than a hard security boundary" (Cursor, Agent, 2026). Approval by default gates the action and is answered by whoever is at the keyboard.

The oversight question is older than coding agents. Article 14 of the EU AI Act requires high-risk systems to "be effectively overseen by natural persons during the period in which they are in use", and says overseers must be able to "disregard, override or reverse the output" and "interrupt the system through a 'stop' button or a similar procedure" (European Union, 2024). A file list gives an overseer no view of the run, no named approver and no record to review.

For this page's record the gap is concrete. The key printed by the failing test is used in a command the developer approved before the output existed, so the approval covered the command and not the value. What Is Supervised Delegation? describes approval by a named person for each consequential action, and What Is an AI Control Record? the record of what the model read, what it did and who approved. Does Cursor Keep an Audit Log of What the Agent Did? takes up the audit question and the same condition: a record of the screen shows what the model saw only if the values on it were replaced first. A longer ignore list cannot replace either, because the list never sees the action or the output. The approval question is therefore separate from the read question, and a review that answers only the second leaves the first open.

What does a governed environment change?

A governed environment is a control class that acts where a page is rendered, before any model reads it. Values chosen by policy are replaced with consistent tokens for the whole run, so the model works on placeholders such as KEY_001. Real values resolve only at an approved destination, at the moment of an approved action. A named person confirms the policy and approves each payment, submission or record change, and every screen as tokens, every action and every approval is exported to the organization's own monitoring.

For this page the class changes two things a path rule leaves alone: the value that arrives on a page and the record of what the model received. A test that prints a key to a terminal is outside this control's scope, so the fix for that route stays operational: keep the value out of the test output, and rotate the key if it printed. What the class does change is the value that arrives through a rendered screen, such as the settings page where the key is rotated, the dashboard where it is displayed, or the CI log viewer that renders a line of output. Those pages are drawn as tokens for the model, and the real value is released only where a named person approved its use.

The control is model agnostic and is enforced outside the model where integrated, so the model receives tokens in place of the values. Its scope is the rendered page in supported workflows, not the terminal, the IDE, the local filesystem, direct API calls or MCP, so the two surfaces stay complementary. RedactSure vs Cursor: 2026 Comparison & Alternative sets out the comparison for this vendor.

What the record shows

A control class that replaces values on a rendered page before any model reads it addresses a surface a path rule never sees. The path rule decides which stored files a tool may open, and the answer it gives is partial. Cursor's page describes a block for the code its file tools can reach, a default that ignores .env* without saying which features that covers, and a terminal and MCP route that the same documentation says the block cannot reach (Cursor, Ignore, 2026). A key printed by a failing test is therefore in the model's context even when the file that holds it is listed. A team should keep the path rule and stop treating it as isolation, because a key is out of reach only when each surface it appears on is governed by a control that fits that surface. Settling it takes one repository and one dummy key: list the file in .cursorignore, run a test that prints the key, compare what the agent received before and after the rule, then open a settings page that shows a key and check what the model receives there.

Methodology and limitations

This page rests on Cursor's ignore-files and agent security documentation, one USENIX Security paper, one preprint, Meta's Rule of Two post, Article 14 of the EU AI Act, a Columbia University lab page and existing RedactSure research pages. The vendor pages were read in full, and a full read of public documentation gives a sound view of where a product applies its control. Vendor pages were read between October 16, 2026 and October 22, 2026, and each Sources line carries the date for its page.

No product on this page was tested hands-on, so nothing here reports an observed read. "Not described in the pages reviewed" means the pages reviewed and nothing broader; vendor features change, and the page carries its date. The description of RedactSure reflects the product as deployed, and RedactSure is deploying now with enterprise and government customers. The example describes a record type, a key printed by a failing test, and not an organization. Determinations about whether a configuration meets a legal, contractual or regulatory requirement belong to counsel, assessors and the organization's own security and compliance officers. Nothing here replaces a pilot of one workflow on the organization's own screens.

Frequently asked questions

Does .cursorignore stop the agent from reading my API keys?

Partly. It blocks the agent's access to the file paths the ignore file lists, so a key file named there is out of the agent's own file reads. A credential in an unlisted file is readable like any other file. It does not reach a key printed by a test, shown on a rendered page or left in a commit, and Cursor says the terminal and MCP tools cannot block access to code the rule governs. List the real filenames, then check the other routes.

What can the model still read after .cursorignore is set?

The output of a command, a log line, a diff from git history, an unlisted file and any value a rendered page displays. The rule applies where Cursor's tools ask for a path, so a value that arrives through the terminal or a page is outside it. Cursor documents the terminal and MCP limit directly. An unlisted copy of the same key is the other common gap. Test the routes your agent actually uses, and rotate any key that has already appeared in output.

Does .cursorignore cover the terminal and MCP tools?

No. Cursor states that the terminal and MCP server tools used by Agent cannot block access to code governed by .cursorignore (Cursor, Ignore, 2026). Terminal commands and MCP connections need approval by default, which gates the command or the connection and not the output a tool returns. Read the prompt for what the command will print, not only for what it will do. If a test prints a key, the approval was for the test run, and the value is in the agent's context once the command finishes.

Who approves the action that uses a key the agent read?

By default, the developer at the keyboard answers the terminal and MCP prompts. That is a decision about an action, made before the output exists in the test case, and Cursor calls its run modes best-effort guardrails rather than a hard security boundary (Cursor, Agent, 2026). The value can be used in any later command the same run is permitted to make. Ask for an approver who is named in the record, and for a record that shows what the model had read before the action.

What record shows what the agent read?

A .cursorignore file shows what the project intended to block and nothing about what the agent received. The pages reviewed do not describe a per-run record of the values the model saw, so the file list cannot answer the question after an incident. The practical substitute is operational: keep credentials out of the workspace, log the commands and pages the agent uses, and review the output of any test that prints configuration values. A dated export of the run answers that question better than a settings file.

Is .cursorignore enough for a repository that holds customer data?

No, not on its own. It closes the file path for the agent's own tools, and leaves the terminal, MCP servers, history, logs and rendered pages to other controls. The useful test is one dummy value and four routes: a listed file, a printed command, a git diff and a settings page. Whichever route still shows the value is the one to fix next, and the file list is worth keeping either way. A path rule is worth having, and it is not a boundary.

About the author

Chris Sowa is a founder of RedactSure and a former CEO of an AI company; he started it years before ChatGPT existed. He previously led AI at Accenture, served as Global VP of Strategy & Innovation at Schneider Electric, was CCO of Sovos, and spent more than a decade at Oracle, with earlier roles at SAP and IBM.

How RedactSure Keeps a Printed Key Off the Rendered Page

An ignore file hides a path while the same key appears in test output and on a page.

The environment that enforces this is built by RedactSure, an AI agent controls, governance and data protection company.

A path entry is a standing rule. For each task, RedactSure's Policy Planner proposes what the agent may see and what it may do. Before, the key printed by a failing test stayed in the agent's context for the run. Inside, the settings page renders KEY_001, the real value lands at the approved API, and a named person approves the release.

RedactSure is deploying now with enterprise and government customers. Cursor says its terminal and MCP tools cannot block access to code governed by .cursorignore.

Everyone else controls where data can go. RedactSure controls what the AI can see.

See it on your own workflow

A path rule protects a file, not the key a test prints or a settings page shows. Bring one task where an agent handles a key and see, with test values, what the model reads and who approves the release. Book a demo

Book a demo

Book a demo

Having trouble? Open the booking page or email us.