T01 · Skill Instruction Hijacking
- Location
ima_api.cjs:119- Finding
Backend-Controlled Update Instructions Can Hijack Agent Behavior
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This IMA notes and knowledge-base skill is purpose-related, but it needs Review because it handles private notes, files, and credentials with under-scoped network and update behavior.
Install only if you are comfortable giving this skill access to your IMA notes, knowledge bases, selected local files, and IMA API credentials. Before use, avoid plaintext credential files when possible, do not set IMA_BASE_URL unless you fully trust the endpoint, treat update instructions as untrusted text, and be careful with URL imports because the workflow can fetch and upload remote content.
ima_api.cjs:119Backend-Controlled Update Instructions Can Hijack Agent Behavior
ima_api.cjs:65IMA Credentials Can Be Transmitted to an Arbitrary Configurable Endpoint
knowledge-base/SKILL.md:193Unrestricted URL Fetching Enables Server-Side Request Forgery
knowledge-base/scripts/cos-upload.cjs:73Long-Lived and Temporary Credentials Are Exposed Through Process Arguments
knowledge-base/SKILL.md:78Unescaped File Metadata Is Interpolated into JSON Request Bodies
The activation text is extremely broad and matches common phrases like '帮我记一下' or general document/search intents, which can cause the skill to trigger for routine conversation that the user did not intend to route to an external knowledge service. This increases the risk of accidental data disclosure, unintended persistence of personal content, or unnecessary use of stored credentials.
The skill declares network and environment-variable capabilities but does not explicitly constrain tool scope with a permissions/allowed-tools policy. In practice, this leaves the agent with ambiguous authority boundaries for credential access and outbound requests, increasing the chance of unintended tool use or abuse if the skill is invoked in the wrong context.
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
1. **UTF-8 encoding (notes writes only):** Before calling `import_doc` or `append_doc`, ALL string fields (`content`, `title`) MUST be validated as legal UTF-8. Non-UTF-8 content causes irreversible garbled text. See [Detailed Rules](#detailed-utf-8-encoding-rules) for platform-specific methods.
2. **File upload naming:** `title` MUST equal `file_name` (with extension). Never rename, shorten, translate, or modify the original filename.
3. **Unsupported file types:** Reject immediately with a clear message. Do NOT ask user "do you still want to try?" Video files, Bilibili/YouTube URLs, and `file://` URLs are not supported — tell user to use IMA desktop client.
4. **File upload integrity:** Keep file content as-is during upload. No encoding conversion for binary files (PDF, images, Excel, etc.).
5. **PowerShell 5.1 (all modules):** If running in PowerShell, detect version before first API call. PS 5.1 silently converts request Body to GBK — must use UTF-8 byte array mode. See [Detailed Rules](#powershell-51-environment-detection).
The operational instructions and user-facing routing examples are written entirely in Chinese and implicitly assume Chinese-language interaction patterns, without offering a language or locale choice. Under the policy, skills should not force a specific language unless the constraint is documented and justified or the user opts in.
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.
## 模块决策表
| 用户意图 | 模块 | 读取 |
| ------------------------------------------------------------------------------------------ | -------------- | ------------------------- |
| 搜索笔记、浏览笔记本、获取笔记内容、创建笔记、追加内容 | notes | `notes/SKILL.md` |
| 上传文件、添加网页链接、搜索知识库、浏览知识库内容、获取知识库信息、获取可添加的知识库列表 | knowledge-base | `knowledge-base/SKILL.md` |
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.
## 模块决策表
| 用户意图 | 模块 | 读取 |
| ------------------------------------------------------------------------------------------ | -------------- | ------------------------- |
| 搜索笔记、浏览笔记本、获取笔记内容、创建笔记、追加内容 | notes | `notes/SKILL.md` |
| 上传文件、添加网页链接、搜索知识库、浏览知识库内容、获取知识库信息、获取可添加的知识库列表 | knowledge-base | `knowledge-base/SKILL.md` |
The skill recommends persisting API credentials in plaintext files under ~/.config/ima, which creates a local secret-at-rest exposure risk. Other local users, processes, backups, shell history, or malware could recover these long-lived credentials and use them to access the user's IMA account or data.
方式 A — 配置文件(推荐):
mkdir -p ~/.config/ima
echo "your_client_id" > ~/.config/ima/client_id
echo "your_api_key" > ~/.config/ima/api_key
The script emits user-facing error text in Chinese, and similar hard-coded Chinese messages appear elsewhere in the file. There is no opt-in, language selection mechanism, or documented justification for restricting output to a specific locale.
The code sends client ID and API key in outbound requests and this file provides no user-facing disclosure that credential-bearing calls will occur. In a skill context, undisclosed authenticated network activity is risky because users may trigger actions without understanding that secrets and request metadata are being transmitted to a remote service.
The skill performs a remote self-update check on most API calls, which is outside the stated note/knowledge functionality and creates an undeclared secondary network flow. Although it does not auto-download code, it transmits metadata and can alter runtime behavior by causing the tool to fail with an update-required condition, increasing privacy and integrity risk beyond user expectations.
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.
## 接口决策表
| 用户意图 | 调用接口 | 关键参数 |
| --------------------------------------------- | ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| 上传文件到知识库 | `check_repeated_names` → `create_media` → COS Upload → `add_knowledge` | `media_type`(按扩展名),`knowledge_base_id`,`file_name`,`file_size` |
| 上传文件到知识库的某个文件夹 | 先定位文件夹 → 同上(`folder_id` 传入目标文件夹 ID) | 见「文件夹操作」章节 |
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.
## 接口决策表
| 用户意图 | 调用接口 | 关键参数 |
| --------------------------------------------- | ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| 上传文件到知识库 | `check_repeated_names` → `create_media` → COS Upload → `add_knowledge` | `media_type`(按扩展名),`knowledge_base_id`,`file_name`,`file_size` |
| 上传文件到知识库的某个文件夹 | 先定位文件夹 → 同上(`folder_id` 传入目标文件夹 ID) | 见「文件夹操作」章节 |
The manifest frames this skill as a unified IMA OpenAPI capability for note management and knowledge-base operations. In contrast, the documented workflow explicitly performs outbound network access to arbitrary user-supplied URLs via curl, including header inspection and full file download, which is a distinct web-fetching capability not inherent to basic knowledge-base CRUD/search behavior.
The document instructs callers to send credential-bearing headers (ima-openapi-clientid, ima-openapi-apikey) and later also documents temporary COS secrets, but it provides no warning about treating these values as sensitive, redacting them from logs, or avoiding exposure in user-visible output. In an agent skill context, this omission is risky because LLM-driven tooling may echo headers, include them in traces, or mishandle them during debugging, which can lead to unauthorized API access.
The API reference defines URLInfo.headers as request headers required to access protected media URLs, but it does not warn that these headers may contain bearer tokens or other sensitive authorization material. In this skill, that is dangerous because an agent could retrieve protected content and accidentally disclose the signed URL or headers in messages, logs, or downstream requests, enabling unauthorized access to private documents.
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.
| 值 | 名称 | content_type / 说明 |
| --- | -------------- | ------------------------------------------------------------------------------------------------------------- |
| 1 | PDF | `application/pdf` |
| 2 | 网页 | N/A(直接 AddKnowledge,`web_info.content_id=<url>`) |
| 3 | Word | `application/msword` / `application/vnd.openxmlformats-officedocument.wordprocessingml.document` |
| 4 | PPT | `application/vnd.ms-powerpoint` / `application/vnd.openxmlformats-officedocument.presentationml.presentation` |
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.
| 9 | 图片 | `image/png`, `image/jpeg`, `image/webp` |
| 11 | 笔记 | N/A(直接 AddKnowledge,`note_info.content_id=<doc_id>`) |
| 12 | AI会话 | N/A(直接 AddKnowledge,`session_info.content_id=<session_id>`) |
| 13 | TXT | `text/plain` |
| 14 | Xmind | `application/x-xmind` / `application/vnd.xmind.workbook` / `application/zip` |
| 15 | 录音 | `audio/mpeg`(mp3), `audio/x-m4a`(m4a), `audio/wav`(wav), `audio/aac`(aac) |
| 16 | 视频解析 | **不支持通过 skill 添加**。Bilibili/YouTube/本地HTML等仅支持在 ima 桌面端内添加进知识库 |
Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.
#### 返回字段(`data` 内)
| 字段 | 类型 | 说明 |
| ------------------- | --------------- | ------------------------------------------------------------------------------------------------- |
| `media_type` | int32 | 媒体类型(见 MediaType 枚举) |
| `url_info` | URLInfo | 访问链接信息,非笔记类型时填写(见 [URLInfo](#urlinfo访问链接信息)) |
This code requires sensitive credential arguments (--secret-id, --secret-key, --token) and later performs an HTTPS PUT upload of local file contents to COS, but the user-facing messaging only covers usage and errors. There is no confirmation prompt or explicit warning that the script will transmit local file data and credential-derived authorization material to a remote service.
The trigger guidance for SearchNote uses broad phrases like “搜索”“找笔记”“查找包含XX的内容” without requiring stronger note-specific context or user confirmation. In a skill that can access private notes, overly generic triggers increase the chance of accidental invocation and unintended retrieval of sensitive user data.
Phrases such as “列出笔记” and especially “最近的笔记” are underspecified and can match common conversational requests that do not clearly authorize private note enumeration. Because the skill operates on personal note metadata, accidental activation could expose notebook structure, titles, and timestamps.
The write-capable ImportNote trigger includes very broad phrases like “新建笔记”“导入笔记”“把这段内容保存为笔记” without clearly defined boundaries or confirmation requirements. Overbroad activation on a write operation is more dangerous than read-only misfires because it can create or store content in a user's private workspace without clear intent.
The skill's stated purpose is operating on notes and knowledge bases, but the implementation also reads credentials from environment variables and from ~/.config/ima/, and persists update-check state under the user's home directory. While credentials may be a practical integration detail, local filesystem access for credential and updater state management is not justified by the manifest's functional description and is not disclosed there.
The workflow explicitly performs curl HEAD/GET requests and stores remote content in a temporary directory, but it does not require a user-facing notice that the provided URL will be fetched by the backend and that remote content will be transmitted through system infrastructure. This can create privacy and security issues, especially if users supply internal, sensitive, or authenticated URLs, because the agent may initiate unintended network access and retrieve potentially sensitive content.
SQP-3 适用于所有文件。该文档整体以中文定义技能名称、用户意图和触发场景,但没有说明这是面向中文用户的特定区域技能,也没有提供用户语言选择或多语言兼容说明,存在默认强制单一语言/locale 的自然语言策略风险。
Detected: suspicious.env_credential_access, suspicious.exposed_secret_literal