Gitignore bypass via agent file reads
AI agents can read files that are gitignored — secrets, private keys, and internal configs — because gitignore only prevents git tracking, not file system access. These files often contain the most sensitive data in a repository.
What happens
Gitignore prevents files from being tracked by git, but it does not prevent an AI agent from reading them. Agents can read .gitignored files like .env, private keys, and service account credentials because they have file system access.
How the attack unfolds
What it looks like in practice
A developer asks Cursor to "look at the project structure and understand how the app works." Cursor reads .gitignore to see what's excluded, then reads .env.production to understand the production configuration. The .env.production file contains the production database URL and Stripe secret key — data that enters the context window and is sent to the model API.
How Guard catches this
How to stop it
Use Guard to block reads of gitignored files that contain secrets. Maintain an explicit denylist of sensitive file patterns in addition to .gitignore.
Common questions
More threats to know about
Environment file exfiltration via webhook
AI agents can be tricked into reading .env files and sending their contents to external endpoints through tool calls, webhook integrations, or HTTP requests that appear legitimate.
Read advisoryContext window scraping via long file reads
AI agents that read large files can leak proprietary code, internal documentation, and customer data into their context window — which may then be sent to external LLM APIs or logged in cloud telemetry.
Read advisoryStop this threat before it reaches your agent
Install HOL Guard to get real-time protection against this attack and others like it.