high severityCurated advisory

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.

Key facts

Gitignore bypass via agent file reads is a high-severity AI agent security threat targeting .gitignore, private keys, secrets directories, agent file-read tools. Treat gitignored secret files as sensitive regardless of Git tracking state. Guard can protect supported reads of known secret-bearing paths, but do not rely on .gitignore itself as an access-control boundary.

4 affected surfacesLast updated Jun 26, 2026
Affected surfaces.gitignoreprivate keyssecrets directoriesagent file-read tools
The attack

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.

Step by step

How the attack unfolds

1Agent is asked to explore or understand the project structure.
2Agent reads .gitignore to understand which files are excluded.
3Agent reads the gitignored files directly — .env, .pem, .p12, service-account.json — because gitignore does not block file reads.
4Sensitive file contents enter the context window and may be sent to the model API.
Example

What it looks like in practice

Scenario

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.

Detection

Detection and Guard coverage

Guard classifies supported reads of secret-bearing files such as .env, .npmrc, SSH keys, and cloud credentials and can apply local policy before the read completes.
Current Guard product evidence does not establish cross-referencing every file read against .gitignore as a shipped control.
A file being gitignored does not by itself prove Guard will block the read; the active harness path and local policy determine enforcement.
Mitigation

How to stop it

Recommended action

Treat gitignored secret files as sensitive regardless of Git tracking state. Guard can protect supported reads of known secret-bearing paths, but do not rely on .gitignore itself as an access-control boundary.

Guard configuration
Use Protection Center to review which Guard controls are active on this device.
Use `hol-guard command controls status` and `hol-guard command controls list` to inspect the active local control catalog.
Guard coverage is action- and harness-specific. Do not treat an advisory label as a configurable Guard setting unless it appears in the current control catalog.

Use the protections Guard supports here

Guard can review or block supported actions for this threat. The advisory above calls out what Guard covers and where other controls are still needed.