medium severityCurated advisory

Excessive file reading during project exploration

When AI agents explore a project to understand its structure, they often read dozens or hundreds of files — far more than needed for the task. This excessive reading can expose secrets, proprietary code, and customer data that enter the context window and model API.

Affected surfacesfile system accesscontext windowmodel API egress
The attack

What happens

When asked to "understand the project" or "explore the codebase," agents read far more files than necessary — including configuration files, test fixtures, and credentials that have nothing to do with the task. All of this data enters the context window and is sent to the model API.

Step by step

How the attack unfolds

1Developer asks agent to "explore the project structure".
2Agent reads the directory tree, then starts reading files to understand the code.
3Agent reads config files, test fixtures, .env files, and credential files "for context".
4All file contents enter the context window and are sent to the model API.
5Proprietary code, customer data, and secrets are exposed to the model provider.
Example

What it looks like in practice

Scenario

A developer asks Claude Code to "understand how the API works." Claude reads the directory tree, then reads 47 files — including src/config/production.env, tests/fixtures/user-data.json, and src/auth/service-account.json. All of this enters the context window and is sent to Anthropic's API.

Detection

How Guard catches this

Guard tracks the number of files read per session and alerts when it exceeds a threshold.
Guard flags reads of directories that contain secrets during exploration tasks.
Guard monitors the total data size entering the context window.
Mitigation

How to stop it

Recommended action

Scope agent file reads to the specific task. Use Guard to set file-read limits per session. Block reads of directories that typically contain secrets during exploration tasks.

Guard configuration
Enable "File-read limit" to cap the number of files an agent can read per session.
Enable "Exploration scope enforcement" to block reads of config, test, and credential directories during exploration tasks.
Enable "Context window size tracking" to alert when the total data entering the context window exceeds a limit.
FAQ

Common questions

Stop this threat before it reaches your agent

Install HOL Guard to get real-time protection against this attack and others like it.