Back to skill

Security audit

WebSearchAPI

Security checks for vulnerabilities and agentic risk

Overview

This search skill mostly matches its stated purpose, but it ships a real-looking SearchAPI key in plaintext and under-warns that user queries are sent to a third party.

Review this before installing. Remove and rotate the bundled SearchAPI key, configure your own key through an environment variable or protected local secret file, and avoid using the tool for searches containing secrets or confidential data because queries are sent to SearchAPI/Google.

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 (1)

T09 · Insecure Skill Coding Practices

Error
Location
tools/websearchapi/config.json:1
Finding

Plaintext Hard-Coded SearchAPI Credential

Content
View full analysis

Vulnerability Details

File Location: tools/websearchapi/config.json:1
Vulnerability Type: Hard-coded secret / plaintext credential exposure
Risk Level: High

Vulnerable Code

json
{"apiKey":"rEux5Wb3fyHM47TKyCpNdHGf","num":5,"lang":"zh-CN","gl":"cn","engine":"google","maxRetries":3,"timeout":15000}

Related credential-loading and transmission logic appears in tools/websearchapi/websearchapi.js:

javascript
const CONFIG_FILE = path.join(__dirname, 'config.json');

function loadConfig() {
  try {
    if (fs.existsSync(CONFIG_FILE)) {
      return { ...DEFAULT_CONFIG, ...JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf8')) };
    }
  } catch (e) {
    console.error('加载配置失败:', e.message);
  }
  return DEFAULT_CONFIG;
}

const params = {
  q: query,
  num: options.num || config.num,
  hl: options.lang || config.lang,
  gl: options.gl || config.gl,
  engine: engine,
  api_key: config.apiKey
};

const url = `${API_BASE}?${querystring.stringify(params)}`;

Technical Analysis

The project distributes a reusable SearchAPI credential directly in a plaintext configuration file. Anyone who can access the source tree, a copied project archive, deployment artifact, backup, or repository history can recover the credential without authentication.

The application reads this value and includes it in the HTTPS request query string. TLS protects the request in transit, but query-string credentials may still be exposed through application diagnostics, proxy logs, request traces, or URL logging. The saveConfig() implementation also writes configuration with fs.writeFileSync() without explicitly enforcing restrictive file permissions.

Masking the key when the config command displays it does not mitigate direct access to config.json.

Attack Path

  1. An attacker obtains read access to the project package, repository, deployment artifact, backup, or copied tool direc ...[truncated 1045 chars]
Remediation
View remediation

Remediation Suggestions

  1. Immediately revoke and rotate the exposed SearchAPI key.

  2. Remove the credential from the current project and repository history. Treat all existing copies as compromised.

  3. Replace the committed value with an empty placeholder or example configuration.

  4. Load the key from an environment variable or managed secret store, for example:

    javascript
    const apiKey = process.env.SEARCHAPI_API_KEY;
    
  5. Add config.json to .gitignore if it must contain local secrets, and provide a non-sensitive config.example.json.

  6. If local file-based secret storage is unavoidable, create or update the file with owner-only permissions such as mode 0600, and validate existing permissions before use.

  7. Prefer an authorization header instead of a query parameter if the provider supports it, reducing exposure through URL logs and request traces.

  8. Apply provider-side restrictions where available, including quota limits, usage alerts, endpoint restrictions, and key rotation procedures.

  9. Add automated secret scanning to source-control and release pipelines to prevent future credential commits.

Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (8)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill clearly routes user-provided queries to an external third-party search provider, but the documentation does not prominently warn users that their prompts, search terms, and related parameters will be transmitted off-platform to SearchAPI/Google. In an agent setting, users may include sensitive internal data in queries, so lack of disclosure creates a real privacy and data-handling risk even though it is not direct code execution.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The documentation sets default search parameters to zh-CN language and cn region, which imposes a specific locale by default. Under the policy, forcing a language or locale without explicit user choice is a natural-language policy violation unless clearly justified as region-specific.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The config hard-codes both language and geolocation to Chinese settings via "lang":"zh-CN" and "gl":"cn". This is a natural-language locale policy issue because the skill appears to enforce a specific language/region without indicating any user-selectable option or documented justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The tool silently defaults searches to zh-CN and cn, which can route user queries through a China-specific locale and alter both privacy exposure and result shaping without explicit user consent. In an agent context, users may assume neutral/global search behavior, so hidden locale defaults can leak regional preferences and bias retrieved information.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The API key is stored in plaintext in a local config.json file with no warning, permission hardening, or secure secret storage mechanism. If the host is multi-user, synced, backed up, or later exposed through logs/repositories, the credential can be recovered and abused for unauthorized API usage.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The code sends arbitrary search queries directly to searchapi.io over the network without any in-code notice, confirmation, or sensitivity filtering. In an agent workflow, prompts, internal task details, secrets, or user-provided sensitive data could be unintentionally exfiltrated to a third-party service.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The documented defaults --lang zh-CN and --gl cn impose a specific language and region by default. Under the policy, forcing a locale without user opt-in or a clearly documented regional justification is a natural-language policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The description string uses Chinese-only phrasing ('Agent 专用搜索工具 - 基于 SearchAPI') in a package manifest. For a general-purpose skill, this can create a language/locale policy issue because it does not indicate user choice, multilingual support, or a justified region-specific scope.

Content

No source excerpt is available for this finding.