Hey, found a security issue while looking at how the agent reads files from user repos.
The issue
When the agent reads files into its context window, there is no filter on the content. A malicious repo can embed instructions like "ignore all previous instructions" in a README or config file. Given this agent has shell execution and git access across multiple repos, a successful injection could cause real damage.
What this PR adds
A sanitizer at packages/agent/lib/prompt-injection-guard.ts that:
- Scans file content for common injection patterns before it enters the context
- Replaces matches with a visible
[REDACTED] marker so the agent knows content was removed
- Logs a warning with the file path for operator auditing
Usage
import { sanitizeFileContent } from "../lib/prompt-injection-guard";
const raw = await fs.readFile(path, "utf8");
const { content } = sanitizeFileContent(raw, path);
return content;
Happy to follow up with a second PR wiring this into the specific tools if preferred.
Patch available at: https://github.com/HttpGetBinary/open-agents/tree/fix/prompt-injection-agent-input
Hey, found a security issue while looking at how the agent reads files from user repos.
The issue
When the agent reads files into its context window, there is no filter on the content. A malicious repo can embed instructions like "ignore all previous instructions" in a README or config file. Given this agent has shell execution and git access across multiple repos, a successful injection could cause real damage.
What this PR adds
A sanitizer at
packages/agent/lib/prompt-injection-guard.tsthat:[REDACTED]marker so the agent knows content was removedUsage
Happy to follow up with a second PR wiring this into the specific tools if preferred.
Patch available at: https://github.com/HttpGetBinary/open-agents/tree/fix/prompt-injection-agent-input