Back to skill

Security audit

AI国学大师

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly a local Chinese-culture report generator, but it can write reports to arbitrary paths and embeds user input into HTML without escaping.

Review before installing. Use only with trusted invocation arguments, keep output paths in a dedicated report folder, avoid opening reports generated from untrusted query text, and do not rely on the advertised AI/network/corpus claims until the artifact is corrected.

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

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/guoxue.py:794
Finding

Unescaped Query Injection in Generated HTML Reports

Content
View full analysis

未找到与「{query}」相关的经典内容

" items_html = "" for i, item in enumerate(data, 1): items_html += f"""

📖 {i}. {item['classic']} · {item['chapter']}

{item['school']} {item['era']} {item['author']}

📜 原文

「{item['text']}」

📝 白话译文

{item['translation']}

💡 深度解读

{item['insight']}

""" return f""" 经典解读:{query} ...

📖 经典解读

查询:{query}

{items_html}
""" def generate_poetry_report(data, query): """生成诗词赏析报告""" if not data: return f"

未找到与「{query}」相关的诗词

" ``` The same unsafe interpolation also occurs in the poetry report at lines 871 and 888 and in the idiom report at line 898. ### Technical Analysis The command-line `--query` value is controlled by the caller and is inserted directly into generated HTML through Python formatted strings. No contextual HTML encoding, sanitization, or restrictive Content Security Policy is applied. A value containing markup such as: ```html ``` can therefore become active HTML when a generated report is ...[truncated 2165 chars]
Remediation
View remediation

" f"No classic content found for “{safe_query}”" "

" ) ``` 3. Prefer an auto-escaping template engine such as Jinja2 rather than constructing HTML with formatted strings. Keep auto-escaping enabled for HTML templates. 4. Treat all dynamic values as untrusted, including future LLM responses, network-derived content, imported databases, and metadata fields. Encode according to context: - HTML text encoding for element content. - HTML attribute encoding for attribute values. - URL validation for links. - JavaScript serialization for values placed in scripts. 5. Add a restrictive Content Security Policy to generated reports as defense in depth: ```html ``` 6. Add regression tests using payloads such as: ```text ``` Tests should verify that these values appear only as encoded text and never produce executable elements. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/guoxue.py:1185
Finding

Unrestricted Output Path Allows Arbitrary Writable-File Overwrite

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • 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
Findings (12)

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The code substantially aligns with the general domain and feature set of a guoxue assistant: it supports classic interpretation, poetry appreciation, idiom lookup, I Ching simulation, solar-term wellness, daily quotes, and HTML report generation. However, there are material description-behavior mismatches. First, the description emphasizes an AI assistant, yet the code contains no AI inference, no network calls, and no use of the provided API key/base/model arguments. Second, several scale/coverage claims are overstated: the classics, poetry, idiom, and I Ching data are hardcoded and limited; the '64卦详解' is only partially complete, and '6万条成语' is clearly not present. Third, the advertised comprehensive report capability is not actually implemented, since report mode falls back to the demo report. No undeclared sensitive permissions or resource access are present, but the descriptive claims materially overstate the implemented behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

The instruction says responses about Hong Kong, Taiwan, and Macau '必须明确标注地区归属', which enforces a specific political/locale framing in all such cases. This is a natural-language policy constraint that does not offer user opt-in or a clearly documented region-specific compliance justification.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
76% confidence
Finding

The skill advertises generation of HTML reports and the associated codebase reportedly has file-write capability, but the manifest does not declare any tool scope or permissions. This creates a transparency and containment gap: a host agent may invoke a skill that writes files without an explicit policy boundary, increasing the risk of unintended filesystem modification or unsafe output placement.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The manifest includes highly generic trigger words such as broad cultural and literary terms, making accidental activation more likely. This can route unrelated user content into a skill that may perform report generation or network-backed enrichment, expanding data exposure and unexpected behavior.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
80% confidence
Finding

The skill supports sending queries to an external API endpoint, which can transmit user-provided text off-platform. In this context, users may submit sensitive personal, health, or belief-related questions, so external transmission materially increases privacy and data-handling risk if not clearly disclosed and controlled.

Content

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

md
| `--query` | ❌ | - | 查询关键词(经典名句、诗名、成语等) |
| `--output` | ❌ | ./guoxue_report.html | 输出HTML报告路径 |
| `--api-key` | ❌ | - | LLM API Key(DeepSeek/OpenAI兼容;无Key使用内置数据库) |
| `--api-base` | ❌ | https://api.deepseek.com/v1 | API Base URL |
| `--model` | ❌ | deepseek-chat | 模型名称 |

## 触发场景

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The trigger conditions are broad enough to match generic cultural, poetry, wellness, or divination queries, which can cause unintended skill invocation. In an agent environment, overbroad routing can expose user prompts to unnecessary processing paths, external lookups, or file-generation behaviors that the user did not specifically request.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The manifest describes coverage across '四书五经/道德经/庄子等' and '成语典故(6万条)', implying extensive corpus support. In code, CLASSICS_DB contains only a handful of works, POETRY_DB only a few poems, and CHENGYU_DB only several idioms, so the actual content scope materially underdelivers relative to the stated behavior.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The generated HTML explicitly sets lang="zh-CN", and the skill’s user-facing titles, help text, and outputs are all hard-coded in Chinese throughout the file. This imposes a specific language/locale on users without any opt-in, fallback, or documented region-specific justification, which matches the language/locale policy-violation category.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The manifest advertises '易经占卜(64卦详解)', but the database only defines full 'yao' patterns for hexagrams 1-6 and adds several others in simplified form without 'yao' values. Since simulate_yijing() resolves hexagrams by matching generated yao strings, many outcomes will leave ben_gua or bian_gua unresolved, so the implemented behavior falls short of the described capability.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% 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 · scripts/guoxue.py (reported line 1187)May include surrounding context.

python
parser.add_argument("--query", default="", help="查询关键词")
    parser.add_argument("--output", default="guoxue_report.html", help="输出路径")
    parser.add_argument("--api-key", default="", help="API Key")
    parser.add_argument("--api-base", default="https://api.deepseek.com/v1", help="API Base URL")
    parser.add_argument("--model", default="deepseek-chat", help="模型名称")
    args = parser.parse_args()

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The docstring at L0652 says '获取当前最近的节气', but the implementation simply iterates by month and returns the first matching term. For months with two solar terms, this does not compute the nearest term by date and can contradict the documented intent.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
98% confidence
Finding

The docstring and mode name imply a synthesized report based on provided data/query, yet generate_comprehensive_report() immediately delegates to generate_demo_report() without using either argument. This is a direct contradiction between stated intent and actual behavior.

Content

No source excerpt is available for this finding.