Back to skill

Security audit

Tianshu Image

Security checks for vulnerabilities and agentic risk

Overview

This image-generation skill does what it claims, but its optional save path can overwrite arbitrary local files and it accepts API keys through command-line arguments.

Install only if you are comfortable sending prompts to Alibaba DashScope and using a DashScope API key. Prefer DASHSCOPE_API_KEY over --api-key, avoid sensitive prompt content, and only use --filename with a clearly safe output path because the current script can overwrite existing writable files.

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

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/generate_image.js:115
Finding

Arbitrary Local File Overwrite Through Unrestricted Output Path

Content
View full analysis

Vulnerability Details

File Location: scripts/generate_image.js, lines 115-120
Vulnerability Type: Unrestricted file write and overwrite
Risk Level: Medium

Vulnerable Code:

javascript
if (opts.filename) {
  const dir = path.dirname(opts.filename);
  if (dir && !fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
  const imgRes = await fetch(imageUrl);
  const buf = Buffer.from(await imgRes.arrayBuffer());
  fs.writeFileSync(opts.filename, buf);

Technical Analysis

The --filename argument is used directly as a filesystem path without normalization, containment checks, an allowed output directory, or overwrite protection. The code also creates missing parent directories recursively. Consequently, an invocation can target any path writable by the operating-system account running the skill.

fs.writeFileSync() overwrites an existing file by default. The downloaded response is written without validating the HTTP status, MIME type, or maximum response size. This can result in unexpected content being stored or excessive memory and disk consumption.

Attack Path

  1. An attacker supplies task content that causes the agent or user to invoke the skill with an attacker-selected --filename value.
  2. The value identifies a sensitive file writable by the skill process, potentially using an absolute path or path traversal.
  3. The script creates missing parent directories where permitted.
  4. It downloads the URL returned by the image-generation service into memory.
  5. fs.writeFileSync() creates or overwrites the selected file without confirmation.
  6. Subsequent applications may consume the corrupted or replaced file.

Impact Assessment

Exploitation does not grant privileges beyond those of the process running the skill. Within those privileges, it can overwrite user-owned configuration files, scripts, documents, or other writable resources. This may cause data loss ...[truncated 269 chars]

Remediation
View remediation

Remediation Suggestions

  • Store generated images only in a dedicated output directory with restrictive permissions.
  • Resolve the requested path using path.resolve() and verify that it remains beneath the approved directory.
  • Reject absolute paths, traversal components, symbolic-link escapes, and special files.
  • Generate server-side filenames rather than accepting unrestricted paths.
  • Use exclusive file creation, such as the wx flag, unless overwrite is explicitly requested and confirmed.
  • Validate imgRes.ok, enforce an allowlist of image MIME types, and reject redirects to untrusted schemes or destinations where appropriate.
  • Stream the response to disk while enforcing strict download and output-size limits instead of loading the entire response into memory.
  • Write to a securely created temporary file and atomically rename it after validation.

T09 · Insecure Skill Coding Practices

Note
Location
scripts/generate_image.js:43
Finding

API Credential Exposure Through Command-Line Arguments

Content
View full analysis

Vulnerability Details

File Location: scripts/generate_image.js, lines 43-44
Vulnerability Type: Sensitive credential exposure
Risk Level: Low

Vulnerable Code:

javascript
} else if (args[i] === '--api-key' || args[i] === '-k') {
  opts.apiKey = args[++i];

Technical Analysis

The script accepts the DashScope API key directly through --api-key or -k. Command-line arguments can be retained in shell history, agent execution traces, process-monitoring systems, debugging output, audit logs, or process listings available to other local users, depending on the operating system and runtime environment.

The credential is therefore exposed through a less secure secret-delivery channel even though the script also supports the DASHSCOPE_API_KEY environment variable.

Attack Path

  1. A user or agent invokes the script with --api-key SECRET or -k SECRET.
  2. The complete command is recorded in shell history, orchestration logs, agent traces, or process metadata.
  3. A local user or log reader with access to one of those sources retrieves the API key.
  4. The exposed credential is used to make unauthorized DashScope API requests until it is revoked or expires.

Impact Assessment

An attacker obtaining the key can act within the permissions and quotas assigned to that DashScope credential. Potential consequences include unauthorized image-generation requests, quota exhaustion, unexpected charges, and access to other API capabilities available to the same key.

This issue does not itself provide operating-system privilege escalation. Its scope is limited by the compromised credential's service-side permissions.

Remediation
View remediation

Remediation Suggestions

  • Remove support for supplying credentials through command-line arguments.
  • Obtain the key from a protected environment variable, restricted configuration file, operating-system credential store, or dedicated secret manager.
  • Ensure agent and process logs redact authorization credentials and secret-related environment values.
  • Apply least privilege and service-side quota limits to the DashScope key.
  • Rotate the key immediately if it has previously appeared in command history or logs.
  • Document secure credential configuration without showing command examples that embed secrets.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (7)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
95% confidence
Finding

The skill declares required environment variables and documents networked API usage, but it does not declare an explicit tool scope such as permissions or allowed-tools. That creates an authorization ambiguity where a runtime or orchestrator may permit broader environment or network access than users expect, weakening least-privilege guarantees.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

The natural-language trigger examples and usage guidance are written as Chinese-only user utterances such as 「画一张」「生成图片」「文生图」, with no indication that other languages are supported or that the skill is intentionally restricted to a Chinese locale. Under the stated policy, forcing a specific language without user opt-in or justification is a policy concern.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The description includes very broad activation cues such as '画一张' and '生成图片', which are common phrases in ordinary conversation and can cause the skill to trigger unintentionally. In an agent environment, overlapping triggers may lead to misrouting of user requests, unintended API calls, and unnecessary consumption of the configured DashScope API quota.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file's docstring and CLI messages are written only in Chinese, with no option to select another language or indication that the skill is intentionally region-specific. This creates a natural-language policy concern because it imposes a locale/language choice on users without opt-in.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
70% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · scripts/generate_image.js (reported line 82)May include surrounding context.

js
const timeout = setTimeout(() => controller.abort(), 120000);

  try {
    const res = await fetch(
      'https://dashscope.aliyuncs.com/api/v1/services/aigc/multimodal-generation/generation',
      {
        method: 'POST',

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The documentation instructs users to provide an arbitrary --filename local path and states that the script will save output there, but it does not warn that this writes to the local filesystem. In an agent context, undocumented file creation or overwrite behavior can surprise users and may lead to unintended modification of local files if paths are not carefully controlled.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

This code transmits the user's prompt content to DashScope over the network, which can affect privacy if prompts contain sensitive data. While the header comment states the API used, there is no runtime disclosure, confirmation, or explicit warning that user-supplied text will be sent to a third-party service.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.