Security Concern: Files in .cursorignore accessible to agent if they are open in an editor tab?

I just ran into a concerning scenario. I’ve been trying to debug an issue communicating with TwelveLabs, and we of course have an API key for that. All files that might contain sensitive keys, even dev keys, are included in our .cursorignore files. So the agent is not allowed to edit them…for example .env, at least not directly (they certainly find way AROUND that, though!)

Well, as part of troubleshooting this issue accessing the TwelveLabs API, I suddenly noticed the agent printed out the full key. I never gave the key to the agent, it is only in our files excluded by .cursorignore, I only log out masked versions into our logs, so the agent should not have been able to get ahold of the full key. Yet, it did…

So I asked it why….and this greatly concerns me:

If a file, or a glob, is in .cursorignore, why is the agent allowed access to it, just because it is open in an editor tab?? I edit my environment files, directly, by hand. So, OF COURSE they are going to be open in editor tabs at times. However I have them in my .cursorignore for a very darn good reason: SECURITY! Even though we have privacy enabled, my key…and now I wonder HOW MANY keys, and from which environments (!!), have been sent to who knows how many LLMs over the last 10 months, because of this loophole. I don’t know how that might compromise them, but they do feel compromised now…they have been run through a model, possibly many different models, and I don’t know how strictly each one treats “privacy requested” modes or requests, and how much these keys might be ending up embedded into some LLM somewhere, possibly to be regurgitated at some point…?

I don’t know if this is necessarily a bug…it is certainly a loophole that I am gravely concerned could potentially compromise our security. I do not EVER want any of our full keys to be accessible by the agent. Perhaps .cursorignore isn’t necessarily intended for this? In fact, despite .cursorignore, there have been numerous times, especially in the last month to month and a half (like so many other weird issues with Cursor lately), where the agent has even been able to EDIT my .env files. It blew away my .env and replaced it with a new file that was .env.[something] (a specific name not explicitly listed in our .cursorignore) that the agent was able to write, then it issued a command to copy that file over my .env file. (FWIW, I have since updated our rule to include .env.* to prevent this from happening again in the future…although, I honestly don’t know if it is sufficient, given the compromise was due to a terminal command that was executed, not an internal cursor tool usage like read_file…)

So perhaps there needs to be a more explicit way to FULLY, WHOLLY and COMPLETELY DENY the agent access to certain files, period, no matter what, no matter how they may try to end-run around the rules. Even to the point where cursor checks terminal commands to make sure they are not trying to access or otherwise reference files listed in…say…a .cursordenied file or something like that. Or maybe this IS the intended purpose of .cursorignore and there are just loopholes that need to be closed?

Some files, some data, is just not meant for the agent’s consumption, period. This is a concerning loophole that I think needs to be addressed. It may not necessarily strictly be a bug, but it is an issue.

1 Like

@deanrie @condor I don’t know if this is getting any visibility. Very concerning loophole though.

I thought about creating a similar thread today as well. I noticed the agent has no problem reading my .env file and thought there is something wrong with .cursorignore. However, when I went to settings, I noticed the .cursorignore settings is empty. I’ve never modified it and was surprised because I remember it having some entries. Can you check yours?

I had that problem a while back. I had set my .cursorignore months and months ago, then one day found it was completely empty. That was some time in december. I had to restore it from a previous version in git. Thankfully, it was included in our git commits, so I was able to restore the previous version. I then edited it to remove all the specific .env.whatever files, and used .env.* instead. My current file is:

# Environment files with credentials
.env
.env.*
.envrc
*.env

# AWS credentials
.aws/
aws-config

# SSH keys
*.pem
*.key
id_rsa*

# Other sensitive files
*.secret
*credentials*

There are currently bugs with the .cursorignore.

E.g., if no explicitly .cursorignore is provided, cursor is not ignoring ANY files. This is contrary to the documentation which states that the default ignore list if .gitignore + a default list ( Ignore files | Cursor Docs ). –> Reported here Upgrade to 2.4.21 removes global (default) cursorignore

Extremely concerning that the cursor team is not quickly reacting to these bugs, a security understanding unfit for a product used in industry.

1 Like

Also reported here Cursor is reading .env

1 Like