Back to skill

Security audit

Feishu Group Helper

Security checks for vulnerabilities and agentic risk

Overview

This Feishu group helper mostly matches its stated purpose, but it needs review because its helper code can be redirected to read or overwrite arbitrary local JSON files.

Install only if you trust the skill operator and are comfortable with it using Feishu message-sending permissions and storing group metadata locally. Before broader use, constrain the group registry file to the agent workspace, add confirmation before sending messages to groups, and provide a way to review and delete stored group records.

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 (1)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/groupManager.js:17
Finding
Unrestricted Caller-Controlled Filesystem Access## Vulnerability Details **File Location**: `scripts/groupManager.js`, lines 17–72 **Vulnerability Type**: Arbitrary file read, file overwrite, and directory creation through an unrestricted path **Risk Level**: Medium ### Vulnerable Code ```javascript let GROUPS_FILE = path.join(process.cwd(), 'feishu-groups.json'); /** * 设置群信息文件路径 * @param {string} customPath - 自定义路径 */ function setGroupsFilePath(customPath) { if (customPath) { GROUPS_FILE = customPath; } } /** * 获取当前群信息文件路径 * @returns {string} */ function getGroupsFilePath() { return GROUPS_FILE; } /** * 初始化群信息文件 * @param {string} customPath - 可选的自定义路径 */ function initGroupsFile(customPath) { const filePath = customPath || GROUPS_FILE; if (!fs.existsSync(filePath)) { // 确保目录存在 const dir = path.dirname(filePath); if (!fs.existsSync(dir)) { fs.mkdirSync(dir, { recursive: true }); } const initialData = { groups: {}, updated_at: new Date().toISOString() }; fs.writeFileSync(filePath, JSON.stringify(initialData, null, 2)); console.log(`[群管理] 初始化群信息文件: ${filePath}`); } return JSON.parse(fs.readFileSync(filePath, 'utf8')); } /** * 读取群信息 * @param {string} customPath - 可选的自定义路径 */ function getGroups(customPath) { const filePath = customPath || GROUPS_FILE; initGroupsFile(filePath); return JSON.parse(fs.readFileSync(filePath, 'utf8')); } /** * 保存群信息 * @param {object} data - 群信息数据 * @param {string} customPath - 可选的自定义路径 */ function saveGroups(data, customPath) { const filePath = customPath || GROUPS_FILE; data.updated_at = new Date().toISOString(); fs.writeFileSync(filePath, JSON.stringify(data, null, 2)); } ``` ### Technical Analysis The module accepts an unrestricted `customPath` and also exposes `setGroupsFilePath()`, which permanently changes the module-level storage target. The supplied path is not normaliz ...[truncated 2762 chars]
Remediation
## Remediation Suggestions 1. Remove public `customPath` parameters from ordinary group-management functions unless they are strictly required. 2. Establish one trusted storage root, such as the current agent's workspace, and resolve every requested path relative to that root. 3. Canonicalize and validate the target before access: ```javascript const STORAGE_ROOT = path.resolve(process.env.AGENT_WORKSPACE); const DEFAULT_FILE = path.join(STORAGE_ROOT, 'feishu-groups.json'); function validateGroupsPath(candidate = DEFAULT_FILE) { const resolved = path.resolve(candidate); const relative = path.relative(STORAGE_ROOT, resolved); if (relative.startsWith('..') || path.isAbsolute(relative)) { throw new Error('Groups file must remain inside the agent workspace'); } return resolved; } ``` 4. Reject symbolic links and non-regular files. Validate existing path components with `fs.lstatSync()` and compare canonical paths using `fs.realpathSync()` before reading or replacing a target. 5. Create the storage directory and file with restrictive permissions, such as directory mode `0700` and file mode `0600`. 6. Use atomic writes: write to a securely created temporary file in the same validated directory, flush it, and rename it over the destination. 7. Validate the loaded JSON schema before using or modifying it. Require `groups` to be a plain object and validate each stored field. 8. Avoid returning raw contents from arbitrary storage targets and sanitize filesystem errors before exposing them to untrusted callers. 9. Add tests covering absolute paths, `../` traversal, symbolic links, missing parent directories, malformed JSON, and attempts to target files outside the workspace.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (4)

Vague Triggers

Medium
Confidence
95% confidence
Finding
The trigger phrases are broad and overlap with ordinary conversational language about groups, joining, removing, or sending messages. This can cause the skill to activate unintentionally and perform side-effecting actions such as querying group metadata or sending messages without a clearly scoped user intent, which is especially risky because the skill also writes persistent local state and can initiate external communications.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The skill describes sending messages to Feishu groups and maintaining a persistent local group registry, but it does not require explicit user-facing notice or confirmation before external message delivery or storage updates. Users may not realize that their request can cause outbound communication to third parties and durable storage of group identifiers and metadata, creating privacy, consent, and unintended-action risks.

Missing User Warnings

Low
Confidence
84% confidence
Finding
The event-listening upgrade introduces ingestion of external Feishu event data and automated processing paths, but the skill text does not warn that outside systems can trigger state changes via callbacks. Even though this section is framed as a future upgrade, automatic handling of group add/remove events increases the attack surface and can lead to silent local state changes if event provenance, validation, and user awareness are not addressed.

Natural-Language Policy Violations

Low
Confidence
92% confidence
Finding
The file-level comments and usage guidance are written only in Chinese, and there is no indication that this skill is intended exclusively for a Chinese-speaking or region-specific environment. Under the policy, forcing a specific language without user opt-in or justification is a natural-language locale violation.

Static analysis

No suspicious patterns detected.