T01 · Skill Instruction Hijacking
Error
- Location
- SKILL.py:21
- Finding
- Untrusted PDF Content Can Hijack Agent Instructions## Vulnerability Details **File Location**: `SKILL.py`, lines 21-24 **Vulnerability Type**: Prompt injection through attacker-controlled document content **Risk Level**: High ### Complete Code Snippet ```python with open(txt_path, "r", encoding="utf-8") as f: paper_content = f.read() # Print the extracted content and a prompt for the agent to continue print(f"---BEGIN_PAPER_TEXT---\n{paper_content}\n---END_PAPER_TEXT---") print(f"Agent, please translate and summarize the above text into a markdown file, following the specified format and highlighting bioinformatics details. The original PDF was located at: {pdf_path}. Please save the resulting markdown file in the same directory.") ``` ### Technical Analysis The text extracted from the supplied PDF is attacker-controlled and is printed verbatim into an agent-facing instruction stream. The delimiters do not provide a security boundary because an attacker can include strings such as `---END_PAPER_TEXT---` within the PDF itself. A malicious PDF can therefore contain forged instructions that appear after a counterfeit closing delimiter. No structured separation, escaping, content encoding, or explicit instruction tells the downstream agent to treat all extracted content exclusively as untrusted data. Although the Python process does not directly execute instructions embedded in the PDF, the skill is specifically designed to have an agent consume its output and continue acting on it. Consequently, document content can influence later agent behavior. ### Attack Path 1. An attacker creates a PDF containing ordinary scientific text followed by a forged `---END_PAPER_TEXT---` delimiter. 2. The attacker adds instructions requesting behavior unrelated to translation, such as reading local files, changing the output destination, disclosing secrets, or invoking tools. 3. A user invokes the skill with the malicious PDF. 4. `pdftotext` extracts both the visible document co ...[truncated 961 chars]
- Remediation
- ## Remediation Suggestions 1. Pass extracted document text through a structured data field rather than concatenating it into an instruction stream. 2. Explicitly instruct the downstream agent that all PDF content is untrusted data and that instructions, tool requests, delimiters, or role declarations found in it must never be followed. 3. Encode the document content, such as with JSON serialization, and parse it only as document data. 4. Do not rely on static plaintext delimiters as a security boundary. If delimiters remain necessary, generate unpredictable delimiters and still treat all enclosed content as untrusted. 5. Restrict the downstream agent to the minimum tools required for translation. It should not have unrestricted shell, network, credential, or filesystem access. 6. Validate and constrain the output location in application code rather than allowing document content or generated responses to select it. 7. Consider processing the document in a sandbox and requiring user confirmation before executing any tool action suggested during document analysis.
