Back to skill

Security audit

File Transfer

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly a coherent simulated file-transfer library, but it needs Review because it exposes an overbroad file-deletion helper and has misleading file-transfer behavior.

Install only after reviewing how your agent will expose file paths. Do not pass untrusted paths to cleanupTempFile, and treat transfer examples as simulated until a real Telegram integration is implemented with explicit user confirmation and privacy disclosure.

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

Error
Location
src/core/file-manager.js:141
Finding
Unrestricted File Deletion Through Temporary-File Cleanup API## Vulnerability Details **File Location**: `src/core/file-manager.js`, lines 141–145 **Vulnerability Type**: Arbitrary file deletion / insufficient path validation **Risk Level**: High ### Vulnerable Code ```javascript async cleanupTempFile(filePath) { try { await fs.unlink(filePath); return true; } catch (error) { console.warn(`Failed to cleanup temp file ${filePath}: ${error.message}`); return false; } } ``` ### Technical Analysis `cleanupTempFile()` is documented as deleting a temporary file, but it passes the caller-controlled `filePath` directly to `fs.unlink()` without verifying that the target is inside the configured temporary directory. No canonicalization, ownership tracking, filename allowlist, or path-boundary check is performed. Consequently, an absolute path such as `/home/service/config.json`, or a traversal path escaping the temporary directory, can target any file writable by the Node.js process. The method is part of the exported `FileManager` public interface. Its documentation in `docs/API.md` also accepts a general `filePath`, so callers may invoke this primitive directly. Symbolic links and filesystem path aliases may further undermine a simple lexical prefix check unless the implementation resolves and validates canonical paths. ### Attack Path 1. An attacker obtains influence over the argument passed to `FileManager.cleanupTempFile()`. This may occur when an integrating agent, API, or application exposes the cleanup operation to untrusted input. 2. The attacker supplies the absolute path of a writable non-temporary file, for example: ```javascript await manager.cleanupTempFile('/home/service/app-config.json'); ``` 3. The method passes that path directly to `fs.unlink()`. 4. Node.js deletes the target using the host process's filesystem privileges. 5. The attacker may repeat the operation against application data, configuration, logs, or other writable files. The repository does not itself expo ...[truncated 805 chars]
Remediation
## Remediation Suggestions Restrict cleanup to files created and tracked by this `FileManager` instance: 1. Resolve the configured temporary directory and candidate path to absolute canonical paths. 2. Reject targets outside the temporary-directory boundary. Use `path.relative()` rather than a raw string-prefix check. 3. Track paths returned by `createTempFile()` in a private set and only permit deletion of tracked entries. 4. Use unpredictable, securely generated filenames, such as `crypto.randomUUID()`. 5. Consider opening and creating temporary files with exclusive semantics and restrictive permissions. 6. Remove a path from the tracking set only after successful deletion. 7. Add tests covering absolute external paths, `../` traversal, prefix-confusion paths, and symbolic links. Example hardening pattern: ```javascript import path from 'path'; import fs from 'fs/promises'; async cleanupTempFile(filePath) { try { const tempRoot = await fs.realpath(this.config.tempDir); const candidate = path.resolve(filePath); const parent = await fs.realpath(path.dirname(candidate)); const resolvedTarget = path.join(parent, path.basename(candidate)); const relative = path.relative(tempRoot, resolvedTarget); if ( relative === '' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative) ) { throw new Error('Refusing to delete a file outside the temporary directory'); } if (!this.createdTempFiles?.has(resolvedTarget)) { throw new Error('Refusing to delete an untracked temporary file'); } await fs.unlink(resolvedTarget); this.createdTempFiles.delete(resolvedTarget); return true; } catch (error) { console.warn(`Temporary-file cleanup failed: ${error.message}`); return false; } } ``` For stronger symbolic-link protection, create and manage a dedicated private temporary directory with restrictive permissions and avoid following attacker-controlled links. The integration la ...[truncated 71 chars]
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (43)

Self-Modification

High
Category
Rogue Agent
Content
### `configure(newConfig)` -> `void`

Update skill configuration. Reinitializes channels if channel config changes.

### `getStatus()` -> `Object`
Confidence
85% confidence
Finding
Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Direct Prompt Extraction

