Back to skill

Security audit

Baidu API Search

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly matches its Baidu search purpose, but it needs Review because a Baike endpoint override can send Baidu API keys to an arbitrary URL and generated packs do not clearly isolate untrusted web snippets.

Review before installing. Use limited Baidu API keys, do not pass --baike-base-url unless it is the official Baidu host or a trusted test endpoint with test credentials, and use --no-cache for sensitive searches. Treat research_pack.md and lookup_pack.md source snippets as untrusted web content, not instructions for the agent.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • 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/lookup.py:438
Finding

Configurable Baike Base URL Can Exfiltrate API Keys

Content
View full analysis

Vulnerability Details

File Location: scripts/lookup.py:70-71, 123-126, 309-314, 438
Vulnerability Type: Credential disclosure through an unvalidated authentication endpoint override
Risk Level: High

Vulnerable Code

python
def build_url(base_url: str, path: str, params: dict[str, Any]) -> str:
    return f"{base_url.rstrip('/')}{path}?{urllib.parse.urlencode(params)}"
python
def get_json(url: str, key: str, timeout: int, auth_header: str) -> dict[str, Any]:
    request = urllib.request.Request(url, headers=build_headers(key, auth_header), method="GET")
    try:
        with urllib.request.urlopen(request, timeout=timeout) as response:
python
list_url = build_url(
    args.baike_base_url,
    LIST_PATH,
    {"lemma_title": topic, "top_k": clamp_top_k(args.top_k)},
)
python
parser.add_argument("--baike-base-url", default=BAIKE_BASE_URL)

The authentication headers populated by build_headers() contain the complete API key:

python
bearer = f"Bearer {key}"
if auth_header in {"authorization", "both"}:
    headers["Authorization"] = bearer
if auth_header in {"x-appbuilder", "both"}:
    headers["X-Appbuilder-Authorization"] = bearer

Technical Analysis

--baike-base-url accepts an arbitrary URL. The selected URL is passed to get_json(), which attaches a Baidu API key in an Authorization or X-Appbuilder-Authorization header without validating the URL scheme or destination hostname.

Consequently, anyone who can influence the command-line arguments can redirect authenticated requests to an attacker-controlled server. This is particularly relevant in an agent skill because generated tool arguments may be influenced by user instructions or indirectly by untrusted retrieved content.

The key pool increases the possible exposure. baike_get() retries the request with every configured key after failures. An attacker-controlled end ...[truncated 1356 chars]

Remediation
View remediation

Remediation Suggestions

  • Remove --baike-base-url from production-facing agent commands unless endpoint substitution is strictly required.
  • Enforce HTTPS and an exact hostname allowlist before attaching authentication headers. For example, only permit appbuilder.baidu.com.
  • Reject URLs containing user information, fragments, unexpected ports, IP literals, or non-HTTPS schemes.
  • Construct the API URL from a fixed origin and fixed paths rather than concatenating an arbitrary base URL.
  • If compatibility testing requires custom endpoints, require an explicit development-only flag and separate test credentials.
  • Do not send production credentials to a custom endpoint under any circumstances.
  • Limit retries and avoid cycling through the entire key pool when the destination has not passed validation.
  • Add tests confirming that HTTP URLs, lookalike domains, subdomains, alternate ports, and attacker-controlled hosts are rejected.
  • Revoke and rotate any keys that may previously have been used with an untrusted --baike-base-url.

T01 · Skill Instruction Hijacking

Warning
Location
scripts/build_research_pack.py:177
Finding

Untrusted Search-Result Content Is Embedded in Agent-Readable Packs Without Prompt-Injection Boundaries

Content
View full analysis

Vulnerability Details

File Location: scripts/run_search_plan.py:18-26, scripts/dedupe_results.py:132-141, scripts/build_research_pack.py:177-189
Vulnerability Type: Indirect prompt injection through untrusted remote search metadata
Risk Level: Medium

Vulnerable Code

Remote references are accepted from the API without field-level trust labeling or content filtering:

python
def extract_references(api_result: dict) -> list[dict]:
    response = api_result.get("response", {})
    if isinstance(response, dict):
        refs = response.get("references")
        if isinstance(refs, list):
            return refs
        data = response.get("data")
        if isinstance(data, dict) and isinstance(data.get("references"), list):
            return data["references"]
    return []

Their attacker-controlled title and snippet fields are retained by deduplication:

