Back to skill

Security audit

Keyapi Threads User Discovery

Security checks for vulnerabilities and agentic risk

Overview

This Threads research skill is mostly coherent, but its helper can use the user's KeyAPI token in broader and less protected ways than the skill description clearly scopes.

Review before installing. Use a scoped KeyAPI token, avoid setting KEYAPI_SERVER_URL unless you fully trust the destination, prefer setting KEYAPI_TOKEN through your shell or secret manager instead of the interactive prompt, and clear .keyapi-cache or .env files when they are no longer needed.

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

Bearer Token Disclosure Through Arbitrary MCP Server Override

Content
View full analysis

Vulnerability Details

File Location: scripts/run.js:58, scripts/run.js:285-291, and scripts/run.js:509-510
Vulnerability Type: Credential exfiltration through an unrestricted network 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}` } } }
  );
js
const serverUrl = `${SERVER_BASE}/${values.platform}/mcp`;
const client = await connect(serverUrl);

Technical Analysis

The code permits KEYAPI_SERVER_URL to replace the trusted KeyAPI MCP origin. Regardless of the selected origin, connect() attaches the production KEYAPI_TOKEN as an Authorization bearer credential.

No hostname allowlist, HTTPS requirement, certificate pinning, destination confirmation, or separation between production and custom-server credentials is implemented. Consequently, an actor capable of influencing the process environment can direct authenticated requests to an attacker-controlled server.

A server override may be useful during development, but forwarding the primary API credential to an unrestricted destination exceeds the minimum privileges required for the declared Threads discovery functionality.

Attack Path

  1. The attacker gains the ability to influence the environment used to launch the Skill, such as through a wrapper script, CI configuration, container environment, or compromised shell configuration.
  2. The attacker sets KEYAPI_SERVER_URL to an attacker-controlled HTTP or HTTPS endpoint.
  3. A user invokes the Skill to list tools, retrieve a schema, ...[truncated 721 chars]
Remediation
View remediation

Remediation Suggestions

  • Remove KEYAPI_SERVER_URL in production builds and use a fixed trusted endpoint.
  • If overrides are operationally necessary, parse the URL and require:
    • The https: protocol.
    • An exact hostname from a documented allowlist.
    • An expected port and path.
    • Rejection of embedded credentials and unexpected URL components.
  • Do not send KEYAPI_TOKEN to custom endpoints. Require a separate credential specifically configured for the custom server.
  • Require explicit interactive confirmation before connecting to a non-default origin and display the exact destination without displaying the token.
  • Treat environment configuration as untrusted input and document the security implications of endpoint overrides.
  • Rotate the token immediately if it may have been sent to an untrusted endpoint.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/run.js:253
Finding

API Token Stored in Plaintext With Default File Permissions

Content
View full analysis

Vulnerability Details

File Location: scripts/run.js:253-279
Vulnerability Type: Insecure credential entry and storage
Risk Level: Medium

Vulnerable Code

js
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 mask the entered value, so the API token is visible while it is typed. The token is then persisted directly in a plaintext .env file.

writeFileSync() is called without an explicit restrictive mode. The resulting permissions therefore depend on the process umask and surrounding filesystem configuration. The implementation also does not verify whether an existing .env file has safe ownership or permissions before reading or overwriting it.

Persisting the credential supports convenience r ...[truncated 1013 chars]

Remediation
View remediation

Remediation Suggestions

  • Prefer the operating system's credential manager, a dedicated secrets manager, or ephemeral environment injection instead of a project-local plaintext file.
  • Use a hidden-input mechanism that disables terminal echo while the token is entered.
  • If file persistence is unavoidable:
    • Create the file with mode 0o600.
    • Verify that it is a regular file owned by the current user.
    • Refuse unsafe symbolic links and unexpectedly permissive existing files.
    • Avoid overwriting unrelated .env content.
  • Add .env to .gitignore and provide a .env.example containing placeholders only.
  • Document credential rotation and revocation procedures.
  • Avoid including tokens in command lines, logs, error messages, or diagnostic output.

T08 · Insecure Dependencies

Warning
Location
package.json:5
Finding

Unpinned Dependency Installation Without a Lockfile

Content
View full analysis

Vulnerability Details

File Location: package.json:5-7; installation instructions in SKILL.md:45 and SKILL.md:66
Vulnerability Type: Non-reproducible third-party dependency resolution
Risk Level: Medium

Vulnerable Code

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

The documented installation command is:

bash
npm install

No package lockfile is present in the audited project structure.

Technical Analysis

The caret range permits npm to install later compatible releases rather than one reviewed version. Without a committed lockfile, direct and transitive dependency versions can change between installations.

This does not demonstrate that the named SDK is malicious. The risk arises because the artifact cannot guarantee that future installations execute the same reviewed dependency graph. If a permitted direct or transitive release is compromised, its installation lifecycle behavior or imported runtime code could execute in the user's environment.

Attack Path

  1. An attacker compromises a dependency release or one of its transitive dependencies within the version range npm may resolve.
  2. A user follows SKILL.md and runs npm install.
  3. Because no lockfile fixes the reviewed dependency graph, npm resolves the compromised release.
  4. Malicious lifecycle code may run during installation, or malicious module code may run when scripts/run.js imports the SDK.
  5. The dependency executes with the permissions of the user running npm or Node.js and can access resources available to that process, potentially including KEYAPI_TOKEN and project files.

Impact Assessment

The maximum impact depends on the permissions of the installation or runtime process. A compromised dependency could read or modify accessible files, inspect environment variables, exfiltrate the KeyAPI token, perform network requests, or alter Skill behavior.

The audit found ...[truncated 141 chars]

Remediation
View remediation

Remediation Suggestions

  • Resolve a reviewed dependency graph and commit the generated package-lock.json.
  • Use npm ci for installation so builds fail when package metadata and the lockfile differ.
  • Pin the direct SDK dependency to a reviewed exact version where operationally feasible.
  • Review lockfile changes as security-sensitive code changes.
  • Run dependency vulnerability and provenance checks in CI.
  • Evaluate lifecycle scripts before approving dependency updates and consider disabling scripts during installation when compatible with the dependency set.
  • Periodically update dependencies through controlled, tested pull requests rather than unconstrained installation-time resolution.
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 (31)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The documented skill claims to be Threads-specific, but the referenced execution model exposes generic tool invocation, schema inspection, multi-platform selection, and local file writes. That mismatch is dangerous because users or higher-level agents may trust the narrow declared purpose while the implementation surface permits broader operations than expected, increasing the risk of misuse, unintended data access, or execution against other platforms.

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 threads --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

The skill requires environment access to a bearer token and instructs execution of local Node.js commands, but it does not declare an explicit tool scope such as allowed tools or permissions boundaries. In an agent ecosystem, missing scope constraints increases the chance that the skill can be used with broader-than-necessary execution capabilities, exposing secrets or enabling unintended command/tool use.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill explicitly directs caching of retrieved profiles, posts, comments, and search results to local disk without warning about retention, access control, or sensitivity. Even if the data is public, local aggregation can create a more sensitive dataset, and disk persistence can expose user research targets, collected content, or operational metadata to other local users, backups, or later compromise.

Content

No source excerpt is available for this finding.