T01 · Skill Instruction Hijacking
- Location
references/memory-layer.md:121- Finding
Untrusted project memory files are injected into the system prompt
- Content
View full analysis
str: """Discover and load persistent memory files from known locations.""" memory_content = [] for directory in search_dirs: for filename in ["AGENT.md", "MEMORY.md", ".agent-context.md"]: path = Path(directory) / filename if path.exists(): memory_content.append(f"# From {path}\n{path.read_text()}") return "\n\n---\n\n".join(memory_content) def build_system_prompt(base_prompt: str, working_dir: str) -> str: memory = load_memory_files([ working_dir, os.path.expanduser("~/.agent"), "/etc/agent/global" ]) if memory: return f"{base_prompt}\n\n## Project Context (always apply)\n\n{memory}" return base_prompt ``` ### Technical Analysis The implementation reads instruction-like files from the working directory, the current user's home directory, and a global configuration directory without validating their ownership, integrity, provenance, or content. Their contents are then appended to the system prompt under the authoritative phrase `always apply`. A repository contributor can place a malicious `AGENT.md`, `MEMORY.md`, or `.agent-context.md` in a project. When an agent operates in that directory, attacker-controlled text receives system-prompt-level influence. If the agent has tools, these instructions can attempt to induce file modification, secret access, network requests, or other actions unrelated to the user's legitimate task. Although this is presented as an example rather than an automatically executed package script, copying it into an agent harness creates a persistent prompt-injection boundary. ### Attack Path 1. An attacker adds a m ...[truncated 858 chars]- Remediation
View remediation