python
sources.append(
    {
        "source_id": source_id,
        "title": best.get("title") or "",
        "url": best.get("url") or "",
        "canonical_url": best.get("canonical_url") or "",
        "domain": domain,
        "snippet": best.get("snippet") or best.get("content") or "",
        "website": best.get("website") or "",
        "date": best.get("date") or "",

The fields are then written directly into the agent-readable Markdown pack:

python
for source in sources[:50]:
    flags = ", ".join(source.get("quality_flags", [])) or "none"
    queries = " | ".join(source.get("matched_queries", [])[:5])
    lines.append(f"### {source.get('source_id')} - {source.get('title')}")
    lines.append("")
    lines.append(f"- URL: {source.get('url')}")
    lines.append(f"- Domain: `{source.get('domain')}`")
    lines.append(f"- Best rank: {source.get('best_rank')}")
    lines.append(f"- Matched queries: {queries}")
    intents = ", ".join(source.get("matched_intents", [])) or "unknown
...[truncated 2484 chars]
Remediation
View remediation

Remediation Suggestions

  • Add a prominent invariant at the beginning of every generated pack stating that all source titles, snippets, URLs, and page content are untrusted evidence, not instructions.
  • Require downstream agents to ignore commands found in retrieved content and never use them to change goals, reveal secrets, or invoke tools.
  • Represent remote records in a clearly delimited data block or structured JSON attachment rather than blending them with operational recommendations.
  • Separate trusted tool-generated metadata from untrusted source fields using explicit sections and labels.
  • Escape Markdown control characters and normalize embedded line breaks to prevent source fields from creating headings, lists, links, or new apparent instruction sections.
  • Add deterministic detection and warning flags for common instruction-injection phrases. Detection should supplement, not replace, strict trust-boundary handling.
  • Ensure tool calls derived from retrieved content require independent validation against the original user request.
  • Never place credentials, system prompts, private context, or unrestricted tool capabilities into the same reasoning context without appropriate isolation.
  • Add regression tests using malicious titles and snippets that attempt to override instructions, request secret disclosure, and trigger tool execution.
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • 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 (21)

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The core area overlaps with the declaration in that the code does perform Baidu-based web search via the Baidu AI Search API. However, several specific declared behaviors are not present in this code chunk. The code only posts to a single Baidu AI Search web_search endpoint; there is no separate Baidu Baike call. It preserves raw results, but it does not perform result deduplication or assemble a 'research pack' beyond returning payload/response metadata. These are material gaps between the declared description and the actual implemented behavior, so this should be flagged as a mismatch.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

该代码的主功能与声明存在明显范围差异。声明把该 Skill 描述为适合‘查一下/搜索/联网查/最近/最新/热点’等广泛中文搜索场景的百度 API 搜索技能,并暗示百度百科与百度 AI Search 都是常规组成部分;但实际代码是 lookup.py,文档字符串也明确写着“Lightweight Baidu Baike lookup for entity-style questions”。其主流程是:查询百科候选词条、可选抓取前 N 个词条详情、输出 baike_candidates/baike_content/lookup_pack;只有在传入 --fallback-search 且百科无候选时,才调用一次 search_baidu 做网页搜索。因此代码更像‘百科实体消歧/简介查询工具’,而不是面向最新、热点、全网研究的通用搜索 Skill。另一个重要不一致是声明提到‘去重并生成 research pack’,但片段中看不到任何去重实现,输出文件名和渲染函数也都是 lookup_pack 而非 research pack。代码没有明显的额外越权或恶意能力,问题主要是声明夸大了搜索覆盖面与核心能力。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The declared purpose emphasizes an operational Baidu search skill that performs online search via Baidu Baike and Baidu AI Search API, keeps original results, deduplicates them, and assembles a research pack. This code chunk instead performs only an upstream planning function: generating query candidates and selecting a diverse subset according to topic profile and mode. While query planning is related to search, it is not the same primary behavior as executing searches against Baidu services. The only deduplication present is deduplication of generated query strings, not deduplication of fetched search results. There is also no evidence of API credentials, HTTP requests, Baidu endpoints, result handling, or research-pack synthesis. Therefore the code materially under-implements and differs from the declared description.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The recommended trigger phrases are broad enough to match many ordinary user requests such as 'search', 'latest', or 'check this', which can cause the agent to invoke this skill more often than intended. In an agent ecosystem with multiple tools, this increases the chance of inappropriate tool selection, unnecessary external data access, and leakage of user queries to Baidu APIs when a narrower or safer tool would have been more appropriate.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The README recommends invoking the skill for very broad phrases like “查一下”“搜索”“联网查”“最近/最新/热点”, which overlap with common user requests and can cause the agent to route many ordinary queries into external web search without sufficiently explicit user intent. In an agent setting, this increases the chance of unnecessary network access, exposure to prompt-injection-bearing web content, and overuse of a high-authority retrieval path for ambiguous requests.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill declares access to environment variables and instructs running scripts that read/write local files and perform network requests, but it does not define any explicit tool scope such as permissions or allowed-tools. This creates an authorization ambiguity where an agent may grant broader-than-necessary capabilities, increasing the blast radius if the skill is misused or the downstream scripts behave unexpectedly.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill advertises activation on very broad phrases like '查一下/搜索/联网查/最近/最新/热点', which overlap with ordinary user requests. Overbroad triggers can cause the agent to invoke a networked, file-writing skill in situations where a narrower or safer tool would suffice, unnecessarily exposing API keys, external requests, and local side effects.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The instruction to prioritize this skill over generic web_search for broad categories lacks clear boundaries and can bias an agent into overusing a higher-capability tool. In context, this matters because the skill performs network access, reads secrets from the environment, and writes result artifacts, so unnecessary invocation expands data exposure and operational risk.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill prompt explicitly biases behavior toward Chinese-language sources and prioritizes this skill when certain Chinese search-like phrases appear, without confirming the user's language or source preference. This can silently constrain retrieval diversity, produce locale-biased results, and route queries to region-specific sources even when the user did not opt in.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The default prompt uses very broad trigger phrases such as “查一下”“搜索”“联网查”“最近/最新/热点”, which are common in normal user requests. This can cause the skill to activate or be preferred in many situations beyond its narrowly intended scope, potentially overriding safer or more appropriate retrieval tools and creating unintended data-flow or tool-selection behavior.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The document explicitly states that the cache stores raw API responses and request payloads for 24 hours, but it does not warn users that search results or payload content may contain sensitive, personal, or regulated data. In an agent/search skill context, retained raw responses can increase exposure through local disclosure, accidental reuse, or unintended inclusion in later outputs, especially when queries concern current events, people, or internal topics.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
82% confidence
Finding

This markdown reference uses Chinese-only example topics and queries, and later lookup examples continue that locale pattern. Because the file does not state that the skill is China-specific or that users can choose language/locale, it may reflect an undocumented locale constraint in the skill's expected outputs.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The template {topic} {competitor} 对比 embeds a Chinese comparison term directly in the guidance. This imposes a specific language/locale in natural-language behavior without any documented user opt-in or explanation that the skill is region-specific.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest describes a broader workflow: invoking both Baidu Encyclopedia and Baidu AI Search, deduplicating results, and producing a research pack. In this file, the code builds a single POST request to the Baidu AI Search web_search API and outputs the raw result structure, with no Baidu Encyclopedia integration, deduplication logic, or research-pack generation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

When --cache-dir is enabled, the script stores raw queries and full API responses on disk, which may include sensitive search terms, retrieved content, or investigative context. In an agent skill context, searches can contain user-provided or system-derived sensitive data, so silent retention increases the risk of local data disclosure, unintended persistence, and later access by other users/processes.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The file constructs search queries using fixed Chinese terms such as "评测", "官网", "知乎", and similar phrases across its template sets. This enforces a specific language/locale behavior in the skill logic without offering the user a language choice or documenting that the skill is intentionally region-specific, which matches the language/locale policy-violation criterion.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
76% confidence
Finding

The file presents the skill primarily in Simplified Chinese and describes it as intended for Chinese search results, but does not state in the operational guidance that language should follow user preference. Although an English README link exists, the skill-facing guidance does not explicitly offer language or locale choice to the end user.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

The sample request content is written in Chinese, and the live testing checklist repeats the same Chinese query. In a general-purpose reference file, this can imply a fixed language/locale expectation without explicit user opt-in or a stated region-specific justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

The testing command uses a Chinese query string as the default example, but the file does not clarify whether the skill is limited to Chinese-language or Baidu-specific workflows. That can conflict with policy expectations requiring language choice or explicit justification for locale constraints.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
79% confidence
Finding

Multiple usage examples hard-code Chinese search queries, which can imply a fixed language/locale expectation without stating that this is just an example or offering user choice. SQP-3 applies to natural-language policy issues, including forcing a specific language without user opt-in.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
80% confidence
Finding

The docstring presents the behavior as either calling Baidu AI Search or merely printing the request in dry-run mode. However, the implemented non-dry-run path can also persist the full payload and response to a cache directory and optionally write output to a file, which is more than the documented behavior.

Content

No source excerpt is available for this finding.