Back to skill

Security audit

Keyapi Tiktok Ecommerce

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly matches its KeyAPI TikTok Shop analytics purpose, but it needs review because it handles API tokens and local cached data with weak controls and exposes broader MCP access than the description suggests.

Review before installing. Use a minimally scoped KeyAPI token, prefer setting KEYAPI_TOKEN only for the current command instead of entering it interactively, do not commit or share .env or .keyapi-cache, avoid KEYAPI_SERVER_URL unless the endpoint is trusted, and run npm dependency installation in a contained environment.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (3)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/run.js:272
Finding

Bearer Token Can Be Disclosed Through an Unrestricted Server Endpoint Override

Content
View full analysis

Vulnerability Details

File Location: scripts/run.js:59, 272-279
Vulnerability Type: Unrestricted authentication endpoint configuration
Risk Level: High

Vulnerable Code

js
const SERVER_BASE = process.env.KEYAPI_SERVER_URL ?? "https://mcp.keyapi.ai";
js
async function connect(serverUrl) {
  let token = process.env.KEYAPI_TOKEN;
  if (!token) token = await promptToken();

  const client = new Client({ name: "keyapi-runner", version: "1.0.0" });
  const transport = new StreamableHTTPClientTransport(
    new URL(serverUrl),
    { requestInit: { headers: { Authorization: `Bearer ${token}` } } }
  );
  await client.connect(transport);
  return client;
}

The configured base is subsequently used without validation:

js
const serverUrl = `${SERVER_BASE}/${values.platform}/mcp`;
const client = await connect(serverUrl);

Technical Analysis

KEYAPI_SERVER_URL may specify an arbitrary origin or protocol. The connection routine unconditionally places KEYAPI_TOKEN in the Authorization header, without requiring HTTPS, validating the destination hostname, or asking for confirmation before sending the credential to a non-default origin.

Although sending the token to the documented https://mcp.keyapi.ai service is necessary for the Skill's declared functionality, transmitting it to an unrestricted override endpoint exceeds minimum privilege. A malicious or mistakenly configured .env file, inherited environment variable, wrapper process, or deployment configuration can redirect authentication to an attacker-controlled service.

Attack Path

  1. An attacker gains the ability to modify the project .env, a launch script, container configuration, or another source of environment variables.
  2. The attacker sets KEYAPI_SERVER_URL to an attacker-controlled HTTPS endpoint or an interception-prone HTTP endpoint.
  3. The victim invokes scripts/run.js for any sup ...[truncated 799 chars]
Remediation
View remediation

Remediation Suggestions

  • Require the effective endpoint to use HTTPS.
  • Allowlist mcp.keyapi.ai as the default and only automatic recipient of KEYAPI_TOKEN.
  • Reject URLs containing embedded credentials, unexpected ports, fragments, or unsupported schemes.
  • If custom enterprise endpoints are required, maintain an explicit allowlist or require informed user confirmation before sending the token to a different origin.
  • Use separate credentials scoped to custom endpoints rather than reusing the production KeyAPI token.
  • Validate the final URL after combining the base and platform path.
  • Document the security implications of KEYAPI_SERVER_URL.
  • Add tests confirming that HTTP endpoints and unapproved hosts cannot receive the authorization header.
  • Rotate the token immediately if it may previously have been sent to an untrusted endpoint.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/run.js:240
Finding

API Token Is Persisted in a Plaintext Environment File Without Explicit Permission Hardening

Content
View full analysis

Vulnerability Details

File Location: scripts/run.js:240-265
Vulnerability Type: Insecure local credential storage
Risk Level: Medium

Vulnerable Code

js
/** Prompt for KEYAPI_TOKEN interactively and persist it to .env */
async function promptToken() {
  if (!process.stdin.isTTY) {
    throw new Error(
      "KEYAPI_TOKEN is not set.\n" +
      "  → Register at https://keyapi.ai/ to obtain a free token, then either:\n" +
      "    export KEYAPI_TOKEN=your_token_here\n" +
      "  → Or create a .env file in the skill directory:\n" +
      "    echo \"KEYAPI_TOKEN=your_token_here\" > .env"
    );
  }
  const { createInterface } = await import("readline");
  const rl = createInterface({ input: process.stdin, output: process.stderr });
  return new Promise((resolve, reject) => {
    process.stderr.write("\nKEYAPI_TOKEN is required. Get yours at https://keyapi.ai/\n\n");
    rl.question("Enter your token: ", (answer) => {
      rl.close();
      const token = answer.trim();
      if (!token) {
        reject(new Error("No token entered. Set KEYAPI_TOKEN and try again."));
        return;
      }
      const envPath = join(ROOT, ".env");
      writeFileSync(envPath, `KEYAPI_TOKEN=${token}\n`, "utf8");
      log(`[token] Saved to ${envPath} — future runs will load it automatically`);
      process.env.KEYAPI_TOKEN = token;
      resolve(token);
    });
  });
}

