Back to skill

Security audit

Keyapi Youtube Video Analysis

Security checks for vulnerabilities and agentic risk

Overview

The skill appears to be a legitimate KeyAPI YouTube helper, but its bundled runner handles the user's API token in ways that need review before installation.

Review this before installing if you use a real KeyAPI token. Prefer setting KEYAPI_TOKEN only for the command invocation, avoid the interactive prompt that writes .env, do not set KEYAPI_SERVER_URL unless you fully trust the endpoint, and treat cached/output JSON as potentially containing private API results.

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:271
Finding

API Token Disclosure Through an Unrestricted Server URL Override

Content
View full analysis

Vulnerability Details

File Location: scripts/run.js:59, scripts/run.js:271-279, and the server URL construction in main()
Vulnerability Type: Unrestricted credential forwarding to a configurable network endpoint
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 Skill legitimately requires KEYAPI_TOKEN to authenticate to the documented KeyAPI MCP service. However, KEYAPI_SERVER_URL can replace the trusted server base without validation. The code does not enforce HTTPS, verify that the destination hostname belongs to KeyAPI, reject embedded credentials or nonstandard ports, or request user confirmation before forwarding the bearer token.

The connect() function unconditionally attaches KEYAPI_TOKEN to the selected endpoint as an Authorization: Bearer header. Consequently, any party capable of controlling the process environment can redirect both the token and subsequent MCP requests to an arbitrary server.

Authentication to https://mcp.keyapi.ai is necessary for the declared YouTube-analysis functionality. Forwarding the same credential to unrestricted destinations exceeds minimum privilege and creates an avoidable credential-disclosure boundary.

Attack Path

  1. An attacker gains the ability to influence the environment used to launch the Skill, su ...[truncated 1480 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove KEYAPI_SERVER_URL if custom MCP endpoints are not required for the Skill's documented operation.
  2. If configurability is required, parse and validate the URL before creating the transport:
    • Require the https: protocol.
    • Permit only an explicit allowlist such as mcp.keyapi.ai.
    • Reject embedded usernames or passwords.
    • Reject fragments, unexpected ports, and deceptive hostname suffixes.
  3. Attach KEYAPI_TOKEN only when the normalized destination origin exactly matches an approved KeyAPI origin.
  4. For development environments, require a separate explicit unsafe-development flag and a separate test credential before connecting to custom endpoints.
  5. Fail closed when URL validation fails; do not silently fall back or send the token.
  6. Avoid logging authorization headers and ensure transport errors cannot expose bearer credentials.
  7. Add automated tests covering malicious values such as HTTP endpoints, look-alike domains, embedded credentials, alternate ports, and attacker-controlled localhost endpoints.
  8. Document the trust implications of endpoint overrides and advise users to rotate the token immediately if it may have been sent to an untrusted destination.
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 (34)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description says this skill analyzes YouTube content in depth and implies a YouTube-focused implementation for specific data types like metadata, comments, related videos, Shorts, search, and trending. The code, however, does not implement YouTube-specific analysis logic. Instead, it is a general-purpose CLI wrapper for calling any KeyAPI MCP tool on any platform, with the default platform set to TikTok. It can list available tools, inspect schemas, call arbitrary tools, auto-paginate, cache responses, save output to files, and convert TikTok cover image URLs. While this runner could potentially be used to access some YouTube tools by passing --platform youtube and appropriate tool names, that is only an indirect possibility, not the concrete primary behavior shown in the code. Therefore the code’s actual purpose is materially broader and different from the declared YouTube-analysis purpose.

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

md
node scripts/run.js --platform youtube --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 --platform youtube --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/run.js --platform youtube --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 --platform youtube --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/run.js --platform youtube --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 --platform youtube --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/run.js --platform youtube --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 --platform youtube --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
node scripts/run.js --platform youtube --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
96% confidence
Finding

This line writes the entered API token to a project-local .env file, creating persistent credential exposure on disk. In the context of a reusable skill repository, that is especially dangerous because secrets can be read by other local users, captured by tooling, backed up unintentionally, or committed to version control.

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;

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The token prompt writes the entered API credential directly to a .env file without explicit user confirmation or warning that the secret will be stored on disk. Persisting secrets silently is dangerous because the file may be readable by other local processes or users, accidentally committed to version control, or harvested later from the workspace.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill declares access to sensitive capability inputs via environment variables (KEYAPI_TOKEN) but does not define any explicit tool scope or allowed-tools boundary. That weakens least-privilege guarantees and makes it harder to constrain what execution paths or helper scripts may do with the available secret, especially since the workflow relies on command execution (node scripts/run.js) and external network access.

Content

No source excerpt is available for this finding.