Back to skill

Security audit

百度热榜监控 | Baidu Hot Monitor

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly matches its Baidu hot-topics purpose, but its generated report can render remote data unsafely and its advertised scope is broader than the code supports.

Review this skill before installing if you plan to generate or open the HTML report. It does not show credential theft, persistence beyond its local database/report files, or malicious system changes, but the report generator should be fixed to escape remote data and avoid innerHTML before being used with untrusted or hosted reports.

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

Warning
Location
scripts/generate_html.py:218
Finding
Stored Cross-Site Scripting in the Generated HTML Report<![CDATA[ ## Vulnerability Details **File Location**: `scripts/generate_html.py:218-242` and `scripts/generate_html.py:286-313` **Vulnerability Type**: Stored Cross-Site Scripting (Stored XSS) **Risk Level**: Medium ### Vulnerable Code ```python for cat in categories: html += f' <option value="{cat}">{cat}</option>\n' html += f''' </select> </div> <div class="filter-group"> <label>搜索</label> <input type="text" id="searchInput" placeholder="输入关键词..."> </div> <button class="btn" onclick="resetFilters()">重置</button> </div> <div class="stats"> <span>显示 <span class="highlight" id="showCount">{len(items)}</span> / {len(items)} 条</span> </div> <div class="content"> <div class="hot-list" id="hotList"></div> </div> <script> const items = {json.dumps(items, ensure_ascii=False)}; const categoryColors = {json.dumps(CATEGORY_COLORS, ensure_ascii=False)}; ``` ```python let html = ''; Object.keys(grouped).sort().reverse().forEach(date => {{ html += grouped[date].map(item => {{ const bgColor = categoryColors[item.category] || '#868e96'; return ` <a href="${{item.url}}" class="hot-item" target="_blank" style="text-decoration: none; color: inherit;"> <div class="rank ${{getRankClass(item.rank)}}">${{item.rank}}</div> <div class="item-content"> <div class="item-title">${{item.title}}</div> <div class="item-meta"> <span class="category-badge" style="background: ${{bgColor}}">${{item.category}}</span> <span style="color: #999;">${{item.date}}</span> </div> </di ...[truncated 4463 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. **Do not render remote data through `innerHTML`.** Build each item with DOM APIs and assign untrusted strings through `textContent`. ```javascript const title = document.createElement('div'); title.className = 'item-title'; title.textContent = item.title; ``` 2. **Store serialized data in a non-executable element.** For example, use `<script type="application/json">`, then parse its text content. Before embedding JSON in HTML, escape characters significant to the HTML parser, including `<`, `>`, and `&`. ```python serialized_items = json.dumps(items, ensure_ascii=False) serialized_items = ( serialized_items .replace('&', '\\u0026') .replace('<', '\\u003c') .replace('>', '\\u003e') ) ``` 3. **Apply context-specific HTML escaping** to values written into server-generated markup, including dates and category names. ```python from html import escape safe_cat_text = escape(str(cat)) safe_cat_attr = escape(str(cat), quote=True) html += f'<option value="{safe_cat_attr}">{safe_cat_text}</option>' ``` 4. **Validate links before assigning them.** Parse each URL and allow only HTTPS links to the expected Baidu host. Reject unsafe schemes such as `javascript:` and `data:`. 5. **Add `rel="noopener noreferrer"`** to links opened with `target="_blank"`. 6. **Deploy a restrictive Content Security Policy.** Prefer external JavaScript and disallow inline script execution, for example with a policy based on `script-src 'self'`. A CSP should be defense in depth rather than a substitute for output encoding. 7. **Validate upstream fields.** Enforce expected types, reasonable maximum lengths, and allowed category values before persistence. 8. **Add regression tests** using payloads containing `</script>`, quotes, HTML closing tags, event-handler attributes, and unsafe URL schemes. Verify that generated reports display these payloads as inert text. ]]>
Vulnerability Patterns
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • 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 (12)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The code clearly implements only one portion of the declared description: retrieving the Baidu realtime hot topics list. It sends an HTTP request to Baidu's hot-board API, extracts ranked titles and simple category labels, and returns/output those entries. However, the description also states capabilities for '搜索趋势 / trends' and '关键词热度 / keyword popularity', which are not actually present. The script does not accept a keyword input, does not query any trend endpoint, and does not compute or return popularity metrics except leaving 'search_count' empty. There are no undeclared harmful capabilities, but the declared description overstates the implemented functionality, so this is a description-behavior mismatch.

Lp3

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding
The skill advertises capabilities that imply shell execution, network access, and file writing, but it does not declare any tool scope or permission boundaries. This is dangerous because an agent may execute broader actions than users expect, including writing local files or making outbound requests, without explicit governance or least-privilege constraints.

Vague Triggers

Medium
Confidence
96% confidence
Finding
Broad trigger phrases like '百度', '热搜', and 'baidu' are likely to match ordinary conversation, causing the skill to activate unexpectedly. Unintended activation is risky here because the skill also implies network, shell, and file-write behaviors, so casual mentions could lead to unnecessary external requests or local side effects.

Description-Behavior Mismatch

Medium
Confidence
92% confidence
Finding
The skill expands from simple monitoring into local database persistence and HTML report generation, which materially increases its capability footprint. Even if presented as documentation, this broadening introduces data retention, file creation, and report-generation risks that exceed the minimal expectations of a search/trending monitor and could store sensitive queries or produce unsafe local artifacts.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
The HTML document declares `lang="zh-CN"`, and the visible UI text throughout the page is exclusively in Simplified Chinese. Under the policy, forcing a specific language without user opt-in or documented justification is a natural-language policy violation.

Natural-Language Policy Violations

Medium
Confidence
93% confidence
Finding
The generated document sets `lang="zh-CN"`, and the UI text throughout the file is fixed in Chinese, which imposes a specific language/locale on all users. The file does not offer a language choice or document that this skill is intentionally limited to a Chinese-only regional context.

Natural-Language Policy Violations

Medium
Confidence
97% confidence
Finding
This Python file contains natural-language descriptions and console messages entirely in Chinese, including the module docstring and runtime output. Under the policy rules, forcing a specific language without user opt-in is a natural-language policy violation unless the locale limitation is explicitly justified, which is not present here.

subprocess module call

Medium
Category
Dangerous Code Execution
Content
try:
        # 调用原有脚本获取数据
        result = subprocess.run(
            [sys.executable, str(script_path), str(limit), '--json'],
            capture_output=True,
            text=True,
Confidence
70% confidence
Finding
subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Description-Behavior Mismatch

Medium
Confidence
92% confidence
Finding
Saving items with save_hot_items() and recording operational logs with log_fetch() are write-side effects not conveyed by the manifest's retrieval-focused wording. While fetching Baidu trends is expected, persistent database writes are an additional behavior users would not infer from the current description alone.

Description-Behavior Mismatch

Medium
Confidence
94% confidence
Finding
The manifest describes getting Baidu hot searches, trends, and keyword popularity, which suggests retrieval/monitoring behavior. This script goes beyond retrieval by creating a database if needed and saving results persistently, which is a broader data-storage behavior not stated in the manifest description.

Natural-Language Policy Violations

Low
Confidence
95% confidence
Finding
The request sets `Accept-Language` to prefer `zh-CN` and `zh`, which forces a specific locale behavior at runtime. Under the policy, language or locale constraints should be user-selectable or clearly justified, and this file does neither.

Natural-Language Policy Violations

Low
Confidence
83% confidence
Finding
This code file contains natural-language descriptions only in Chinese or bilingual Chinese-first form, such as the module title and docstrings, with no indication that language is configurable or optional for users. Under the stated policy, forcing a specific language or locale without opt-in can be a natural-language policy concern.

Static analysis

No suspicious patterns detected.