Back to skill

Security audit

Keyapi Youtube Channel Analysis

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly a disclosed KeyAPI YouTube analysis helper, but it handles an API token in ways users should review carefully before installing.

Install only if you are comfortable using a KeyAPI token with this local runner. Prefer setting KEYAPI_TOKEN only for the current shell session, avoid interactive token entry, do not set KEYAPI_SERVER_URL unless you fully trust the destination, and keep any .env or cache output out of shared, synced, or source-controlled directories.

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

Error
Location
scripts/run.js:272
Finding

Bearer Token Can Be Redirected to an Arbitrary Server

Content
View full analysis

Vulnerability Details

File Location: scripts/run.js, lines 59 and 272–279
Vulnerability Type: Unvalidated credential destination
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}` } } }
  );

Technical Analysis

Sending KEYAPI_TOKEN to the documented KeyAPI endpoint is necessary for the Skill's declared functionality. However, KEYAPI_SERVER_URL controls the destination without protocol or hostname validation. The bearer token is unconditionally attached to requests sent through the resulting transport.

Consequently, an attacker who can influence the process environment can redirect authentication requests to an attacker-controlled server. The implementation does not restrict the destination to https://mcp.keyapi.ai, enforce HTTPS, or require user confirmation before sending the credential to an override endpoint.

Attack Path

  1. An attacker influences the environment used to launch the Skill, such as through a compromised wrapper, shell configuration, CI configuration, or launcher.
  2. The attacker sets KEYAPI_SERVER_URL to an endpoint under their control.
  3. The user invokes scripts/run.js with a valid KEYAPI_TOKEN.
  4. The script constructs the MCP URL from the attacker-controlled base URL and selected platform.
  5. connect() attaches Authorization: Bearer <KEYAPI_TOKEN> to the transport.
  6. The attacker-controlled server receives and records the bearer token.
  7. The attacker reuses the token against KeyAPI until it is revoked or expires.

...[truncated 625 chars]

Remediation
View remediation

Remediation Suggestions

  1. Restrict credential-bearing connections to an explicit hostname allowlist, preferably only mcp.keyapi.ai.
  2. Require the effective URL to use HTTPS.
  3. Parse and validate the complete URL before constructing the transport:
    • Require url.protocol === "https:".
    • Require url.hostname === "mcp.keyapi.ai" or another explicitly trusted hostname.
    • Reject embedded credentials and unexpected ports.
  4. If custom endpoints are operationally required, do not automatically forward KEYAPI_TOKEN. Use a separate credential variable for custom servers and display an explicit warning or confirmation prompt.
  5. Log the effective destination hostname before connecting, without logging the token.
  6. Document the trust implications of endpoint overrides and recommend clearing inherited environment variables in privileged or automated execution contexts.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/run.js:240
Finding

Interactive API Token Is Echoed and Persisted in Plaintext

Content
View full analysis

Vulnerability Details

File Location: scripts/run.js, lines 240–265
Vulnerability Type: Insecure secret input and 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 standard readline.question() interface does not suppress terminal echo, so the API token can be displayed while the user types it. This exposes the secret to nearby observers, terminal recording systems, screen sharing, and captured session output.

The implementation also persists the token automatically to a plaintext .env file. The write operation does not explicitly request owner-only permissions and does not ask whether the user wants persistent storage. Effective ...[truncated 1259 chars]

Remediation
View remediation

Remediation Suggestions

  1. Use a secret-entry mechanism that disables terminal echo while the token is entered.
  2. Prefer session-only use of interactively supplied credentials.
  3. Ask for explicit consent before persisting the token to disk.
  4. If persistence is selected, create the file with owner-only permissions such as mode 0600, and verify or repair permissions if the file already exists.
  5. Avoid overwriting an existing .env file; update only the required key while preserving unrelated configuration.
  6. Ensure .env is excluded from source control and warn users not to place it in shared or synchronized directories.
  7. Where available, use an operating-system credential manager or secret-management service instead of a plaintext file.
  8. Provide token revocation and rotation guidance in case accidental exposure occurs.
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (34)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The documented behavior goes beyond a narrow YouTube-analysis skill and appears to expose generic MCP tool execution, schema discovery, local credential handling, and filesystem writes/caching that are not fully represented in the declared purpose. This kind of capability mismatch is dangerous because users and orchestrators may approve the skill expecting limited read-only YouTube analysis while it can perform broader actions and touch local secrets or disk.

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 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 136)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 147)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 159)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 163)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 170)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 177)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 184)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 191)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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 203)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 210)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 217)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 224)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 231)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 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
90% confidence
Finding

The promptToken() flow persistently stores a user-entered API token to a plaintext .env file in the skill directory. In shared workspaces, checked-in repos, or multi-user environments, this increases the chance of token disclosure through accidental commits, backups, or local file access.

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(