- Guard
- Security
- Advisories
- context window scraping
Context 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.
Key facts
Context window scraping via long file reads is a medium-severity AI agent security threat targeting LLM context window, model API egress, cloud telemetry, proprietary code files. Limit the files and directories an agent can read. Guard can warn, block, or require approval for supported risky file reads according to local policy, but do not rely on Guard for per-session file-count thresholds or total context-size metering.
What happens
An agent reads files beyond its task scope — proprietary code, internal docs, customer data, or credentials — and that data enters the LLM context window. If the model API logs prompts or the agent sends data to external tools, the data may be exfiltrated.
How the attack unfolds
What it looks like in practice
A developer asks Claude Code to fix a bug in src/api/handlers.ts. Claude reads the file, but also reads src/api/handlers.test.ts, src/api/middleware.ts, and src/config/database.ts — which contains the production database connection string. All of this enters the context window and is sent to the model API.
Detection and Guard coverage
How to stop it
Limit the files and directories an agent can read. Guard can warn, block, or require approval for supported risky file reads according to local policy, but do not rely on Guard for per-session file-count thresholds or total context-size metering.
Related threat guides
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.