Back to skill

Security audit

stock-deep-backtest

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly a disclosed stock backtest diagnostic tool, but it uses hard-coded local WorkBuddy paths and can read or write prior backtest artifacts without tight user-controlled scoping.

Install only if you are comfortable with a Chinese-language QuantAll stock-analysis skill that reads local QuantAll market data and writes analysis reports/artifacts to WorkBuddy skill directories. Pass input files explicitly, review or adjust hard-coded paths before running scripts, and treat generated HTML reports as local files that should not consume untrusted JSON without sanitization.

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/make_report_html.py:11
Finding

Unescaped Report Data and Unrestricted Path Construction

Content
View full analysis
1 else "golden_cross" import os res_file = f"{BASE}/full_attribution_result_{strat}.json" if not os.path.exists(res_file): res_file = f"{BASE}/full_attribution_result.json" D = json.load(open(res_file, encoding="utf-8")) ``` ```python q_rows = "" for k, v in A.get("quarters", {}).items(): cls = "pos" if str(v).startswith("+") else "neg" q_rows += f"{k}{v}" ``` ```python qs = D["quarter_share"] qmax = max(qs.values()) if qs else 1 qbar = "" for q, v in qs.items(): w = v / qmax * 100 qbar += f"""
{q}
{v*100:.1f}%
""" ``` ```python
{M['date_range']} · {M['n_stocks']:,} 只股票 · stock-deep-backtest 技能 · 计算耗时 {M['runtime_s']}s
``` ```python OUT = f"{BASE}/full_attribution_report_{strat}.html" open(OUT, "w", encoding="utf-8").write(HTML) ``` ### Technical Analysis The renderer correctly applies `html.escape()` to some values, such as factor names and the strategy title, but it directly interpolates other JSON-derived strings into the generated HTML. In particular, quarter keys, quarter values, and metadata such as `date_range` are inserted without contextual HTML escaping. If an attacker can modify a consumed `base_*.json` or `full_attribution_result_*.json` file, those fields can contain HTML elements or script-capable markup. The resulting payload becomes part of the generated report and can execute when the user opens it in a browser. The command-line `strat` value is also used directly when constructing input and output filenames. It ...[truncated 1993 chars]
Remediation
View remediation
1 else "golden_cross" if strat not in ALLOWED_STRATEGIES: raise ValueError(f"Unsupported strategy: {strat!r}") ``` 2. Escape every textual value inserted into HTML, not only selected fields: ```python def esc(value): return html.escape(str(value), quote=True) q_rows += ( f"{esc(k)}{esc(v)}" f"" ) ``` 3. Apply the same escaping to `date_range`, quarter labels, and every other string obtained from JSON. 4. Validate loaded JSON against a strict schema. Require numeric fields to be finite numbers and textual fields to follow expected formats. 5. Use `pathlib.Path` and verify that resolved input and output paths remain under `BASE`: ```python base = Path(BASE).resolve() output = (base / f"full_attribution_report_{strat}.html").resolve() if output.parent != base: raise ValueError("Output path escapes the report directory") ``` 6. Prefer a template engine with automatic HTML escaping rather than assembling large HTML documents through direct f-string interpolation. 7. If reports may contain untrusted data, add a restrictive Content Security Policy that blocks inline scripts and unnecessary network connections. This should be defense in depth and not a substitute for output escaping. ]]>

T09 · Insecure Skill Coding Practices

Note
Location
scripts/timeline_analysis.py:201
Finding

Predictable Temporary File Allows Symlink-Based File Overwrite

