Back to skill

Security audit

Kay Image

Security checks for vulnerabilities and agentic risk

Overview

The skill appears to be a legitimate AI image tool, but it under-discloses some external routing and lets environment variables redirect API-key-bearing requests to arbitrary endpoints.

Install only if you are comfortable sending prompts and selected images/videos to cloud AI providers. Use clean, trusted environment variables, avoid setting custom *_BASE_URL values, and do not submit confidential or regulated media unless provider handling is acceptable. Prefer a version that declares all credentials/providers and validates API destinations.

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
scripts/main.ts:539
Finding

Environment-Controlled API Base URLs Can Expose Bearer Credentials and User Content

Content
View full analysis

Vulnerability Details

File Location: scripts/main.ts:19-27, scripts/main.ts:305-311, and scripts/main.ts:539-563
Vulnerability Type: Unvalidated destination for sensitive network requests
Risk Level: High

The application accepts API base URLs directly from environment variables without enforcing HTTPS or validating the destination hostname. It then sends provider bearer credentials, prompts, and potentially local image or video contents to the resulting endpoint.

ts
// API Configuration
const KIE_API_BASE = process.env.KIE_BASE_URL || "https://api.kie.ai";
const KIE_API_KEY = process.env.KIE_API_KEY;

const LAOZHANG_API_BASE = process.env.LAOZHANG_BASE_URL || "https://api.laozhang.ai/v1";
const LAOZHANG_API_KEY = process.env.LAOZHANG_API_KEY;

// API Source for understanding mode
const UNDERSTANDING_API_BASE = process.env.KIE_UNDERSTANDING_BASE_URL || "https://api.kie.ai";
const UNDERSTANDING_API_KEY = process.env.KIE_UNDERSTANDING_API_KEY;

The generation request sends the KIE credential to the environment-selected destination:

ts
const response = await fetch(url, {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${KIE_API_KEY}`,
  },
  body: JSON.stringify(body),
});

The understanding request similarly selects an unvalidated base URL and sends the corresponding credential and request body:

ts
// Determine API endpoint and credentials
const apiBase = useLaozhang ? LAOZHANG_API_BASE : UNDERSTANDING_API_BASE;
const apiKey = useLaozhang ? LAOZHANG_API_KEY : UNDERSTANDING_API_KEY;
const apiName = useLaozhang ? "LaoZhang" : "KIE";

// Call API
const url = `${apiBase}/v1/chat/completions`;
const body = {
  model: model,
  messages: [
    {
      role: "user",
      content: content,
    },
  ],
  max_tokens: parseInt(values["max-tokens"] || "1000"),
};

console.log(`\n📡 Sending request 
...[truncated 3192 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove configurable API base URLs if custom endpoints are not an essential feature. Use fixed constants for the documented KIE and LaoZhang origins.
  2. If endpoint overrides are required, parse each value with new URL() and reject invalid URLs.
  3. Require the https: scheme and reject URLs containing embedded user information.
  4. Maintain an exact allowlist of approved origins, such as https://api.kie.ai and https://api.laozhang.ai. Avoid suffix-based checks that could accept domains such as api.kie.ai.attacker.example.
  5. Bind each credential to its expected origin. Never attach a KIE credential to a LaoZhang origin, a custom origin, or any other unapproved destination.
  6. Disable automatic redirects for authenticated calls with redirect: "error", or manually inspect every redirect and remove the Authorization header unless the destination remains the exact approved origin.
  7. Validate the final request URL immediately before every authenticated fetch, including task creation, task polling, and understanding requests.
  8. Fail closed with a clear error if validation fails; do not silently fall back to an untrusted endpoint.
  9. Document that understanding mode uploads explicitly selected local images and videos to a third-party service, allowing users to make an informed disclosure decision.
  10. Add automated tests covering HTTP URLs, lookalike domains, embedded credentials, malformed URLs, alternate ports, and cross-origin redirects.
  11. Rotate any API keys that may already have been used while untrusted endpoint environment variables were present.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (11)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The documentation claims the tool is based on KIE AI and only requires KIE_API_KEY, but the detected behavior includes additional third-party integration (LaoZhang API), extra credentials for understanding features, and undeclared polling/result-download behavior. This mismatch can mislead users about where their data is sent and what credentials or network actions the skill actually uses.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

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

或在 skill 目录创建 .env 文件:

bash
# 创建 .env 文件
nano skills/kay-image/.env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

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

或在 skill 目录创建 .env 文件:

bash
# 创建 .env 文件
nano skills/kay-image/.env

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

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

或在 skill 目录创建 .env 文件:

bash
# 创建 .env 文件
nano skills/kay-image/.env

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding

The skill declares required environment variables and describes use of external APIs, but it does not declare an explicit tool scope such as permissions or allowed-tools. This weakens least-privilege controls because consumers cannot easily tell that the skill needs network access and credential access before running it.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill processes images, videos, and prompts through external AI services, but the markdown does not warn users that their media and text may be transmitted off-box for processing. This creates privacy and compliance risk, especially if users submit sensitive images, documents, or videos without informed consent.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% 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/main.ts (reported line 23)May include surrounding context.

ts
const KIE_API_BASE = process.env.KIE_BASE_URL || "https://api.kie.ai";
const KIE_API_KEY = process.env.KIE_API_KEY;

const LAOZHANG_API_BASE = process.env.LAOZHANG_BASE_URL || "https://api.laozhang.ai/v1";
const LAOZHANG_API_KEY = process.env.LAOZHANG_API_KEY;

// API Source for understanding mode

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill metadata states only KIE_API_KEY is required, but the code also depends on KIE_UNDERSTANDING_API_KEY and optionally LAOZHANG_API_KEY for advertised understanding features. This is a security-relevant transparency issue because users may unknowingly route sensitive image/video data to different services or encounter unexpected credential prompts for core functionality.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill advertises KIE-based image understanding, but includes a switch that sends understanding content to LaoZhang instead. Because understanding mode can include local images and videos converted to base64, this undisclosed alternate routing creates a real data disclosure risk if users assume content only goes to KIE.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

In understanding mode, local image and video files are read, base64-encoded, and sent to external APIs without an explicit privacy warning or confirmation. This is dangerous because users may provide sensitive local media assuming local analysis, while the tool silently uploads full file contents to third-party services.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

The natural-language description, headings, parameter explanations, and usage examples are all presented only in Chinese, with no indication that users may choose another language or that the skill is intentionally limited to a Chinese-speaking context. This can conflict with language/locale policy expectations when no user opt-in or justification is provided.

Content

No source excerpt is available for this finding.