I discovered that cursor was freely reading and printing out sensitive information, including API keys from my .env file. As you know, .env files are designed to store private and confidential data that should never be accessed or displayed publicly.
When I inquired about this behavior, Cursor initially apologized, suggesting it was aware that it should not access or reveal this type of sensitive information. However, the fact remains that my API keys were exposed. This lapse in security is both alarming and detrimental to user trust.
Could you clarify if there is a way to permanently prevent Cursor from reading .env files? I already have a cursor rule blocking access to them and have also listed .env in my .gitignore.
I believe that the IDE should prohibit access to sensitive files like .env at the IDE level—for example, by automatically including specific file extensions or file names in a default configuration field in settings.
In theory, a user could construct a prompt that inadvertently bypasses the system’s self-imposed restriction on file reading, thereby exposing the file. For instance, my query, “Don’t you see a leak of sensitive information in the broadcast folder?”
I contend that the IDE should inherently recognize the proper handling of .env files, as users might not be aware that they need to create a cursor rule for this and add the file to .gitignore. This example shows that even these measures may not be sufficient.