Content
View full analysis
/path/to/a/file/writable/by/the/victim ``` 3. The victim runs `timeline_analysis.py` without a timeline text argument, causing the self-test branch to execute. 4. `open(tmp, "w")` follows the symbolic link. 5. The linked target is truncated and replaced with generated timeline text. 6. The subsequent `os.remove(tmp)` removes the temporary-directory link, potentially obscuring evidence of the redirection. ### Impact Assessment The attacker may overwri ...[truncated 510 chars]
Remediation
View remediation
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (38)

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

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

md
- 通用:`run_codes` 一次拉多矩阵(hold/ret/因子…)+ duckdb 读 `stock_basic`;日收益先 1%/99% 截尾防停牌缺口极端值;`scripts/factor-screen-final-50.xlsx` 为 50 个清洗因子参考库(name/code/IR)。

Chaining Abuse

High
Category
Tool Misuse
Confidence
75% confidence
Finding

Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.

Content

Scanner excerpt · scripts/output/factor-TA_Indicators.xlsx!/xl/sharedStrings.xml (reported line 71)May include surrounding context.

text
out = 100*(1 - rolling_imax(ah, 20))</t></si><si><t>TA_AROON_DOWN20</t></si><si><t>ah = d['high']*d['adj_factor']; al = d['low']*d['adj_factor']
out = 100*(1 - rolling_imin(al, 20))</t></si><si><t>TA_AROON_OSC20</t></si><si><t>ah = d['high']*d['adj_factor']; al = d['low']*d['adj_factor']
out = 100*(1-rolling_imax(ah,20)) - 100*(1-rolling_imin(al,20))</t></si><si><t>TA_CMO14</t></si><si><t>ac = d['close']*d['adj_factor']
dd = ac.diff(); su = dd.clip(lower=0).rolling(14).sum(); sd = (-dd).clip(lower=0).rolling(14).sum()
out = (su-sd)/(su+sd+1e-12)*100</t></si><si><t>TA_CMOU14</t></si><si><t>ac = d['close']*d['adj_factor']
dd = ac.diff(); up = dd.clip(lower=0); dn = (-dd).clip(lower=0)
out = (up-dn)/(dd.abs()+1e-12)*100</t></si><si><t>TA_BOP</t></si><si><t>ac = d['close']*d['adj_factor']; ah = d['high']*d['adj_factor']; al = d['low']*d['adj_factor']; ao = d['open']*d['adj_factor']

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The manifest says this skill should be used for deep diagnosis of '已回测的策略' and explicitly says it should not trigger for requests like '跑个回测看收益'. However, this script embeds full trading strategy definitions (golden_cross, reversal, macd), selects one from CLI input, and executes it through QuantAll via run_codes to generate buy/sell signals and returns from raw market data. That is primary backtest execution behavior, not merely post-backtest attribution.

Content

No source excerpt is available for this finding.

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · scripts/segment_batch_move_result.csv (reported line 1)May include surrounding context.

text
name,IR,global,best30,improve,spread,trend,agree,n,time_share_mean,time_share_max,time_share_min,curve
GTJA_Alpha70,-0.6428,0.013762606,0.020131558,0.006368952,-0.013149813,降,True,69436,0.2997352185836836,0.3014354066985646,0.2959413754227734,+2.5 +1.8 +1.8 +1.1 +1.3 +1.2 +0.8 +1.1 +1.1 +1.1
Alpha#44,0.8564,0.013761866,0.019113773,0.0053519076,0.017017912,升,True,69435,0.30032316113458457,0.3038331454340473,0.29904306220095694,+0.4 +1.2 +1.1 +1.3 +1.3 +1.4 +1.3 +1.8 +1.9 +2.1
GTJA_Alpha74,-0.6191,0.015637228,0.020616926,0.004979698,-0.014269675,降,True,63841,0.2992998904648769,0.3005483813904122,0.29501698754246886,+2.2 +2.0 +1.9 +1.7 +1.2 +1.4 +1.7 +1.5 +1.1 +0.8

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · scripts/segment_combo_eval_result.csv (reported line 1)May include surrounding context.

text
name,IR,global,best30,improve,spread,trend,agree,n,time_share_mean,time_share_max,time_share_min,curve
GTJA_Alpha70,-0.6428,0.013762606,0.020131558,0.006368952,-0.013149813,降,True,69436,0.2997352185836836,0.3014354066985646,0.2959413754227734,+2.5 +1.8 +1.8 +1.1 +1.3 +1.2 +0.8 +1.1 +1.1 +1.1
Alpha#44,0.8564,0.013761866,0.019113773,0.0053519076,0.017017912,升,True,69435,0.30032316113458457,0.3038331454340473,0.29904306220095694,+0.4 +1.2 +1.1 +1.3 +1.3 +1.4 +1.3 +1.8 +1.9 +2.1
GTJA_Alpha74,-0.6191,0.015637228,0.020616926,0.004979698,-0.014269675,降,True,63841,0.2992998904648769,0.3005483813904122,0.29501698754246886,+2.2 +2.0 +1.9 +1.7 +1.2 +1.4 +1.7 +1.5 +1.1 +0.8

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · scripts/segment_screen_eval_result.csv (reported line 1)May include surrounding context.

text
name,IR,global,best30,improve,spread,trend,agree,n,time_share_mean,time_share_max,time_share_min,curve
GTJA_Alpha70,-0.6428,0.013762606,0.020131558,0.006368952,-0.013149813,降,True,69436,0.2997352185836836,0.3014354066985646,0.2959413754227734,+2.5 +1.8 +1.8 +1.1 +1.3 +1.2 +0.8 +1.1 +1.1 +1.1
Alpha#44,0.8564,0.013761866,0.019113773,0.0053519076,0.017017912,升,True,69435,0.30032316113458457,0.3038331454340473,0.29904306220095694,+0.4 +1.2 +1.1 +1.3 +1.3 +1.4 +1.3 +1.8 +1.9 +2.1
GTJA_Alpha74,-0.6191,0.015637228,0.020616926,0.004979698,-0.014269675,降,True,63841,0.2992998904648769,0.3005483813904122,0.29501698754246886,+2.2 +2.0 +1.9 +1.7 +1.2 +1.4 +1.7 +1.5 +1.1 +0.8

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The skill explicitly documents file-writing behavior through report generation and local output artifacts, but it does not declare any tool restrictions such as permissions or allowed-tools. In an agent setting, undeclared write capability increases the risk of unexpected filesystem side effects, especially because the skill encourages running scripts and task files that can persist data locally.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill states that oversized MCP results are automatically persisted to tool-results/*.txt and frames this as normal behavior, but it does not present it as a user-visible data storage event requiring consent. Automatic persistence of large analytical outputs can expose proprietary trading logic, market data, or intermediate results on disk without the user's awareness.

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, usage text, and subsequent user-facing messages are written entirely in Chinese, which imposes a specific language on users without offering an opt-in or alternative locale. Under the policy, language constraints should either be optional for the user or clearly justified as region-specific.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The generated document sets lang="zh-CN" and all visible report text is fixed in Chinese, while the file comments and usage do not indicate that the skill is intentionally region-specific or that users can opt into this locale. This is a natural-language policy concern because it forces a specific language experience without user choice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

This file contains natural-language instructions and status messaging entirely in Chinese, including the module docstring and printed completion messages. Because the skill does not offer any language opt-in or indicate that it is intentionally limited to a Chinese-speaking or region-specific audience, it creates a locale-policy concern under the natural-language policy rule.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The manifest frames the skill as a deep-diagnosis tool for an already-run strategy, but the code contains a menu of built-in strategies ('golden_cross', 'reversal', 'macd') and lets the operator choose among them at runtime. This makes the skill operate as a strategy runner/template library in addition to an attribution analyzer, which exceeds the described scope.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

This plain-text file presents all operational and result messages in Chinese, with no indication that the language was user-selected or that the skill is intended only for a Chinese-speaking or region-specific context. That creates a natural-language locale policy concern because it effectively imposes a specific language without opt-in.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The output log writes results to C:/Users/CMF/.workbuddy/skills/backtest-attribution/... while the manifested skill is stock-deep-backtest. This cross-skill path reference can cause data to be written into the wrong skill directory, leading to integrity issues, confusing provenance, accidental data exposure between skills, or one skill unintentionally overwriting another skill's artifacts.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This README presents all operational instructions in Chinese and does not indicate that users may choose another language or locale. Under the policy for natural-language constraints, a skill that effectively requires a specific language without opt-in is a policy concern.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The manifest says this skill should not proactively handle "跑个回测看收益" requests and that such work belongs to the separate strategy_backtest skill, while this skill focuses on diagnosis of already backtested strategies. However, this task file is configured to call the "strategy_backtest" tool directly, indicating the skill itself can run a raw backtest operation rather than only analyze prior backtest outputs.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest states this skill should not proactively handle '跑个回测看收益' requests and that deep diagnosis is its scope, yet this task is wired to call the strategy_backtest tool directly. Although segment-view data may be an input to later attribution, this file itself performs a backtest operation rather than purely analyzing an already-produced backtest result.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest explicitly says this skill should not trigger for requests like 'run a backtest to see returns' and positions itself as analyzing already-backtested strategies. However, this task is wired to the strategy_backtest tool, indicating the skill can directly run a backtest timeline rather than only perform downstream diagnosis on existing results.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The value "所属行业" is a Chinese-language field name, indicating the skill is configured around a specific language/locale. In this file there is no visible indication that users can choose their preferred language or that the locale restriction is documented and justified.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

The documentation instructs users to generate HTML reports and run scripts that produce output files, but it does not clearly warn that local files will be created as a side effect. This can surprise users, leak sensitive strategy data into the workspace, or overwrite artifacts in shared environments.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

This JSON file uses Chinese-only field names and explanatory text throughout, such as metrics labels and parenthetical notes. Under the policy rule for natural-language violations, forcing a specific language without user opt-in can be a locale/language policy issue.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

This manifest-style JSON uses only Chinese field names and explanatory text, such as the summary keys and detailed narrative, with no indication that the skill is region-specific or that users can opt into this locale. Under the policy criteria, forcing a specific language without user choice can be a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

This JSON mapping consistently hard-codes field translations in Chinese across the dataset schema, which constitutes a locale-specific natural-language constraint. There is no indication in this file that users can opt into another language or that the Chinese-only output is region-specific and documented.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The script defaults to reading a hard-coded file from a specific local user/project tool-results path when no CLI argument is provided. In an agent skill context, this creates unintended access to local artifacts outside the declared input boundary and can expose prior backtest outputs or unrelated project data if the path exists on the host.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

This file declares lang="zh-CN", and the visible report content is entirely in Chinese, which imposes a specific language/locale on users. The file does not indicate that the locale is optional, user-selected, or required for a region-specific compliance reason.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.