Back to skill

Security audit

法律数据库检索助手

Security checks for vulnerabilities and agentic risk

Overview

The skill matches a legal-research purpose, but it needs review because it runs a mutable third-party MCP package with an API key and creates unsanitized HTML reports from legal data.

Install only if you trust the legal-data providers and pin or otherwise verify the npm MCP server before use. Treat generated HTML reports as sensitive files, avoid opening reports built from untrusted records until the generator escapes HTML, and keep provider API tokens scoped and rotated if exposed to third-party tooling.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/report_generator.py:72
Finding

Stored HTML and JavaScript Injection in Generated Legal Reports

Content
View full analysis
未检索到相关法规", cases_section=cases_html if cases_html else "

未检索到相关案例

", similar_section=similar_html if similar_html else "

未检索到类案

", analysis_section=analysis_html if analysis_html else "

暂无分析建议

", ) ``` Legal-data fields are also interpolated without HTML escaping: ```python items.append(f"""
{title} {num}
{sxx} {effect}
{content}
""") ``` Case information is handled in the same unsafe manner: ```python items.append(f"""
{title or case_num} {case_num}
🏛️ {court} 📅 {date} 📋 {procedure}
{summary}
{f'
判决结果:{result}
' if result else ''}
""") ``` Similar-case fields a ...[truncated 3023 chars]
Remediation
View remediation
str: if value is None: return "" return escape(str(value), quote=True) ``` Apply this function to the title, query, source, legal fields, case fields, similar-case fields, and every analysis item. 2. Prefer an auto-escaping template engine such as Jinja2: ```python from jinja2 import Environment, select_autoescape env = Environment(autoescape=select_autoescape(["html", "xml"])) ``` Keep trusted structural HTML separate from untrusted text values. 3. Validate the input schema before rendering. Require expected container and scalar types, reject unexpected objects, and enforce reasonable field-length limits. 4. If selected rich-text fields must support formatting, sanitize them with a maintained HTML sanitizer and a minimal allowlist. Do not permit script elements, event-handler attributes, embedded frames, active URLs, or arbitrary styles. 5. Add a restrictive Content Security Policy to the generated report, for example: ```html ``` CSP should be defense in depth and must not replace output escaping. 6. Add automated tests using payloads in every report field, including closing tags, script elements, event handlers, encoded markup, and malicious URL schemes. Verify that payloads appear only as text in the resulting report. ]]>

T08 · Insecure Dependencies

Warning
Location
SKILL.md:57
Finding

Automatic Execution of an Unpinned npm Package

Content
View full analysis
Remediation
View remediation
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 (12)

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

声明描述的是一个覆盖检索、查证、类案分析、报告生成的综合法律数据库助手;但所给代码片段只是“类案分析引擎”的一部分,对输入案例数据做本地统计和文本规则分析。代码中没有任何网络请求、数据库访问、MCP调用、法规检索、案例检索或HTML生成功能。虽然‘类案分析’这一子能力与声明部分一致,但整体声明明显超出了该代码块实际行为,因此描述与代码行为存在实质不匹配。

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
70% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

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

2. 配置北大法宝 MCP(权威补充)

bash
# 1. 访问 https://mcp.pkulaw.com/ 注册获取 Access Token
# 2. 在控制台购买需要的MCP服务
# 3. 将以下配置添加到 WorkBuddy MCP 配置

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
85% confidence
Finding

The skill explicitly instructs the agent to run local Python scripts and produce HTML output files, which implies file read/write behavior, but it declares no tool scope or permissions boundary. Missing scope declarations weaken least-privilege controls and make it harder for users or the platform to understand and constrain local filesystem access.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The skill’s natural-language instructions and description are entirely in Chinese and present the capability as the default experience, without offering user language choice or explicitly documenting a justified locale restriction. Under the policy, forcing a specific language without opt-in can be a natural-language policy violation unless the locale constraint is clearly documented and justified.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
70% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · references/api-guide.md (reported line 62)May include surrounding context.

"return_num": 20, }

response = requests.post(url, json=payload, headers=headers, timeout=60) print(response.json())

text

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

This Python file contains natural-language descriptions entirely in Chinese, including the module docstring and later user-facing CLI/help strings, but does not indicate that the skill is region-specific or provide any opt-in language selection. Under the policy, forcing a specific language without user choice is a natural-language locale violation.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The manifest describes a legal database search assistant providing retrieval, verification, similar-case analysis, and report generation, but this file’s CLI implementation also performs arbitrary local filesystem writes via a user-supplied output path. Persisting results to local files is not stated in the manifest and goes beyond pure retrieval/analysis behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module docstring presents the skill entirely in Chinese and frames its purpose and usage in that language, with no indication that users may choose another language or locale. This is a natural-language policy concern because the skill appears to enforce a single language experience without opt-in 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 skill's natural-language description, CLI messages, defaults, and HTML template are all hard-coded in Chinese, and the HTML declares zh-CN as the page language. There is no indication that the user can opt into this locale or that the skill is intentionally limited to a China-specific compliance or jurisdiction-only workflow.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The skill generates a local HTML file but does not prominently warn users in the main description that a filesystem artifact will be created. This can lead to unexpected local writes and accidental opening/sharing of generated reports that may contain sensitive legal matter details.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
97% confidence
Finding

The docstring for _cluster_by_court says it clusters by both court level and geography, which implies regional grouping. In reality, the function only inspects court names to assign one of several court-level buckets and never extracts or groups by region.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

This code writes a generated HTML report containing input query, cases, laws, and analysis data to a filesystem path. Although the function name and CLI arguments imply report generation, there is no explicit warning in the code comments or user-facing output before the write that potentially sensitive legal matter data will be saved locally.

Content

No source excerpt is available for this finding.