Back to skill

Security audit

Keyapi Tiktok Intelligence

Security checks for vulnerabilities and agentic risk

Overview

This skill is a plausible KeyAPI trend-intelligence helper, but its runner has broader remote-tool and credential-handling authority than the TikTok-only description makes clear.

Review this before installing if you use valuable KeyAPI credentials or sensitive market research. Prefer setting KEYAPI_TOKEN only in a trusted shell environment, avoid the interactive plaintext .env save flow, do not set KEYAPI_SERVER_URL unless you fully trust the destination, and clear or relocate .keyapi-cache if cached research data should not remain on disk.

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/run.js:58
Finding

Bearer Token Disclosure Through an Unrestricted Server Override

Content
View full analysis

Vulnerability Details

File Location: scripts/run.js, lines 58 and 290–294, with the constructed endpoint used at lines 503–504
Vulnerability Type: Unrestricted credential destination / sensitive information exposure
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;
}
js
const serverUrl = `${SERVER_BASE}/${values.platform}/mcp`;
const client = await connect(serverUrl);

Technical Analysis

The runner allows KEYAPI_SERVER_URL to replace the intended https://mcp.keyapi.ai service without validating the URL scheme, hostname, port, or origin. The connect function then unconditionally attaches KEYAPI_TOKEN as a bearer credential to requests sent through the configured endpoint.

The project also automatically imports variables from a project-local .env file. Consequently, anyone able to influence the process environment or that file can redirect authenticated requests to an arbitrary server. An HTTP destination is also accepted, potentially exposing the token and query data to passive network interception.

A server override can be useful for testing, but forwarding a production bearer credential to any configured origin exceeds the minimum network privilege required for the Skill’s declared TikTok intelligence functionality.

Attack Path

  1. An attacker gains the ability to modify the project-local .env file, deployment environment, wrapper script, or process configuration.
  2. The attacker sets KEYAPI_SERVER_URL to an attacker-controlled en ...[truncated 1355 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove KEYAPI_SERVER_URL if alternate MCP origins are not essential.
  2. If an override is required, parse it with URL and enforce:
    • The https: protocol.
    • An explicit allowlist of trusted hostnames.
    • Approved ports only.
    • No embedded username or password.
    • No unexpected path, query string, or fragment.
  3. Bind credentials to origins. Attach KEYAPI_TOKEN only when the final normalized origin exactly matches an approved KeyAPI origin.
  4. Use a separate, low-privilege test credential for development or staging endpoints rather than forwarding the production token.
  5. Reject invalid configuration before initializing the MCP transport and display the rejected origin without printing the token.
  6. Document the trusted endpoint policy and ensure environment or .env configuration is not writable by untrusted users.
  7. Add automated tests proving that HTTP URLs, lookalike domains, unapproved ports, embedded credentials, and arbitrary external hosts are rejected.

A suitable validation pattern is:

js
const TRUSTED_ORIGINS = new Set(["https://mcp.keyapi.ai"]);

function validateServerBase(value) {
  const url = new URL(value);

  if (
    url.protocol !== "https:" ||
    !TRUSTED_ORIGINS.has(url.origin) ||
    url.username ||
    url.password ||
    url.search ||
    url.hash
  ) {
    throw new Error("Untrusted KEYAPI server URL");
  }

  return url.origin;
}

The authorization header should only be created after this validation succeeds.

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
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (28)

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The skill is presented as a narrowly scoped TikTok intelligence workflow, but its instructions describe generic MCP tool discovery and arbitrary tool execution through scripts/run.js (--list-tools, --schema, and generic --tool <tool_name>). That broader operational surface can enable execution of tools beyond the declared purpose, including unknown or future server-side capabilities, which materially increases risk to data, credentials, and user expectations.

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 60)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 108)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 111)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 112)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 119)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 123)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 126)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 129)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 135)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 142)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 149)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 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
93% confidence
Finding

The promptToken flow is explicitly designed to collect an API token from the user and persist it locally, which creates a real secret-handling weakness. In this skill context, the token grants access to external intelligence APIs, so compromise could enable unauthorized use, billing abuse, or access to account-scoped data.

Content

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

js
// ── MCP client ────────────────────────────────────────────────────────────────

/** Prompt for KEYAPI_TOKEN interactively and persist it to .env */
async function promptToken() {
  if (!process.stdin.isTTY) {
    throw new Error(

Credential Access

High
Category
Privilege Escalation
Confidence
97% confidence
Finding

This line writes KEYAPI_TOKEN directly to ROOT/.env in plaintext, creating a concrete secret-at-rest exposure. Because the skill is a general-purpose networked runner with caching and output features, storing secrets in the project workspace is more dangerous than in a locked-down dedicated credential store and raises the risk of accidental disclosure or reuse by other local processes.

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
89% confidence
Finding

The skill requests access to a sensitive environment variable (KEYAPI_TOKEN) but does not declare any explicit tool scope or permission boundaries. This weakens least-privilege controls and makes it harder for a host or reviewer to understand what capabilities the skill is expected to use, increasing the chance of unintended credential exposure or misuse.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The skill requires the user to supply KEYAPI_TOKEN and use it for authenticated requests to an external MCP service, but it does not clearly warn that the credential will be transmitted off-host or provide handling guidance. This omission can lead to inadvertent exposure, unsafe sharing, or use in environments where token forwarding to third-party infrastructure is not acceptable.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill instructs the agent to persist all API responses to local cache files, including trend intelligence and related metadata, without warning the user that fetched data will be written to disk. Local persistence can expose potentially sensitive business research, query history, or third-party data to other local users, backups, or later processes, especially when retention and access controls are unspecified.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest describes a TikTok trend intelligence skill, but the runner explicitly supports arbitrary platforms via --platform and includes examples for YouTube. This broadens the actual behavior from TikTok-specific intelligence to a multi-platform KeyAPI client, which is materially wider than the stated skill purpose.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The script interactively collects KEYAPI_TOKEN and writes it in plaintext to a local .env file for future use. Persistent secret storage in the skill directory increases the chance of credential exposure through repository commits, local file disclosure, backups, or other tools that read workspace files.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
97% confidence
Finding

The dependency is specified with a caret range (^1.10.2), which permits automatic installation of newer minor and patch releases rather than a single reviewed version. This weakens supply-chain control and reproducibility, increasing the chance of pulling in a vulnerable or malicious release without explicit review.

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"
  }
}