Back to skill

Security audit

a-share-quant-report

Security checks for vulnerabilities and agentic risk

Overview

The skill matches its quant-report purpose, but its bundled script writes reports to an unconstrained output path and can generate unsafe HTML from environment-controlled text.

Review before installing or running. Use a dedicated, trusted output directory, do not run it with attacker-controlled environment variables, and be cautious opening generated HTML reports if report metadata came from untrusted input. Expect outbound requests to AkShare and yfinance for market data and Chinese-language report defaults.

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
python_report_style_factor_backtest.py:515
Finding

Stored HTML Injection Through Unescaped Report Metadata

Content
View full analysis
{REPORT_TITLE} body {{ font-family: Arial, Helvetica, sans-serif; line-height: 1.6; margin: 28px auto; max-width: 1100px; color: #222; }} h1, h2, h3 {{ color: #1f4e79; }} table {{ border-collapse: collapse; width: 100%; margin: 12px 0 20px 0; }} th, td {{ border: 1px solid #d9d9d9; padding: 8px 10px; text-align: right; }} th:first-child, td:first-child {{ text-align: left; }} .card {{ background: #f8fbff; border: 1px solid #dbe5f1; border-radius: 10px; padding: 14px 18px; margin: 12px 0; }} .small {{ color: #666; font-size: 13px; }}

{REPORT_TITLE}

研究问题与核心结论

研究问题:{RESEARCH_QUESTION}

因子逻辑:{FACTOR_NARRATIVE}

本报告自动按照金工研报的典型展示链路输出:因子定义、有效性检验、分层收益、组合回测、风险与可实施性。

样本与回测设定

  • 目标下载股票数:{summary['target_download_stocks']}
  • 实际成功下载股票数:{summary['actual_download_stocks']}
  • 下载失败或历史长度不足数量:{summary['failed_or_short_history']}
  • 回测区间:{summary['date_start']} 至 {summary['date_end']}
  • 调仓频率:周频
  • 持仓数:Top {TOP_N}
  • 分组数:{QUANTILES}
  • 基准:{BENCHMARK}
  • 成本假设:单边 {TCOST_ONE_WAY:.2%}

候选池说明:{UNIVERSE_NOTE}

图表展示

{''.join(image_blocks)}
''' wit ...[truncated 2025 chars]
Remediation
View remediation
` content. 3. Prefer a template engine configured with automatic HTML escaping rather than constructing the document with an f-string. 4. If limited formatting is intentionally supported, sanitize input with a strict allowlist that rejects scripts, event attributes, iframes, unsafe URLs, SVG, and similar active content. 5. Add a restrictive Content Security Policy to the generated report, for example one that denies scripts and remote connections when the report requires only inline images and CSS. 6. Add tests using payloads containing tags, quotes, event handlers, and encoded markup to verify that the output displays them as text rather than interpreting them as HTML. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
python_report_style_factor_backtest.py:19
Finding

Unrestricted Output Directory Enables File Overwrite Through Predictable Paths and Symbolic Links

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
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (17)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
当任务属于“因子研究 / 分层回测 / 多头多空组合”时,优先使用随 skill 一起提供的 `python_report_style_factor_backtest.py` 作为基础框架,再按研报替换:

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
当任务属于“因子研究 / 分层回测 / 多头多空组合”时,优先使用随 skill 一起提供的 `python_report_style_factor_backtest.py` 作为基础框架,再按研报替换:

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
当任务属于“因子研究 / 分层回测 / 多头多空组合”时,优先使用随 skill 一起提供的 `python_report_style_factor_backtest.py` 作为基础框架,再按研报替换:

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · image-display-guidelines.md (reported line 1)May include surrounding context.

md
# Image Display Guidelines v1.2

## 目标
回测或跟踪完成后,自动把关键图片按章节顺序直接展示出来,而不是只给路径、文件名或一句“已生成图表”。

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
70% confidence
Finding

Without declared permissions the skill's intent is opaque and cannot be validated.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The manifest description is written as an instruction for a Chinese-market quant research skill and the entire skill content is presented only in Chinese, with no indication that users may choose another language. Under the stated policy, forcing a specific language or locale without opt-in is a natural-language policy violation unless the constraint is explicitly documented and justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The file's headings and usage guidance are presented only in Chinese, which can amount to a language-policy violation when the skill does not offer user opt-in or an alternative locale. Nothing in the file explains that the skill is intentionally region-specific or limited to Chinese-speaking users.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file is entirely written as mandatory output instructions in Chinese, including required section structure and phrasing cues, but it does not indicate that the user can choose another language. This creates a natural-language locale policy issue because the skill appears to enforce a specific language without opt-in or justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This file contains user-facing natural-language instructions solely in Chinese, including the objective, rules, and required outputs. Under the stated policy, forcing a specific language without user opt-in or explicit justification is a locale/language policy concern.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The file’s operational instructions are entirely written in Chinese, including required display phrasing and presentation rules, with no indication that the user may choose another language. Under the policy, a skill that imposes a specific language without opt-in is a natural-language policy violation unless the locale restriction is clearly justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script hardcodes report content in Chinese and sets the HTML document language to zh-CN, which enforces a specific language/locale choice in generated user-facing outputs. The file does not offer a language selection mechanism or document this as a justified region-specific constraint.

Content

No source excerpt is available for this finding.

Tainted flow: 'OUT_DIR' from os.getenv (line 19, credential/environment) → open (file write)

Medium
Category
Data Flow
Confidence
65% confidence
Finding

Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.

Content

Scanner excerpt · python_report_style_factor_backtest.py (reported line 654)May include surrounding context.

python
'quantiles': QUANTILES,
        'transaction_cost_one_way': TCOST_ONE_WAY,
    }
    with open(os.path.join(OUT_DIR, 'run_summary.json'), 'w', encoding='utf-8') as f:
        json.dump(run_summary, f, ensure_ascii=False, indent=2)

    make_plots(alpha, ic_df, group_ret, port_nav, bench_nav, ls_nav, turnover, coverage, OUT_DIR)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The guideline is written as a normative instruction set and states the output objective in Chinese, framing the required presentation style without any user opt-in for language or locale. Under the policy, forcing a specific language is a natural-language policy violation unless the skill offers a choice or clearly documents a justified regional constraint.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The skill explicitly requires the final dialogue to mimic a research report, which constrains output style without user opt-in. While this is not a classic security exploit, it can override user preferences, reduce transparency, and make the agent less responsive to user-requested format or language changes.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

This markdown template is entirely structured in Chinese and provides no indication that another language may be used or that the language requirement is optional. Under the policy criteria, a skill artifact that forces a specific language without user opt-in can constitute a locale/language policy violation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
80% confidence
Finding

The call to AkShare retrieves index constituent data from an external source, which is a network action under the missing-warning rule for code files. The file contains no nearby warning, comment, or user-facing message telling the user that outside data providers will be contacted.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The script downloads market data from yfinance for many tickers, which is a network operation that transmits request metadata and query parameters to an external service. Although this is central to the script's functionality, there is no inline comment, docstring, or user-facing notice near the call explaining that external HTTP requests will be made.

Content

No source excerpt is available for this finding.