Back to skill

Security audit

Keyapi Linkedin User Analytics

Security checks for vulnerabilities and agentic risk

Overview

The skill is not clearly malicious, but it handles sensitive LinkedIn data and API tokens with broader and less protected behavior than its description suggests.

Review before installing. Use a scoped or disposable KeyAPI token, avoid KEYAPI_SERVER_URL overrides, do not enter tokens interactively unless you accept plaintext .env storage, and clear or relocate .keyapi-cache because it may contain personal LinkedIn contact/profile 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

Error
Location
scripts/run.js:59
Finding

Unrestricted MCP Endpoint Override Can Disclose the KeyAPI Bearer Token

Content
View full analysis

Vulnerability Details

File Location: scripts/run.js:59, scripts/run.js:272-280, and scripts/run.js:509-510
Vulnerability Type: Unvalidated credential destination and insecure server configuration
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 accepts KEYAPI_SERVER_URL directly from the process environment and does not validate its scheme, hostname, port, or origin. The connect function then unconditionally attaches the production KEYAPI_TOKEN as a bearer credential to the resulting URL.

Network communication with the documented KeyAPI endpoint is necessary for the Skill's declared LinkedIn analytics functionality. However, forwarding the same credential to an arbitrary endpoint is not necessary and exceeds the minimum trust boundary. The implementation permits both attacker-controlled HTTPS destinations and plaintext HTTP destinations if supported by the transport.

This vulnerability is exploitable when an attacker can influence the process environment, deployment configuration, wrapper script, CI job, container configuration, or command-launching context. No ability to modify the Skill source code is required.

