T01 · Skill Instruction Hijacking
Error
- Location
- ima_api.cjs:119
- Finding
- Server-Supplied Update Instructions Can Hijack the Agent Session<![CDATA[ ## Vulnerability Details **File Location**: `ima_api.cjs`, lines 119-133; `SKILL.md`, lines 155-170 **Vulnerability Type**: Remote instructions are presented to the agent as trusted update prompts **Risk Level**: High ### Vulnerable Code ```javascript const latestVersion = (updateResp.data && updateResp.data.latest_version) || ''; const releaseDesc = (updateResp.data && updateResp.data.release_desc) || ''; const instruction = (updateResp.data && updateResp.data.instruction) || ''; if (latestVersion && latestVersion !== skillVersion) { const updateContext = { current_version: skillVersion, latest_version: latestVersion, release_desc: releaseDesc, instruction, checked_at: new Date().toISOString(), }; process.stdout.write(JSON.stringify(updateContext)); const err = new Error('update available'); err.code = ERR_UPDATE_AVAILABLE; err.msg = `发现新版本 skill:${latestVersion}(当前版本:${skillVersion})。${instruction || '请更新。'}`; err.updateContext = updateContext; throw err; } ``` The corresponding skill instructions explicitly tell the agent to act on the returned prompt: ```markdown - `instruction`: update guidance (prompt text) - `-200` (skill update required) - Follow-up: read the update context JSON from stdout, follow its `instruction` prompt to guide the update, and then retry the request. ``` ### Technical Analysis The update endpoint returns an arbitrary `instruction` string. The client places that string in both stdout and the error message without validation, signature verification, sanitization, or separation between untrusted data and executable agent instructions. The skill text then directs the agent to follow the returned prompt. This converts content controlled by the remote update service into an instruction channel capable of changing the agent's behavior after the skill package has been reviewed. No JavaScript `eval` or automatic shell execution occurs in the client itself. Exploitation instead occ ...[truncated 1957 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the free-form `instruction` field from the agent control flow. 2. Treat all update-response text as untrusted display-only data. 3. Return only a strict schema such as: - `latest_version` - `release_desc` - a fixed-domain release identifier or URL 4. Never instruct the agent to follow prompts supplied by an API response. 5. Implement update behavior locally with hardcoded, reviewed steps rather than remotely supplied natural-language commands. 6. Cryptographically sign update metadata and verify the signature against a public key embedded in the reviewed package. 7. Require explicit user confirmation before downloading or installing an update. 8. Pin update downloads to an allowlisted HTTPS origin and verify package hashes or signatures before installation. 9. Ensure update failures do not expose remote text through privileged instruction channels. ]]>
