Back to skill

Security audit

Keyapi Google Search

Security checks for vulnerabilities and agentic risk

Overview

The skill is framed as Google search, but its shipped runner can call broader KeyAPI MCP tools and stores credentials locally in ways users should review carefully.

Install only if you are comfortable giving this runner a KeyAPI token and allowing it to contact KeyAPI MCP services. Prefer setting KEYAPI_TOKEN only in your shell for the current session, avoid entering it interactively into the prompt, do not set KEYAPI_SERVER_URL unless you fully trust the endpoint, and review or clear .keyapi-cache/ if searches may be sensitive.

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

Warning
Location
scripts/run.js:60
Finding

Bearer Token Can Be Transmitted to an Arbitrary Server Through an Unrestricted Endpoint Override

Content
View full analysis

Vulnerability Details

File Location: scripts/run.js, lines 60 and 509-510; credential attachment occurs in the connect function around lines 241-286
Vulnerability Type: Unrestricted credential-bearing network destination
Risk Level: Medium

Relevant Code

javascript
const SERVER_BASE = process.env.KEYAPI_SERVER_URL ?? "https://mcp.keyapi.ai";
javascript
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;
}
javascript
const serverUrl = `${SERVER_BASE}/${values.platform}/mcp`;
const client = await connect(serverUrl);

Technical Analysis

Sending KEYAPI_TOKEN to the documented KeyAPI MCP service is necessary for the declared search functionality. However, the destination is taken directly from KEYAPI_SERVER_URL without enforcing HTTPS or verifying that the host belongs to KeyAPI.

Consequently, the same bearer credential is attached to requests sent to any configured URL, including an attacker-controlled HTTPS endpoint or an unencrypted HTTP endpoint. A fixed KeyAPI endpoint or a narrowly validated override would provide the required functionality with less privilege and lower credential exposure.

The environment override is not inherently malicious, and an attacker who can directly inspect the victim's complete process environment may already have access to the token. The material exploitation case is an attacker who can influence configuration, deployment instructions, shell initialization, or a local .env file without otherwise being able to read the victim's token.

Attack Path

  1. An attacker persua ...[truncated 966 chars]
Remediation
View remediation

Remediation Suggestions

  • Remove KEYAPI_SERVER_URL unless custom endpoints are an essential supported feature.
  • Prefer the fixed documented endpoint: https://mcp.keyapi.ai.
  • If overrides are necessary, parse the URL before attaching credentials and require:
    • https: as the protocol;
    • an explicit allowlist of trusted hostnames;
    • no embedded username or password;
    • an expected port and pathname.
  • Do not forward the production bearer token to arbitrary development endpoints. Use a separate, explicitly named development credential where custom servers are required.
  • Fail closed on malformed URLs, redirects to untrusted hosts, and TLS validation errors.
  • Document the security implications of endpoint overrides and avoid accepting them from untrusted project-local configuration.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/run.js:241
Finding

Interactively Entered API Token Is Persisted as Plaintext Without Restrictive File Permissions

Content
View full analysis

Vulnerability Details

File Location: scripts/run.js, approximately lines 241-277
Vulnerability Type: Plaintext credential storage
Risk Level: Medium

Relevant Code

