Back to skill

Security audit

Keyapi Reddit Content Analytics

Security checks for vulnerabilities and agentic risk

Overview

The skill is advertised as Reddit analytics, but its bundled runner is broader than disclosed and handles the API token in ways users should review carefully.

Install only if you are comfortable with a generic KeyAPI MCP runner, not a tightly scoped Reddit-only helper. Set KEYAPI_TOKEN through your environment or a secure secret manager instead of entering it interactively, avoid custom KEYAPI_SERVER_URL values unless you fully trust the endpoint, and review or delete .keyapi-cache when it contains Reddit user or comment data.

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

Warning
Location
scripts/run.js:264
Finding

Bearer Token Can Be Redirected to an Arbitrary Server

Content
View full analysis

Vulnerability Details

File Location: scripts/run.js:49, scripts/run.js:69, scripts/run.js:264-273, and scripts/run.js:532
Vulnerability Type: Unvalidated authentication endpoint override
Risk Level: Medium

Vulnerable Code

js
const SERVER_BASE = process.env.KEYAPI_SERVER_URL ?? "https://mcp.keyapi.ai";

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

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

Technical Analysis

The runner permits KEYAPI_SERVER_URL to override the documented KeyAPI endpoint without validating its protocol or hostname. The same connection logic unconditionally attaches KEYAPI_TOKEN as a bearer credential.

Consequently, a process environment modified by another program, a malicious wrapper script, a compromised CI configuration, or an untrusted shell profile can redirect requests and credentials to an attacker-controlled endpoint. Plain HTTP URLs are not explicitly rejected, so the credential could also be transmitted without transport encryption where the MCP transport accepts such a URL.

Sending the token to the default documented endpoint is necessary for the Skill's functionality. Allowing that credential to be sent to an unrestricted override exceeds the minimum privileges required to access https://mcp.keyapi.ai.

Attack Path

  1. An attacker gains the ability to influence the environment used to launch the Skill, such as through a wrapper script, CI variable, shell configuration, or deployment settings.
  2. The attacker sets `KEYAPI_ ...[truncated 980 chars]
Remediation
View remediation

Remediation Suggestions

  1. Pin authenticated requests to the documented origin, https://mcp.keyapi.ai, unless endpoint overrides are strictly required.
  2. Parse the final URL before connecting and require the https: protocol.
  3. Compare the normalized hostname against an explicit allowlist before attaching KEYAPI_TOKEN.
  4. If custom MCP endpoints are supported, require a separate credential variable for them rather than forwarding the production KeyAPI token.
  5. Require an explicit, conspicuous opt-in for custom endpoints and display the destination hostname before authentication.
  6. Reject URLs containing embedded credentials, unexpected ports, or hostnames that only superficially resemble the trusted domain.
  7. Add automated tests confirming that bearer credentials are never attached to unapproved origins.

Example hardening:

js
const TRUSTED_ORIGIN = "https://mcp.keyapi.ai";

function validateServerUrl(serverUrl) {
  const url = new URL(serverUrl);
  if (url.protocol !== "https:" || url.origin !== TRUSTED_ORIGIN) {
    throw new Error(`Refusing to send KEYAPI_TOKEN to untrusted origin: ${url.origin}`);
  }
  return url;
}

async function connect(serverUrl) {
  const url = validateServerUrl(serverUrl);
  const token = process.env.KEYAPI_TOKEN ?? await promptToken();

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

  await client.connect(transport);
  return client;
}

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/run.js:245
Finding

API Token Is Collected and Persisted Insecurely in a Plaintext Environment File

Content
View full analysis

Vulnerability Details

File Location: scripts/run.js:245-260
Vulnerability Type: Insecure secret input and plaintext credential storage
Risk Level: Medium

Vulnerable Code

js
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 prompt uses readline.question, which does not suppress terminal echo. The token can therefore be displayed while the user types it and may be exposed to shoulder surfing, terminal capture, or session recording.

The token is then stored directly in a plaintext .env file. The writeFileSync call does not explicitly request owner-only permissions such as mode 0o600. Effective access therefore depends on the process umask, existing file permissions, filesystem defaults, backup systems, and repository hygiene.

If .env already exists with permissive permissions, overwriting it does not necessarily restrict those permissions. The project also contains no demonstrated .gitignore protection in the audited directory, increasing the possibility of accidental source-control inclusion.

Attack Path

  1. The user launches the runner without an existing KEYAPI_TOKEN.
  2. The runner prompts for the token using visible terminal input.
  3. The ...[truncated 852 chars]
Remediation
View remediation

Remediation Suggestions

  1. Prefer accepting the token through a preconfigured environment variable or an operating-system credential manager instead of automatically persisting it.
  2. Use a hidden-input implementation that disables terminal echo while the token is entered.
  3. If file persistence remains necessary, create .env with owner-only permissions:
    js
    writeFileSync(envPath, `KEYAPI_TOKEN=${token}\n`, {
      encoding: "utf8",
      mode: 0o600,
      flag: "w",
    });
    
  4. Explicitly apply chmodSync(envPath, 0o600) after writing so an existing file with permissive permissions is corrected.
  5. Add .env to .gitignore and provide a non-secret .env.example containing only placeholder values.
  6. Warn users that the credential will be stored locally and obtain confirmation before persistence.
  7. Avoid logging token values and redact authorization headers from diagnostics and error reporting.
  8. Document token rotation and revocation procedures for suspected exposure.
  9. Where supported, use short-lived, narrowly scoped tokens rather than long-lived account credentials.
Vulnerability Patterns
  • 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
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (29)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The description claims a Reddit-focused content exploration and analysis capability: posts, comments, user activity, and curated Reddit feeds. The code does not implement Reddit-specific logic. Instead, it is a general-purpose command-line runner for any KeyAPI MCP tool on any configured platform, with the default platform set to TikTok. It dynamically lists tools, inspects schemas, detects pagination conventions, executes arbitrary tools, caches results locally, and performs TikTok-specific image URL conversion. These behaviors indicate a materially different primary purpose and undeclared capabilities unrelated to the stated Reddit functionality.

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 --platform reddit --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 --platform reddit --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

This runner is explicitly generic and can call any KeyAPI MCP tool, while the skill is described as Reddit content analytics. That creates a scope-expansion risk: a user or downstream agent invoking this skill may unknowingly gain access to non-Reddit capabilities across other platforms, violating least privilege and enabling unintended data access or actions through tools outside the advertised manifest scope.

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 · 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
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 262)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*(.*)$/);

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
87% confidence
Finding

The skill requires access to an environment secret (KEYAPI_TOKEN) and instructs users to run Node-based tooling, but it does not declare an explicit tool scope such as permissions or allowed-tools. That weakens least-privilege enforcement and makes it easier for a host agent to grant broader execution or secret access than the skill’s stated Reddit-analysis purpose requires.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill explicitly supports collection of user activity and directs caching of API responses to local disk, yet it provides no privacy notice, retention policy, or guidance on handling potentially sensitive personal data. This can lead to unnecessary persistence of user profiling data, accidental disclosure through shared workspaces, and compliance issues when analyzing identifiable Reddit activity.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The help text and defaults reference TikTok/YouTube influencer tooling instead of Reddit analytics, which materially misrepresents what the skill does. In a security context, this increases the chance that operators or agents invoke broader cross-platform functionality than intended, masking the true capability surface and undermining trust boundaries.

Content

No source excerpt is available for this finding.