Back to skill

Security audit

AkShare Analysis

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent Chinese stock-analysis tool, but its generated HTML reports can execute untrusted content and depend on unverified runtime code.

Review this skill before installing if you plan to generate and open HTML reports. Treat reports as active web pages, avoid rendering reports from untrusted ai_analysis.md or unexpected upstream data, and prefer a hardened version that escapes HTML, adds a CSP, pins dependencies, and bundles or integrity-checks browser scripts.

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/render_report.py:56
Finding

Stored HTML and JavaScript Injection in Generated Reports

Content
View full analysis
{p}" for p in hs.get("points", [])) or "
  • Data unavailable
  • " ``` At lines 141-143, content read from `ai_analysis.md` is inserted without HTML escaping: ```python cards.append(f"""
    {title}
    {body_text}
    """) ``` At lines 159-161, analyst forecast fields are inserted into table cells without escaping: ```python rows = "\n".join( f"{f.get('broker','')}{f.get('rating','')}" f"{f.get('target_price','N/A')}{f.get('date','')}" for f in forecasts ) ``` At lines 172-173 and 235-236, report metadata is embedded directly in the document title and body: ```python {d['ticker']} {d['name']} Analysis Report ``` ```python
    {d['ticker']} {d['name']}
    ``` ### Technical Analysis The renderer treats values from `data.json`, AKShare responses, and `ai_analysis.md` as trusted HTML. These values are interpolated into HTML elements without context-sensitive output encoding. The limited Markdown processing at lines 138-139 only strips Markdown links and bold syntax. It does not remove HTML elements, event-handler attributes, scriptable URLs, or other executable markup. Consequently, a value such as the following would be preserved in the generated document: ```html ``` When the generated `index.html ...[truncated 1921 chars]
    Remediation
    View remediation
    alert(1) ``` 7. Ensure JavaScript data is emitted through a safe JSON serializer and never by directly embedding arbitrary file contents into a script block. ]]>

    T08 · Insecure Dependencies

    Warning
    Location
    scripts/analyze.py:4
    Finding

    Unverified Runtime Dependencies and Remote Browser Script

    Content
    View full analysis
    =1.0.0", # "pandas>=2.0.0", # "mplfinance>=0.12.0", # ] ``` The news script similarly permits any later AKShare version: ```python # dependencies = [ # "akshare>=1.0.0", # ] ``` Generated reports load executable JavaScript from a third-party CDN without Subresource Integrity: ```html ``` ### Technical Analysis The `uv run` workflow can resolve dependency releases newer than those reviewed because the Python requirements use minimum-version constraints rather than exact audited versions. No lockfile or cryptographic hashes are present in the reviewed project. This means the code executed during future runs may differ from the dependency code available at audit time. A compromised package release, dependency account, package registry, or dependency-resolution process could introduce malicious Python code into the analysis process. The generated HTML also downloads and executes a charting library from `unpkg.com` whenever a report is opened with network access. Although the URL includes a package version, the document does not specify a Subresource Integrity hash. The browser therefore relies entirely on the CDN and transport path to provide the expected script. This external dependency also conflicts with the documented description of the report as self-contained. ### Attack Path #### Python Dependency Path 1. A dependency publisher account, package release, or registry delivery path is compromised. 2. A malicious release still satisfies a constraint such as `akshare>=1.0.0`. 3. A user runs on ...[truncated 1538 chars]
    Remediation
    View remediation
    ", # "pandas==", # ] ``` 2. Generate and commit a lockfile containing fully resolved transitive dependencies and cryptographic hashes. 3. Use a controlled package index or dependency mirror where feasible, and restrict unexpected alternate indexes to reduce dependency-confusion risk. 4. Remove `mplfinance` if it is not used. Reducing dependency count reduces the supply-chain attack surface. 5. Bundle the reviewed `lightweight-charts` asset locally so the report is genuinely self-contained. 6. If remote CDN loading is retained, specify a verified Subresource Integrity hash and an appropriate `crossorigin` attribute: ```html ``` 7. Add a restrictive Content Security Policy that limits script sources to explicitly approved origins or, preferably, to the bundled local asset. 8. Establish a dependency-update process that includes source review, vulnerability scanning, reproducible installation tests, and deliberate lockfile updates. ]]>
    Vulnerability Patterns
    • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
    • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
    • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
    • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
    • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
    Findings (7)

    Vague Triggers

    Medium
    Category
    Not specified by scanner
    Confidence
    93% confidence
    Finding

    The trigger description is broad enough to activate on generic investment or trading queries involving Chinese companies, even when the user may not have explicitly requested this specific skill. Over-broad routing can cause unintended tool invocation, increasing the chance of irrelevant financial analysis, reduced user control, and accidental disclosure or processing of sensitive portfolio-related context.

    Content

    No source excerpt is available for this finding.

    Natural-Language Policy Violations

    Medium
    Category
    Not specified by scanner
    Confidence
    84% confidence
    Finding

    The prescribed AI analysis template hardcodes Chinese-language section headers and structure without indicating that output language should follow the user's preference. This can override user language expectations and make the skill less transparent or less usable, especially in multilingual environments where consistent language handling is important.

    Content

    No source excerpt is available for this finding.

    Natural-Language Policy Violations

    Medium
    Category
    Not specified by scanner
    Confidence
    93% confidence
    Finding

    The formatted analysis output includes Chinese recommendation and horizon labels such as 买入, 持有, 卖出, and 短期/中期/长期, while the rest of the interface is in English. This imposes a specific locale in user-facing text 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
    91% confidence
    Finding

    This code emits multiple Chinese-language descriptions in docstrings and signal points such as "数据不足", "超卖", and other user-facing analysis text. The file does not provide any user opt-in, locale selection, or justification that the skill is intended only for Chinese-language users, which creates a language policy concern.

    Content

    No source excerpt is available for this finding.

    Natural-Language Policy Violations

    Medium
    Category
    Not specified by scanner
    Confidence
    93% confidence
    Finding

    This code sets the HTML language to zh and renders labels, headings, and notices in Chinese throughout the report. That is a natural-language locale constraint embedded in the skill without any user-selectable language option or documented justification in this file.

    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 chart and report data to /data/stock-reports, including generated analysis and market data, but the only disclosure is a status message after saving. There is no prior warning or confirmation in the CLI help, function docstrings, or user-facing messaging that enabling report generation will persist files on disk in that location.

    Content

    No source excerpt is available for this finding.

    Intent-Code Divergence

    Low
    Category
    Not specified by scanner
    Confidence
    82% confidence
    Finding

    The docstring says the function will 'Create report directory, generate charts, write data.json', which omits that it also emits a status message to stderr and performs directory creation as part of its side effects. This is a mild intent/documentation divergence rather than a dangerous contradiction, but it still misstates the function's observable behavior.

    Content

    No source excerpt is available for this finding.

    Static analysis

    No suspicious patterns detected.