T09 · Insecure Skill Coding Practices
- Location
notes/scripts/debug_cred.js:6- Finding
IMA Client ID Disclosed Through Debug Logging
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This IMA notes and knowledge-base skill is mostly purpose-aligned, but it ships undeclared debug scripts and credential-handling patterns that can expose account identifiers, private note data, or temporary upload credentials.
Review before installing. This skill can read and modify private IMA notes, upload local files or URLs to a remote knowledge base, and use persistent IMA credentials. Avoid running the bundled debug scripts, remove them if possible, store credentials with strict file permissions, and confirm the exact destination knowledge base before any upload, import, create, or append operation.
notes/scripts/debug_cred.js:6IMA Client ID Disclosed Through Debug Logging
notes/scripts/debug_cred.js:24Undocumented Access to Credentials From Another Skill Installation Path
notes/scripts/debug_search.js:22Private Note Search Results, Content Previews, and Internal IDs Exposed in Output
knowledge-base/SKILL.md:179Temporary Tencent COS Credentials Exposed in Process Arguments
SKILL.md:35Credential Setup Instructions Do Not Enforce Restrictive Filesystem Permissions
knowledge-base/SKILL.md:162Filesystem-Derived Filenames Are Inserted Into JSON Without Serialization
声明描述的是面向笔记和知识库管理的统一技能能力,但提供的代码片段并未实现任何笔记创建、编辑、搜索、文件上传或知识库检索逻辑。相反,它专门从环境变量和本地文件系统位置(如 ~/.config/ima/client_id、技能目录 .env)读取 CLIENT_ID,并将其打印到控制台,属于凭据发现/调试行为。这是与声明用途 materially different 的主要功能,并且涉及对本地敏感配置资源的访问和输出,均未在描述中体现,因此应判定为描述与实际行为不匹配。
The trigger conditions are very broad and include common phrases like '帮我记一下' and general personal document access intents. This can cause the skill to activate on routine conversations and route user content or files into an external service when the user may not have intended to invoke this integration.
The script prints the CLIENT_ID value obtained from the environment or local files directly to stdout, along with paths being checked. Even if a client ID is not a full secret, exposing credential-like identifiers in logs or terminal output can leak sensitive configuration to other users, log collectors, crash reports, or support transcripts and facilitate credential abuse.
The script explicitly reads a .env file from a local skill directory to extract IMA_CLIENT_ID, which is classic credential-access behavior. In a user-facing notes skill, probing local secret stores is more dangerous because it is unrelated to user intent and may normalize access patterns that can be extended to more sensitive secrets later.
if (!CLIENT_ID) {
try {
const skillEnv = path.join(process.env.USERPROFILE, '.workbuddy', 'skills', 'ima笔记', 'notes', '.env');
console.log('Checking skill env:', skillEnv);
const envContent = fs.readFileSync(skillEnv, 'utf8');
const match = envContent.match(/IMA_CLIENT_ID\s*=\s*(.+)/);
Reading a .env file from another local skill path to extract IMA_CLIENT_ID is credential access behavior and exceeds what is necessary for a simple note-search debug script. This creates a path for unintended secret harvesting from developer or user workspaces, and the extracted credential is then used in outbound API authentication.
}
if (!CLIENT_ID) {
try {
const skillEnv = path.join(process.env.USERPROFILE, '.workbuddy', 'skills', 'ima笔记', 'notes', '.env');
const envContent = fs.readFileSync(skillEnv, 'utf8');
const match = envContent.match(/IMA_CLIENT_ID\s*=\s*(.+)/);
if (match) CLIENT_ID = match[1].trim();
The script attempts to read credentials from a separate skill-specific .env path under the user's home directory, expanding the credential search surface beyond standard environment variables or a dedicated config store. In a skill/plugin context, this cross-directory secret harvesting behavior is risky because it can access credentials from another installation location without explicit user consent, and the same pattern could be extended to collect additional secrets.
// 从 ima 技能配置读取
if (!CLIENT_ID) {
try {
const skillEnv = path.join(process.env.USERPROFILE, '.workbuddy', 'skills', 'ima笔记', 'notes', '.env');
const envContent = fs.readFileSync(skillEnv, 'utf8');
const match = envContent.match(/IMA_CLIENT_ID\s*=\s*(.+)/);
if (match) CLIENT_ID = match[1].trim();
Without declared permissions the skill's intent is opaque and cannot be validated.
The natural-language description is written to prescribe activation behavior entirely in Chinese and provides no indication that users may choose another language or locale. Under the stated policy, forcing a specific language without user opt-in is a locale-policy violation unless the constraint is explicitly justified, which is not documented here.
This duplicate finding points to the same credential-persistence behavior: storing long-lived API secrets in plaintext or exported session variables. While environment variables are common, combining them with documented plaintext file fallback broadens the chance of credential leakage across sessions and tooling.
方式 A — 配置文件(推荐):
mkdir -p ~/.config/ima
echo "your_client_id" > ~/.config/ima/client_id
echo "your_api_key" > ~/.config/ima/api_key
This duplicate finding points to the same credential-persistence behavior: storing long-lived API secrets in plaintext or exported session variables. While environment variables are common, combining them with documented plaintext file fallback broadens the chance of credential leakage across sessions and tooling.
方式 A — 配置文件(推荐):
mkdir -p ~/.config/ima
echo "your_client_id" > ~/.config/ima/client_id
echo "your_api_key" > ~/.config/ima/api_key
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
# All requests go ONLY to the official IMA API (ima.qq.com)
ima_api() {
local path="$1" body="$2"
curl -s -X POST "https://ima.qq.com/$path" \
-H "ima-openapi-clientid: $IMA_CLIENT_ID" \
-H "ima-openapi-apikey: $IMA_API_KEY" \
-H "Content-Type: application/json" \
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 description and all operational instructions are presented in Chinese, and the document does not indicate that users may choose another language or locale. This can constitute a language-policy violation when a skill effectively constrains interaction to a specific language without explicit opt-in or justification.
The document instructs callers to send long-lived API credentials (ima-openapi-clientid, ima-openapi-apikey) and later exposes temporary COS secrets (secret_id, secret_key, token) but never warns that these values are sensitive, must not be logged, echoed to users, or embedded in client-side code. In a skill context, this omission increases the chance that an agent or integrator mishandles credentials, leading to unauthorized access to the knowledge base or uploaded objects.
The quick-decision flow directs the agent to upload files, import URLs, and add knowledge to a remote knowledge base, but it does not clearly warn that these are write operations that permanently transmit user content to external storage and may affect shared repositories. In this skill, that matters because users may phrase requests casually ('帮我记一下', upload/search notes), making unintended exfiltration or modification of personal or organizational data more likely if consent is not explicit.
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.
### MediaType(媒体类型枚举)
| 值 | 名称 | content_type / 说明 |
| --- | -------------- | ------------------------------------------------------------------------------------------------------------- |
| 1 | PDF | `application/pdf` |
| 2 | 网页 | N/A(直接 AddKnowledge,`web_info.content_id=<url>`) |
The main skill instructions are written as normative behavior in Chinese, with no indication that another language may be used if the user prefers. Under the policy, forcing a specific language or locale without opt-in is a natural-language policy violation unless the constraint is documented and justified.
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.
## 接口决策表
| 用户意图 | 调用接口 | 关键参数 |
| --------------------------------------------------------------------------------------------------------- | ---------------------------- | ----------------------------------------------------------------------------- |
| 搜索/查找笔记 | `search_note_book` | `query_info`(QueryInfo 对象) |
| 查看笔记本列表 | `list_note_folder_by_cursor` | `cursor`(必填,首页传`"0"`) + `limit`(必填) |
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.
## 接口决策表
| 用户意图 | 调用接口 | 关键参数 |
| --------------------------------------------------------------------------------------------------------- | ---------------------------- | ----------------------------------------------------------------------------- |
| 搜索/查找笔记 | `search_note_book` | `query_info`(QueryInfo 对象) |
| 查看笔记本列表 | `list_note_folder_by_cursor` | `cursor`(必填,首页传`"0"`) + `limit`(必填) |
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.
| 用户意图 | 调用接口 | 关键参数 |
| --------------------------------------------------------------------------------------------------------- | ---------------------------- | ----------------------------------------------------------------------------- |
| 搜索/查找笔记 | `search_note_book` | `query_info`(QueryInfo 对象) |
| 查看笔记本列表 | `list_note_folder_by_cursor` | `cursor`(必填,首页传`"0"`) + `limit`(必填) |
| 浏览某笔记本里的笔记,当用户表述"最新"、"最近"之类的通用限定,没有指明笔记本时,都应该直接在全部笔记里去拉 | `list_note_by_folder_id` | `folder_id`(选填,空为全部笔记本) + `cursor`(必填,首次传`""`) + `limit`(必填) |
| 读取笔记正文 | `get_doc_content` | `doc_id` + `target_content_format`(必填,推荐`0`纯文本) |
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.
| 用户意图 | 调用接口 | 关键参数 |
| --------------------------------------------------------------------------------------------------------- | ---------------------------- | ----------------------------------------------------------------------------- |
| 搜索/查找笔记 | `search_note_book` | `query_info`(QueryInfo 对象) |
| 查看笔记本列表 | `list_note_folder_by_cursor` | `cursor`(必填,首页传`"0"`) + `limit`(必填) |
| 浏览某笔记本里的笔记,当用户表述"最新"、"最近"之类的通用限定,没有指明笔记本时,都应该直接在全部笔记里去拉 | `list_note_by_folder_id` | `folder_id`(选填,空为全部笔记本) + `cursor`(必填,首次传`""`) + `limit`(必填) |
| 读取笔记正文 | `get_doc_content` | `doc_id` + `target_content_format`(必填,推荐`0`纯文本) |
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.
| 用户意图 | 调用接口 | 关键参数 |
| --------------------------------------------------------------------------------------------------------- | ---------------------------- | ----------------------------------------------------------------------------- |
| 搜索/查找笔记 | `search_note_book` | `query_info`(QueryInfo 对象) |
| 查看笔记本列表 | `list_note_folder_by_cursor` | `cursor`(必填,首页传`"0"`) + `limit`(必填) |
| 浏览某笔记本里的笔记,当用户表述"最新"、"最近"之类的通用限定,没有指明笔记本时,都应该直接在全部笔记里去拉 | `list_note_by_folder_id` | `folder_id`(选填,空为全部笔记本) + `cursor`(必填,首次传`""`) + `limit`(必填) |
| 读取笔记正文 | `get_doc_content` | `doc_id` + `target_content_format`(必填,推荐`0`纯文本) |
| 新建一篇笔记(用户明确说"新建/创建笔记"时走此接口) | `import_doc` | `content` + `content_format`(必填,固定`1`) + 可选 `folder_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.
| 搜索/查找笔记 | `search_note_book` | `query_info`(QueryInfo 对象) |
| 查看笔记本列表 | `list_note_folder_by_cursor` | `cursor`(必填,首页传`"0"`) + `limit`(必填) |
| 浏览某笔记本里的笔记,当用户表述"最新"、"最近"之类的通用限定,没有指明笔记本时,都应该直接在全部笔记里去拉 | `list_note_by_folder_id` | `folder_id`(选填,空为全部笔记本) + `cursor`(必填,首次传`""`) + `limit`(必填) |
| 读取笔记正文 | `get_doc_content` | `doc_id` + `target_content_format`(必填,推荐`0`纯文本) |
| 新建一篇笔记(用户明确说"新建/创建笔记"时走此接口) | `import_doc` | `content` + `content_format`(必填,固定`1`) + 可选 `folder_id` |
| 往已有笔记追加内容(⚠️ **敏感操作**:用户必须明确指定目标笔记,否则先确认再操作) | `append_doc` | `doc_id` + `content` + `content_format`(必填,固定`1`) |
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.
#### SearchedDoc
| 字段 | 类型 | 说明 |
| ---------------- | --------------------- | ------------------------------------------------------------------------------------------ |
| `doc` | DocBasicInfo | 笔记 basic 数据,见 [DocBasicInfo](#docbasicinfo) |
| `highlight_info` | map\<string, string\> | 该条笔记匹配的高亮词,key: `doc_title`(文档标题),value: 包含 `<em>高亮词</em>` 的字段值 |
The trigger guidance for search includes the very broad term “搜索”, which can match many unrelated user requests and cause the agent to invoke the notes skill outside a clearly bounded notes/knowledge-base context. In a privacy-sensitive skill that can enumerate or search personal notes, overbroad routing increases the chance of unintended access to private user content or unnecessary transmission of queries to the notes backend.