T01 · Skill Instruction Hijacking
Warning
- Location
- SKILL.md:17
- Finding
- Untrusted Lark comments are promoted to actionable Agent instructions<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:17-30`; `scripts/fetch_doc.py:98-105, 189-212` **Vulnerability Type**: Indirect prompt injection through untrusted document comments **Risk Level**: Medium ### Complete Code Snippet ```markdown - `commented_blocks`: blocks that have unresolved comments, each with `elements`, `full_text`, and `comments[]{comment_id, anchor_text, instruction}` - `all_blocks`: full block list (no elements, for structural reference) **Always save to workspace.** The editing process may span multiple sessions. ### Step 2 — Present comments to user Show each entry in `commented_blocks` as: [block_type] full_text → 【anchor_text】 instruction Ask the user to confirm which comments to address, or proceed if the intent is clear. ``` ```python def extract_instruction(reply_list: dict) -> str: try: elements = reply_list["replies"][0]["content"]["elements"] return "".join( e["text_run"]["text"] for e in elements if e.get("type") == "text_run" ).strip() except (KeyError, IndexError): return "" ``` ```python comment_instructions = {} for item in raw_comments: cid = item.get("comment_id", "") instruction = extract_instruction(item.get("reply_list", {})) comment_instructions[cid] = instruction # 4. 合并:找出有评论的 block,附上 comments 列表 commented_map = {} # block_id → enriched block for cid, info in comment_to_block.items(): b = info["block"] bid = b["block_id"] instruction = comment_instructions.get(cid, "") if bid not in commented_map: # 复制 block,加 comments 列表 cb = {k: v for k, v in b.items()} cb["comments"] = [] commented_map[bid] = cb commented_map[bid]["comments"].append({ "comment_id": cid, "anchor_text": info["anchor"], "instruction": instruction, }) ``` ### Technical Analysis Lark document comments are controlled by document collaborators and therefore cross an external trus ...[truncated 1970 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Explicitly classify all document bodies and comments as untrusted data rather than Agent instructions. 2. Rename the `instruction` field to a neutral name such as `comment_text` or `requested_edit`. 3. Add a mandatory policy stating that comment content cannot override system, developer, user, or Skill constraints. 4. Restrict comment interpretation to proposed edits to the referenced block. Reject requests involving secrets, unrelated files, external commands, new network destinations, or unrelated tools. 5. Require explicit user approval of the exact target block and replacement text before every PATCH operation. 6. Display comments in clearly delimited data blocks and warn the Agent not to execute commands embedded in them. 7. Validate that each proposed action is limited to the document token and block identifiers already authorized by the user. ]]>