High
Category
System Prompt Leakage
Content
determineUrgency(context, scenario) {
    const rule = this.scenarioRules[scenario];
    if (rule) {
      return rule.urgency;
    }
    
    // 基于文件大小和聊天类型
Confidence
85% confidence
Finding
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Direct Prompt Extraction

High
Category
System Prompt Leakage
Content
determineUrgency(context, scenario) {
    const rule = this.scenarioRules[scenario];
    if (rule) {
      return rule.urgency;
    }
    
    // 基于文件大小和聊天类型
Confidence
85% confidence
Finding
Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Intent-Code Divergence

High
Confidence
98% confidence
Finding
The function is advertised and structured as chunked file reading, but it never opens or reads the target file and instead returns synthetic buffers. In any workflow that depends on this method for file transfer, scanning, hashing, upload, or integrity-sensitive processing, the system may operate on fake data while reporting success, causing silent data corruption and bypass of downstream security or business controls.

Vague Triggers

Medium
Confidence
90% confidence
Finding
The README describes the skill in broad, capability-oriented terms such as 'context-aware file transfer' and 'intelligently transfers files based on conversation context' without clearly defining exact user-triggered actions, guardrails, or exclusions. In an agent ecosystem, ambiguous activation and intent inference can cause the skill to be invoked in situations the user did not explicitly authorize, increasing the risk of unintended file disclosure.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The README promotes sending files using chat context and external messaging adapters but does not warn that file contents, captions, chat identifiers, and contextual metadata may be transmitted to third-party messaging platforms. This omission can lead users or integrators to underestimate privacy and data handling risks, resulting in accidental exposure of sensitive files or metadata to external channels.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The skill handles file paths, captions, and chat context for transfer to an external channel, but the documentation does not warn users that sensitive files and conversation metadata may be disclosed outside the local environment. In an agent setting, this can cause accidental exfiltration of confidential documents or context-derived data if users or downstream systems assume the action is purely local or low-risk.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The documentation encourages sending files together with contextual metadata to Telegram without any privacy warning, consent guidance, or data minimization note. In a file-transfer skill, this increases the likelihood that operators will transmit sensitive content or identifiers to third-party messaging infrastructure without understanding the disclosure implications.

Missing User Warnings

Medium
Confidence
89% confidence
Finding
The context analysis API processes message history, user information, and chat metadata, all of which may contain sensitive personal or confidential data, but the documentation omits any warning about privacy exposure. This is dangerous because implementers may ingest or forward more conversational data than necessary, creating unnecessary collection, retention, or downstream disclosure risk.

Intent-Code Divergence

Medium
Confidence
94% confidence
Finding
The section presents TelegramAdapter as a component that sends files to Telegram chats and documents concrete Telegram-specific parameters and return values. However, the final note explicitly states that the current implementation merely simulates file transfer, which contradicts the earlier functional description rather than simply omitting detail.

Natural-Language Policy Violations

Medium
Confidence
92% confidence
Finding
该贡献指南从标题开始即完全以中文呈现,未说明这是面向特定中文用户群体的区域性文档,也未提供其他语言选项。根据语言/区域政策,强制单一语言而没有用户选择或合理限定,属于自然语言层面的策略风险。

Missing User Warnings

Medium
Confidence
92% confidence
Finding
This example code automatically transmits a locally created file to hardcoded Telegram chat IDs, including what appears to be a group chat, without any interactive confirmation, dry-run mode, or prominent warning that it will perform an outbound transfer. In skill or agent contexts, example code is often copied into real workflows, so this pattern normalizes silent exfiltration of local files to external recipients and increases the risk of accidental data disclosure.

Intent-Code Divergence

Medium
Confidence
96% confidence
Finding
The module documentation says it is responsible for uploading files to Telegram and sending/replying to messages. In the actual implementation, `sendFile` only validates the file, analyzes context, stores transfer state, and runs a timed loop labeled as a simulated transfer; it explicitly notes that the real implementation would call the Telegram API later.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The natural-language documentation and user-visible messages in this file are Chinese-only, which can impose a language choice on users or operators without opt-in. The policy allows locale constraints only when they are explicitly justified or when users are offered a language choice, neither of which appears here.

Intent-Code Divergence

Medium
Confidence
98% confidence
Finding
The method contract promises a real file send operation to Telegram. However, lines L136-L159 simulate progress with delays and generate a synthetic `messageId` using `Date.now()` rather than obtaining one from Telegram, so the code contradicts the documented behavior.

Natural-Language Policy Violations

Medium
Confidence
89% confidence
Finding
This code file’s natural-language documentation is written exclusively in Chinese, including the module description and behavioral summaries. Under the policy provided, forcing a specific language without user opt-in or a documented regional justification is a natural-language policy violation.

Natural-Language Policy Violations

Medium
Confidence
91% confidence
Finding
This code file contains natural-language comments and returned error messages exclusively in Chinese, including messages that would likely surface to users during validation failures. Under the policy, forcing a specific language without user opt-in or documented justification is a locale policy violation.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
This code sends a local file and associated context-derived data to a selected channel adapter, which is a network/data-transmission operation. Although the method name suggests transfer functionality, there is no visible confirmation prompt, user-facing disclosure, or warning here that user data and file contents may be transmitted externally.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
This test invokes `adapter.sendFile` with a real-looking Telegram `chatId`, which represents a network transmission of local file contents to an external service. While it is a test, the surrounding code provides no user-facing disclosure, confirmation, or warning that file data will be transmitted off-system.

Missing User Warnings

Medium
Confidence
88% confidence
Finding
These `sendFile` calls send a local file to specified Telegram chat IDs, but the code does not display any confirmation, warning, or user-facing log about the outbound transfer. Network transmission of local file contents is safety-relevant and should be disclosed when not otherwise obvious to the runner.

Missing User Warnings

Medium
Confidence
87% confidence
Finding
The integration test uploads a local file through `adapter.sendFile`, but there is no warning in the code indicating that test execution may send file contents to an external Telegram destination. This creates an undisclosed data-transfer behavior for anyone running the test suite.

Missing User Warnings

Medium
Confidence
87% confidence
Finding
These tests send the same local file to both group and private Telegram chat IDs, which means the suite may transmit data externally multiple times. There is no visible confirmation prompt, user-facing log, or warning comment indicating this behavior.

Natural-Language Policy Violations

Medium
Confidence
93% confidence
Finding
This file uses natural-language comments and test case descriptions exclusively in Chinese, with no indication that the project or skill is intentionally limited to a Chinese-speaking audience. Per the policy, forcing a specific language without user opt-in or documented justification is a locale/language policy violation.

Intent-Code Divergence

Low
Confidence
82% confidence
Finding
The features section says there is 'Full adapter with progress tracking (simulated)', and the limitations section later states there is 'no real API integration yet'. However, the direct usage example and sendFileWithContext example are written as if real transfers occur and return message IDs, which creates contradictory intent signals in the documentation.

Natural-Language Policy Violations

Low
Confidence
90% confidence
Finding
该开发文档从标题到正文均仅以中文编写,未说明这是面向特定中文团队的限定文档,也未提供其他语言版本或语言选择。根据规则,强制单一语言而无用户选择或明确、合理的区域性说明,属于自然语言政策风险。

Static analysis

No suspicious patterns detected.