Technical Analysis

The interactive credential prompt automatically persists the entered bearer token to a plaintext .env file. writeFileSync() does not specify a restrictive file mode, so the resulting permissions depend on the process umask and preexisting file permissions. The audited project also contains no visible .gitignore ensuring that .env is excluded from version control.

The write replaces the complete file rather than securely updating only the relevant entry. This can destroy unre ...[truncated 1416 chars]

Remediation
View remediation

Remediation Suggestions

  • Do not persist interactively entered tokens by default; keep them in process memory for the current invocation.
  • Ask for explicit informed consent before saving a token locally.
  • When persistence is selected, create the file with mode 0600 and verify permissions after creation.
  • If the file already exists, reject unsafe ownership or permissions and avoid following symbolic links.
  • Update only the KEYAPI_TOKEN entry while preserving unrelated configuration safely.
  • Add .env to a committed .gitignore file and provide a non-secret .env.example.
  • Prefer an operating-system credential store or secret manager for long-lived credentials.
  • Ensure terminal input does not echo the token when prompting.
  • Document token revocation and rotation procedures for suspected exposure.

T08 · Insecure Dependencies

Warning
Location
package.json:5
Finding

Dependency Installation Is Not Reproducibly Pinned

Content
View full analysis

Vulnerability Details

File Location: package.json:5-7; installation instructions at SKILL.md:33-35, 53-55
Vulnerability Type: Non-reproducible third-party dependency resolution
Risk Level: Medium

Vulnerable Code

json
"dependencies": {
  "@modelcontextprotocol/sdk": "^1.10.2"
}

The documentation instructs users to resolve dependencies dynamically:

bash
npm install

Technical Analysis

The caret version range permits npm to install later semver-compatible versions of @modelcontextprotocol/sdk. No package lockfile is present in the audited project, so both the direct dependency and its transitive dependency graph can change between installations without changes to the Skill source.

The dependency is security-sensitive because it implements the network transport that receives the bearer token and handles remote MCP responses. Dynamic resolution makes the installed executable code non-reproducible and allows a compromised future release or transitive package to run with the Skill's process privileges.

This audit did not establish that the named package or current version is malicious. The confirmed issue is the absence of reproducible dependency controls, not a confirmed upstream compromise.

Attack Path

  1. A user follows SKILL.md and runs npm install.
  2. npm resolves the caret range and transitive dependencies using the registry state at installation time.
  3. A later allowed release or transitive dependency contains compromised or vulnerable code.
  4. That code is installed without any corresponding modification to the audited project.
  5. When the runner starts, the dependency executes inside the Node.js process with access to the process environment, filesystem permissions, request parameters, API responses, and KEYAPI_TOKEN.

Impact Assessment

A compromised dependency could obtain all privileges of the Node.js process. Depending on the malicious payloa ...[truncated 357 chars]

Remediation
View remediation

Remediation Suggestions

  • Generate, review, and commit a package-lock.json file.
  • Direct users and automated deployments to use npm ci rather than unconstrained npm install.
  • Consider pinning the direct dependency to an exact reviewed version.
  • Review lockfile changes whenever dependencies are upgraded.
  • Use automated vulnerability and provenance checks, such as registry integrity verification, dependency auditing, and software composition analysis.
  • Run installation and execution in a minimally privileged container or user account.
  • Prevent dependencies from accessing unrelated secrets by supplying only KEYAPI_TOKEN to the execution environment.
  • Establish a controlled update process so security patches can be adopted without silently changing the audited dependency graph.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (27)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The documented purpose is a bounded TikTok Shop intelligence skill, but the workflow exposes generic tool listing, schema inspection, arbitrary tool execution parameters, local caching, and filesystem output behavior that materially expands what the skill can do. This mismatch impairs user consent and security review because operators may authorize the skill for narrow analytics while it actually supports broader execution patterns and local persistence.

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 61)May include surrounding context.

md
node scripts/run.js --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/run.js --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/run.js --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/run.js --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/run.js --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/run.js --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/run.js --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/run.js --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/run.js --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/run.js --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/run.js --list-tools

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 · scripts/run.js (reported line 45)May include surrounding context.