javascript
/** 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 interactive prompt automatically writes the bearer token into .env under the Skill directory. The write operation does not specify a restrictive mode such as 0600, so effective permissions depend on the user's umask, existing file permissions, and filesystem behavior.

This creates persistent plaintext credential material in a predictable location. Persistence is not required for a single Skill invocation, and automatic storage exceeds the minimum priv ...[truncated 1133 chars]

Remediation
View remediation

Remediation Suggestions

  • Do not persist an interactively supplied token by default. Use it only in memory for the current process.
  • Ask for explicit confirmation before storing any credential and clearly display the destination.
  • Prefer an operating-system credential manager or secret-management service.
  • If .env support is retained:
    • create the file with mode 0600;
    • verify and repair permissions on an existing file before writing;
    • use atomic creation that refuses unsafe symlinks;
    • add .env to .gitignore;
    • warn users not to synchronize or commit it;
    • avoid overwriting unrelated .env content.
  • Use masked terminal input so the token is not echoed during entry.
  • Provide token revocation and rotation instructions in the documentation.

T08 · Insecure Dependencies

Note
Location
package.json:5
Finding

Dependency Resolution Is Not Reproducibly Pinned

Content
View full analysis

Vulnerability Details

File Location: package.json, lines 5-6
Vulnerability Type: Non-reproducible third-party dependency resolution
Risk Level: Low

Relevant Code

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

No package lockfile is present in the audited directory structure.

Technical Analysis

The caret range permits installation of later compatible releases rather than the exact version reviewed by the Skill author. Without a committed lockfile, separate installations can resolve to different SDK versions and transitive dependency graphs.

The package name and npm source shown in the project do not establish that the current dependency is malicious or vulnerable. The risk is that a future compromised, malicious, or defective compatible release could be installed automatically and execute with the runner's privileges. In this project, those privileges include access to KEYAPI_TOKEN, network access, cached API data, and files writable by the invoking user.

Attack Path

  1. A later version allowed by ^1.10.2, or one of its transitive dependencies, becomes compromised or introduces exploitable behavior.
  2. A user performs npm install after dependency resolution has changed.
  3. npm installs the newly resolved package because no committed lockfile fixes the reviewed dependency graph.
  4. Malicious package lifecycle code or imported runtime code executes in the user's context.
  5. That code may read the API token, access cached results, make network requests, or modify user-writable files.

This is a conditional supply-chain path; the audit did not identify evidence that the currently declared SDK package is malicious.

Impact Assessment

A compromised dependency would run with the same operating-system permissions as the Node.js process. It could potentially access environment variables, including KEYAPI_TOKEN, read or alter project files and caches, and ...[truncated 113 chars]

Remediation
View remediation

Remediation Suggestions

  • Commit a generated package-lock.json and use npm ci for reproducible installation.
  • Consider pinning the SDK to an exact reviewed version rather than a caret range.
  • Enable dependency integrity and vulnerability monitoring, such as automated audit and update review.
  • Review lockfile changes before accepting dependency upgrades.
  • Restrict or disable npm lifecycle scripts in sensitive build environments where feasible.
  • Periodically update dependencies through controlled, tested pull requests rather than unconstrained installation-time resolution.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • 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
Findings (27)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The documented purpose is narrowly framed as Google web/image search, but the behavior described by analysis includes broader MCP capabilities such as listing tools, inspecting schemas, and potentially calling arbitrary MCP tools across platforms. This mismatch is dangerous because users may authorize the skill under false assumptions, while the underlying implementation can interact with a wider remote surface than advertised.

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

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

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The script is a generic MCP client/runner that can invoke arbitrary KeyAPI tools across platforms, which materially exceeds the declared purpose of a Google search skill. This capability mismatch is dangerous because a user or orchestrator trusting the manifest could unknowingly grant the skill broad remote-action capability beyond web/image search.

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

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The code explicitly enumerates all tools from the remote MCP server and exposes their names and descriptions, enabling discovery and later invocation of arbitrary remote capabilities. In the context of a supposedly narrow Google search skill, this creates an unnecessary expansion of attack surface and violates least privilege.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
90% confidence
Finding

The promptToken flow is designed to collect an authentication token interactively and persist it locally, increasing secret-handling risk on shared systems. While not exfiltration, prompting for and storing credentials in plaintext .env can expose the token to other local users, backups, or accidental commits.

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

The script writes the provided KEYAPI_TOKEN directly into a plaintext .env file in the skill directory for future runs. In agent or shared-workspace contexts, this is dangerous because secrets can be exposed via repository sync, backups, loose filesystem permissions, or later prompt/file disclosure.

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

The skill requires access to an environment secret (KEYAPI_TOKEN) and invokes Node-based tooling, but it does not declare an explicit tool scope such as allowed tools or permissions. That creates an under-specified trust boundary: operators and users cannot easily tell what execution and secret-access capabilities the skill needs, increasing the chance of overbroad runtime access or unnoticed capability creep.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill sends user queries and an authentication token to a third-party remote service, but the description does not prominently warn users that their inputs and credentials are leaving the local environment. This creates a privacy and data-governance risk, especially if users submit sensitive search terms or assume the skill operates locally.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The workflow instructs the agent to persist API responses in a local cache directory without warning that search inputs and returned data will be stored on disk. Cached results can expose sensitive queries, competitive research, or third-party data to other local users, backups, or later processes if retention and file permissions are not controlled.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The header and usage text describe a generic KeyAPI runner with a default TikTok platform, directly contradicting the skill metadata claiming Google search functionality. Misleading documentation increases the risk that reviewers and downstream systems will misclassify the skill's true capabilities and approve excessive access.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The documented support for unrelated platforms such as TikTok and YouTube shows the runner is multi-purpose rather than specific to Google search. This broadens reachable backend functionality and makes accidental or unauthorized use of non-search APIs more likely.

Content

No source excerpt is available for this finding.