Back to skill

Security audit

Baidu Search 1

Security checks for vulnerabilities and agentic risk

Overview

This is a straightforward Baidu web search skill, with the main caution that searches and the configured API key involve a third-party service.

Install only if you are comfortable sending search queries to Baidu and using a Baidu API key. Protect ~/.openclaw/openclaw.json with owner-only permissions, avoid printing or sharing the full config, use a dedicated low-privilege key where possible, and rotate the key if it may have been exposed.

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

Note
Location
references/apikey-fetch.md:15
Finding

Plaintext API Key Storage and Disclosure-Prone Configuration Verification

Content
View full analysis

Vulnerability Details

File Location: references/apikey-fetch.md, lines 15-38
Vulnerability Type: T09: Insecure Skill Coding Practices
Risk Level: Low

Vulnerable Code

markdown
### 2. Configure OpenClaw
Edit the OpenClaw configuration file: `~/.openclaw/openclaw.json`

Add or merge the following structure:

```json
{
  "skills": {
    "entries": {
      "baidu-search": {
        "env": {
          "BAIDU_API_KEY": "your_actual_api_key_here"
        }
      }
    }
  }
}

Replace "your_actual_api_key_here" with your actual API key.

3. Verify Configuration

bash
# Check JSON format
cat ~/.openclaw/openclaw.json | python -m json.tool
text

### Technical Analysis

The setup instructions direct users to store a live Baidu API key in plaintext within `~/.openclaw/openclaw.json`, but they do not instruct users to restrict that file's permissions. If the file is readable by other local accounts or processes, the credential may be recovered and reused.

The recommended verification command also prints the entire configuration to standard output. Because the configuration may contain the Baidu key and unrelated OpenClaw credentials, this can expose secrets through terminal recording, command output capture, CI logs, support transcripts, or screen sharing.

The executable itself does not print the API key. It uses the key as a Bearer credential over HTTPS to the declared Baidu endpoint, which is necessary for the Skill's stated search functionality. The weakness is limited to the credential-management guidance.

### Attack Path

1. A user follows the documented setup procedure and writes a valid `BAIDU_API_KEY` into `~/.openclaw/openclaw.json`.
2. The configuration file retains permissive permissions, or the user runs the documented verification command in a recorded or shared terminal.
3. Another local user, process, log reader, or recipient of the captured output obtains the plaintext API key.
4. The exposed credential is submitte
...[truncated 942 chars]
Remediation
View remediation

Remediation Suggestions

  1. Use the OpenClaw or operating-system secret store instead of embedding API keys directly in a general configuration file, where supported.
  2. If file-based storage is required, create and protect the configuration with owner-only permissions:
bash
mkdir -p ~/.openclaw
chmod 700 ~/.openclaw
touch ~/.openclaw/openclaw.json
chmod 600 ~/.openclaw/openclaw.json
  1. Replace the disclosure-prone verification command with validation that suppresses parsed content:
bash
python3 -c 'import json, pathlib; json.loads(pathlib.Path.home().joinpath(".openclaw/openclaw.json").read_text()); print("Configuration JSON is valid")'
  1. Warn users not to paste full configuration files into issue reports, chat sessions, or logs. Provide a redaction procedure for troubleshooting.
  2. Recommend a narrowly scoped API credential, where Baidu supports scope restrictions, and document immediate revocation and rotation after suspected exposure.
  3. Ensure configuration backups and diagnostic bundles either exclude the file or redact credential values.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (8)

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
90% confidence
Finding

The skill invokes a Python script and explicitly requires an environment variable API key, implying network and secret access, but it does not declare any tool scope such as permissions or allowed-tools. This weakens policy enforcement and reviewability because the runtime capabilities are broader than what the manifest communicates, increasing the chance of unintended network use or secret exposure.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
Confidence
60% confidence
Finding

Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Content

Scanner excerpt · references/apikey-fetch.md (reported line 11)May include surrounding context.

md
Visit: **https://console.bce.baidu.com/ai-search/qianfan/ais/console/apiKey**

- Log in to your Baidu Cloud account
- Create an application or view existing API keys
- Copy your **API Key** (only API Key is needed)

### 2. Configure OpenClaw

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The guide tells users to place a live API key directly into a plaintext local JSON config file and does not include any warning about file permissions, secret handling, or avoiding source control exposure. This increases the chance of credential leakage through backups, shared machines, accidental commits, logs, or support bundles, which could allow unauthorized use of the Baidu service.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
92% confidence
Finding

This code performs an outbound HTTP POST to a third-party service using user-controlled content in the request body. While necessary for a web search integration, it still constitutes external transmission and can leak sensitive prompts, internal research topics, or regulated data if upstream callers are not warned or constrained.

Content

Scanner excerpt · scripts/search.py (reported line 19)May include surrounding context.

python
}

    # 使用POST方法发送JSON数据
    response = requests.post(url, json=requestBody, headers=headers)
    response.raise_for_status()
    results = response.json()
    if "code" in results:

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The script sends the user-provided query and filters to Baidu's external API, which creates a data disclosure risk if users supply sensitive or internal information. In a search skill this is expected behavior, but the absence of an explicit in-file warning, consent gate, or data classification check means confidential input could be transmitted off-platform unintentionally.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
82% confidence
Finding

The examples consistently show Chinese-language queries such as "人工智能", "最新新闻", and "旅游景点", which may imply the skill is intended to operate in a specific language or locale. Because the documentation does not explicitly state that the skill is China/Chinese-focused or offer language flexibility, this can conflict with language/locale policy expectations.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
73% confidence
Finding

SQP-3 applies to all file types and includes language or locale policy concerns. The document is centered on Baidu Cloud and Baidu AI Search setup, which may imply a China-specific provider or locale constraint, but it does not state whether this is optional or required for a region-specific use case.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The manifest describes a search capability for live information and research, but the code also depends on reading a secret from the process environment. Accessing environment variables for credential retrieval is an additional capability not stated in the manifest and is not inherently part of the user-facing search behavior.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.