js
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = resolve(__dirname, "..");

// ── .env loader ───────────────────────────────────────────────────────────────

(function loadDotenv() {
  const envPath = join(ROOT, ".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 · scripts/run.js (reported line 106)May include surrounding context.

js
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = resolve(__dirname, "..");

// ── .env loader ───────────────────────────────────────────────────────────────

(function loadDotenv() {
  const envPath = join(ROOT, ".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 · scripts/run.js (reported line 240)May include surrounding context.

js
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = resolve(__dirname, "..");

// ── .env loader ───────────────────────────────────────────────────────────────

(function loadDotenv() {
  const envPath = join(ROOT, ".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 · scripts/run.js (reported line 247)May include surrounding context.

js
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = resolve(__dirname, "..");

// ── .env loader ───────────────────────────────────────────────────────────────

(function loadDotenv() {
  const envPath = join(ROOT, ".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 · scripts/run.js (reported line 48)May include surrounding context.

js
// ── .env loader ───────────────────────────────────────────────────────────────

(function loadDotenv() {
  const envPath = join(ROOT, ".env");
  if (!existsSync(envPath)) return;
  for (const line of readFileSync(envPath, "utf8").split("\n")) {
    const m = line.match(/^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*)$/);

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 · scripts/run.js (reported line 248)May include surrounding context.

js
// ── .env loader ───────────────────────────────────────────────────────────────

(function loadDotenv() {
  const envPath = join(ROOT, ".env");
  if (!existsSync(envPath)) return;
  for (const line of readFileSync(envPath, "utf8").split("\n")) {
    const m = line.match(/^\s*([A-Z_][A-Z0-9_]*)\s*=\s*(.*)$/);

Credential Access

High
Category
Privilege Escalation
Confidence
88% confidence
Finding

This line writes the entered API token to a plaintext .env file in the project directory without any permission hardening or explicit opt-in. Persisting secrets locally in cleartext can expose credentials to other local users, accidental source-control inclusion, backups, or unrelated tools that scan the workspace.

Content

Scanner excerpt · scripts/run.js (reported line 262)May include surrounding context.

js
reject(new Error("No token entered. Set KEYAPI_TOKEN and try again."));
        return;
      }
      const envPath = join(ROOT, ".env");
      writeFileSync(envPath, `KEYAPI_TOKEN=${token}\n`, "utf8");
      log(`[token] Saved to ${envPath} — future runs will load it automatically`);
      process.env.KEYAPI_TOKEN = token;

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill declares access to sensitive capabilities via environment variables (KEYAPI_TOKEN) and requires Node execution, but it does not define any explicit tool scope such as permissions or allowed-tools. That leaves the runtime authority under-specified and can enable broader-than-expected command or tool use, especially since the document instructs use of a generic runner (node scripts/run.js) for schema discovery and tool invocation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

The documentation directs use of Authorization: Bearer $KEYAPI_TOKEN against a remote MCP server but does not include handling guidance such as avoiding logs, shell history, debug output, or accidental persistence in local files. While bearer-token transmission is normal, omission of credential-safety guidance increases the risk of accidental token exposure through tooling, screenshots, scripts, or cached command artifacts.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The skill explicitly instructs the agent to persist all API responses to a local cache, including product, shop, review, creator, and search datasets, without any warning, retention limit, or sensitivity guidance. Local persistence can expose collected commercial data or user-request-derived queries to other local users, later tasks, backups, or unintended sharing, especially when caches are stored in predictable paths.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script advertises that it can call any MCP tool and uses client.callTool({ name: tool, ... }) without constraining tool names to a reviewed subset. In a skill presented as TikTok Shop intelligence, this creates a capability overreach where any server-exposed tool becomes reachable, including tools unrelated to the stated purpose.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The runner explicitly supports arbitrary platforms via --platform and examples for YouTube, while the skill is described as TikTok Shop market intelligence. This scope mismatch increases the chance that users invoke data sources or capabilities outside the reviewed and disclosed functionality, undermining least surprise and expanding attack surface to unreviewed server endpoints.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

The dependency is specified with a caret range (^1.10.2), which allows installation of newer compatible releases without strict reproducibility. This increases supply-chain risk and makes it harder to verify exactly which code is installed, especially for a network-facing MCP skill dependency.

Content

Scanner excerpt · package.json (reported line 6)May include surrounding context.

json
"type": "module",
  "engines": { "node": ">=18.0.0" },
  "dependencies": {
    "@modelcontextprotocol/sdk": "^1.10.2"
  }
}