Attack Path

  1. The attacker obtains influence over the environment used to launch the Skill.
  2. The attacker sets `KEYAPI_SERVER_ ...[truncated 934 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove KEYAPI_SERVER_URL support unless custom MCP servers are an explicit functional requirement.
  2. Require HTTPS and reject URLs using HTTP or other schemes.
  3. Allowlist the documented hostname, mcp.keyapi.ai, before attaching KEYAPI_TOKEN.
  4. Normalize and validate the URL with the URL API, including hostname, protocol, port, username, and password fields.
  5. Never send the production KeyAPI token to a custom endpoint. If custom servers must be supported, require a separate credential through a distinct environment variable.
  6. Fail closed when endpoint validation fails and clearly identify the rejected destination.
  7. Document the trust implications of endpoint overrides and avoid inheriting them from untrusted environment files or wrappers.
  8. Add automated tests confirming that credentials are not attached to non-allowlisted origins.

A hardened design should conceptually enforce the following:

js
const DEFAULT_SERVER_BASE = "https://mcp.keyapi.ai";
const parsedBase = new URL(process.env.KEYAPI_SERVER_URL ?? DEFAULT_SERVER_BASE);

if (
  parsedBase.protocol !== "https:" ||
  parsedBase.hostname !== "mcp.keyapi.ai" ||
  parsedBase.username ||
  parsedBase.password
) {
  throw new Error("Untrusted KeyAPI server URL");
}

If a custom endpoint is selected, the application should refuse to reuse KEYAPI_TOKEN.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/run.js:240
Finding

API Token and Sensitive LinkedIn Responses Are Persisted in Plaintext

Content
View full analysis

Vulnerability Details

File Location: scripts/run.js:240-265, scripts/run.js:143-147, scripts/run.js:394-399, and scripts/run.js:433-448
Vulnerability Type: Insecure plaintext storage of credentials and personal data
Risk Level: Medium

Vulnerable Code

The interactive credential flow automatically saves the token to a project-local .env file:

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

API responses are written as plaintext JSON without an explicit restrictive file mode:

js
function writeJSON(path, data) {
  ensureDir(dirname(path));
  writeFileSync(path, JSON.stringify(data, null, 2), "utf8");
}

The default single-page execution path writes responses to the cache:

...[truncated 3244 chars]

Remediation
View remediation

Remediation Suggestions

  1. Do not persist interactively entered tokens by default. Keep them in memory for the current process unless the user explicitly opts into storage.
  2. Prefer an operating-system credential store or secret-management service over a plaintext .env file.
  3. If file-based token storage remains available, create the file with mode 0600 and verify that an existing file is not permissively accessible.
  4. Create cache directories with mode 0700 and cache files with mode 0600.
  5. Disable caching by default for contact-information endpoints and other responses containing sensitive personal data.
  6. Add configurable cache expiration and a command that securely clears cached records.
  7. Inform users before caching sensitive responses and support an explicit opt-out or opt-in policy.
  8. Add .env and .keyapi-cache/ to a committed .gitignore; also document exclusions for backup and synchronization systems.
  9. Avoid logging secrets, full authenticated requests, or sensitive response bodies during error handling.
  10. Consider encrypting cached sensitive data when persistent caching is operationally required.

Restrictive file creation should use explicit modes, for example:

js
writeFileSync(envPath, `KEYAPI_TOKEN=${token}\n`, {
  encoding: "utf8",
  mode: 0o600,
});

writeFileSync(path, JSON.stringify(data, null, 2), {
  encoding: "utf8",
  mode: 0o600,
});

Directory creation should similarly request mode 0700, subject to platform-specific behavior, and existing file permissions should be checked and corrected.

Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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 (28)

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The declared description is narrowly about analyzing LinkedIn users and enumerates LinkedIn-specific profile and activity fields. The supplied code does not implement LinkedIn-specific discovery or analysis logic. Instead, it is a general-purpose runner for any KeyAPI MCP tool on any supported platform, with examples centered on TikTok and YouTube. Its main functions are connecting to a remote server with an API token, listing available tools, inspecting schemas, calling arbitrary tools, auto-paginating, caching responses, and rewriting image URLs. While such a runner could potentially be used to access some LinkedIn-related backend tool if one existed on the server, that behavior is not present in this code chunk. Therefore the code’s actual primary purpose materially differs from the declared LinkedIn 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 linkedin --list-tools

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

The function is explicitly designed to prompt for a credential and persist it to disk, increasing the attack surface for secret compromise. In the context of a data-access skill, durable local storage of a bearer token is especially sensitive because possession of the token may grant continued API access without further authentication.

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

This line writes the bearer token directly to a plaintext .env file for future reuse. That is dangerous because local compromise, accidental source control inclusion, backups, logs, or multi-user systems can expose the credential and allow unauthorized API access.

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

The skill requires access to a sensitive environment variable (KEYAPI_TOKEN) but does not declare an explicit tool scope such as allowed-tools or permissions boundaries. That makes the trust boundary unclear and increases the risk of overbroad execution or unintended tool use, especially because the workflow invokes Node-based scripts that can reach remote services.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill is explicitly designed to collect extensive LinkedIn personal and contact information, yet it does not warn users that sensitive personal data may be gathered and processed. In a profiling skill, omission of this warning materially increases privacy and compliance risk because operators may collect regulated or unexpected personal data without informed handling.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The workflow instructs users to persist LinkedIn responses into a local cache directory, including contact information and profiling data, without any explicit retention, access-control, or deletion guidance. Local disk caching of sensitive personal data creates a concrete confidentiality risk through accidental disclosure, multi-user access, backups, or later reuse beyond the original purpose.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The runner is explicitly generic: it accepts arbitrary tool names and a user-selected platform, despite the skill being described as LinkedIn user analytics. That scope mismatch matters because it enables use of unrelated MCP capabilities and non-LinkedIn data sources, defeating least-privilege expectations for a narrowly scoped skill.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The manifest frames the skill as discovery/profile analysis of LinkedIn users, which suggests data retrieval and analysis, but this script also writes API responses to cache files, arbitrary output paths, and persists credentials to a .env file. Those local write side effects are not reflected in the manifest description and go beyond pure analytics behavior.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The script interactively collects an API token and persists it in plaintext to a local .env file, creating a durable credential exposure risk. In a skill advertised for LinkedIn analytics, storing secrets this way is broader and more dangerous than necessary because the token may be reused, committed, or read by other local processes.

Content

No source excerpt is available for this finding.