Back to skill

Security audit

ROIC 核心穿透分析工具

Security checks for vulnerabilities and agentic risk

Overview

This skill mostly implements ROIC analysis, but its package also contains unrelated QQ bot setup instructions and mutable bot dependencies that do not match the stated finance purpose.

Review carefully before installing. Do not follow the bundled QQ bot README or install the listed bot dependencies for ROIC analysis. If you use the skill, run it only for explicit ROIC tasks, expect external financial-data and annual-report fetching, and treat generated reports as drafts that need manual verification.

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

Warning
Location
roic_calc.py:506
Finding

Unsanitized stock codes can escape intended output directories

Content
View full analysis

Vulnerability Details

File Location: roic_calc.py:506-513; roic_fetch.py:590-622
Vulnerability Type: Path traversal through user-controlled output filenames
Risk Level: Medium

Vulnerable Code

roic_calc.py:506-513:

python
company = ts_code.split(".")[0]
filename = f"{company}_ROIC穿透分析_{results[0]['year']}-{results[-1]['year']}.md"
workspace = os.environ.get('OPENCLAW_WORKSPACE', os.path.expanduser('~/.openclaw/workspace'))
output_dir = os.path.join(workspace, 'output', 'roic')
os.makedirs(output_dir, exist_ok=True)
filepath = os.path.join(output_dir, filename)

with open(filepath, "w", encoding="utf-8") as f:
    f.write(report)

roic_fetch.py:590-622:

python
DATA_DIR = 'c:/Users/Corey/WorkBuddy/Claw/data/sec_filings'

def main():
    if len(sys.argv) < 3:
        print("用法: python roic_fetch.py <股票代码> <年份范围>")
        print("  A股: python roic_fetch.py 600426.SH 2021-2024")
        print("  美股: python roic_fetch.py AAPL 2021-2024")
        print("  港股: python roic_fetch.py 09988.HK 2021-2024")
        sys.exit(1)
    
    code = sys.argv[1]
    years_spec = " ".join(sys.argv[2:])
    years = parse_years(years_spec)
    
    market = detect_market(code)
    print(f'[ROIC] {code} → 市场: {market}, 年份: {years[0]}-{years[-1]}')
    
    # 确保数据目录存在
    os.makedirs(DATA_DIR, exist_ok=True)

    # ...

    output_file = os.path.join(DATA_DIR, f'{code}_{years[0]}-{years[-1]}_raw.json')
    with open(output_file, 'w', encoding='utf-8') as f:
        clean_results = []
        for r in results:
            clean = {k: v for k, v in r.items() if not k.startswith('raw_')}
            clean_results.append(clean)
        json.dump(clean_results, f, indent=2, ensure_ascii=False, default=str)

Technical Analysis

Both scripts derive output filenames directly from command-line stock codes without rejecting path separators, absol ...[truncated 2167 chars]

Remediation
View remediation

Remediation Suggestions

  1. Validate stock codes using strict, market-specific allowlists before making requests or constructing paths. For example:
    • A-share: ^[0-9]{6}\.(SH|SZ)$
    • Hong Kong: ^[0-9]{4,5}\.HK$
    • US: ^[A-Z][A-Z0-9.-]{0,9}$, followed by separate filename normalization.
  2. Reject identifiers containing /, \, .., drive prefixes, null bytes, or other filesystem metacharacters.
  3. Convert the identifier to a dedicated safe filename component rather than using the original input.
  4. Resolve and verify the destination before writing:
    python
    base = os.path.realpath(output_dir)
    target = os.path.realpath(os.path.join(base, safe_filename))
    if os.path.commonpath([base, target]) != base:
        raise ValueError("Output path escapes the designated directory")
    
  5. Use a configurable workspace directory instead of the developer-specific hardcoded path in roic_fetch.py.
  6. Open new output files with exclusive creation mode where overwriting is not required.
  7. Add tests covering absolute paths, parent traversal, Windows drive paths, mixed separators, and malformed market identifiers.

T08 · Insecure Dependencies

Warning
Location
requirements.txt:1
Finding

Unrelated and loosely constrained dependency installation expands the supply-chain attack surface

Content
View full analysis

Vulnerability Details

File Location: requirements.txt:1-4; installation command at README.md:14-16
Vulnerability Type: Unnecessary, broadly versioned third-party dependencies
Risk Level: Medium

Vulnerable Code

README.md:14-16:

bash
pip install -r requirements.txt

requirements.txt:1-4:

text
nonebot2[all]>=2.3.0
nonebot-adapter-onebot>=2.4.0
nonebot-plugin-apscheduler>=0.3.0
aiohttp>=3.9.0

The README also instructs users to download and execute NapCat from an external release page and log into a QQ account, although the audited Skill declares ROIC analysis as its functionality.

Technical Analysis

The bundled README describes a QQ bot rather than the ROIC analysis Skill. Its setup procedure installs a broad bot framework and associated plugins that are not imported or required by roic_calc.py or roic_fetch.py.

Each dependency uses only a lower-bound version constraint. Consequently, a future installation can resolve to package versions and transitive dependencies that did not exist when the Skill was reviewed. Python package installation may execute build backends or package installation logic with the privileges of the installing user.

No specific dependency was proven malicious during this static audit. The confirmed issue is the unnecessary and mutable dependency surface created by misleading project instructions.

SKILL_FULL.md additionally recommends the unpinned command pip install pypdf pdfplumber, which has the same reproducibility concern, although those libraries are relevant to optional PDF processing.

Attack Path

  1. A user follows the repository's bundled quick-start instructions, believing they are required for the ROIC Skill.
  2. The user executes pip install -r requirements.txt.
  3. The package resolver selects current versions satisfying the open-ended >= constraints, along with a potentially large transitive depend ...[truncated 976 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove or replace the unrelated QQ bot README and dependency list.
  2. Document that the core ROIC scripts use Python standard-library modules and do not require the listed bot packages.
  3. If dependencies are genuinely needed, separate optional features into dedicated requirement groups.
  4. Pin dependencies and transitive dependencies to reviewed versions using a lock file.
  5. Require package hashes, for example through pip install --require-hashes.
  6. Review package provenance, maintainers, release history, and artifacts before updating the lock file.
  7. Install optional parsing packages in an isolated virtual environment with minimal privileges.
  8. Pin and hash the pypdf and pdfplumber packages mentioned in SKILL_FULL.md.
  9. Avoid instructing users to download and execute unrelated account-handling software as part of this Skill's setup.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
Findings (25)

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The README content is fundamentally inconsistent with the declared skill purpose: instead of ROIC/financial analysis, it instructs users how to deploy a QQ bot with external connectivity and account login. This is dangerous because it can mislead reviewers and users into installing and operating unrelated bot infrastructure that handles real accounts and message interfaces, expanding the attack surface far beyond the stated financial-analysis function.

Content

No source excerpt is available for this finding.

Lp1

High
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The script reads an environment variable to determine where files are written, but that environment capability is not reflected in the declared permissions. In an agent/skill setting, undeclared capabilities are dangerous because they bypass operator expectations and can be abused for unintended data access patterns or writes outside the intended sandbox if the runtime trusts the manifest.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The README tells users to log in with a QQ account and enable WebSocket/HTTP bot interfaces, but provides no warning about account compromise, message exposure, local service hardening, or misuse of connected bot capabilities. In the context of a mislabeled skill, these instructions are more dangerous because users expecting a finance assistant may unknowingly deploy network-accessible messaging automation tied to a personal account.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The trigger description is overly broad and includes common finance terms such as ROIC, capital efficiency, NOPAT, and invested capital calculation. This can cause the skill to auto-activate in routine financial discussions where the user did not intend to invoke it, increasing the chance of unintended tool use and data-fetching behavior.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill auto-activates on very common finance terms such as ROIC, NOPAT, capital efficiency, and related analysis phrases, which makes invocation likely in many ordinary finance conversations. Because the skill has powerful tools enabled (Read, Write, Edit, WebFetch, Bash), broad triggering increases the chance that risky external fetches or local script execution occur without clear user intent or narrow scoping.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% 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 · SKILL_FULL.md (reported line 392)May include surrounding context.

md
- 搜索关键词定位附注页码:`其他非流动资产`、`其他流动资产`、`长期股权投资`、`商誉`、`无形资产`

**第二优先:东方财富年报 HTML 版**
- URL 模式:`https://data.eastmoney.com/notices/detail/{股票代码}/AN{公告日期}{序号}.html`
- 东方财富会将年报转成 HTML 格式发布,**可以直接 web_fetch 解析**
- 搜索方式:`web_search "site:data.eastmoney.com {公司名} {年份} 年度报告"` 找到具体 URL

External Transmission

Medium
Category
Data Exfiltration
Confidence
88% confidence
Finding

This section instructs the agent to download PDFs from third-party sites, install Python packages via pip, parse documents locally, and use broad web search as fallback. In a skill with Bash, WebFetch, Read, Write, and Edit permissions, that materially expands the attack surface: untrusted remote content may be fetched and processed, and dependency installation introduces supply-chain risk and opportunities for unintended code execution paths.

Content

Scanner excerpt · SKILL_FULL.md (reported line 462)May include surrounding context.

md
- **权益法投资收益必须从脚注找**:不能从投资收益合计中全取,要找"其中:权益法核算的长期股权投资收益"明细行
- **应收款项融资是类金融资产**:银行承兑汇票、应收账款保理等,实质上是应收账款的金融化变现,必须从分母中剔除(API 字段:`receiv_financing`)
- **⚠️复核不要乱搜**:不要漫无目的地 web_search + web_fetch 抓第三方网站(雪球/搜狐/百度文库等),效率极低且数据质量差。正确做法:①下载完整版年报PDF用 pdfplumber 提取附注;②再去东方财富 HTML 年报(`data.eastmoney.com`)抓附注表格;③以上都不行才搜第三方
- **东方财富 HTML 年报是可靠的在线附注来源**:URL 格式 `https://data.eastmoney.com/notices/detail/{代码}/AN{日期}{序号}.html`,用 `web_search "site:data.eastmoney.com {公司} 年度报告"` 定位
- **年报 PDF 可直接下载解析**:用 `pypdf` + `pdfplumber`(pip install)提取附注表格和文字;巨潮PDF链接可能是摘要版(5页),完整版需从雪球/东方财富获取;雪球PDF URL格式:`https://stockmc.xueqiu.com/{YYYYMM}/{代码}_{YYYYMMDD}_CQ65.pdf`
- **⚠️API字段名必须用小写!**:finance-data API 的字段名必须全部小写(如 `oth_eq_invest`),大写会匹配到错误的字段。旧版脚本用的 `oth_eqt_tools`(API字段不存在,返回0)和 `oth_fncble_assets`(API字段不存在,静默忽略)是严重的字段名bug
- **其他权益工具投资的正确API字段**:`oth_eq_invest`(不是 `oth_eqt_tools`)— 美的有0.36亿、海螺有14.16亿

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The skill is configured to auto-activate on a broad set of finance-related phrases without clear boundaries or exclusions, which can cause the agent to invoke this skill in contexts the user did not intend. Because the skill has access to Read, Write, Edit, WebFetch, and Bash, over-broad triggering increases the chance of unnecessary tool use, unintended file modifications, or network activity during ordinary financial discussion.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
83% confidence
Finding

The file presents the skill entirely in Chinese and describes automatic use for Chinese financial-analysis terms, without indicating that users may choose another language or that the locale restriction is intentional and justified. Under the stated policy, forcing a specific language without opt-in can be a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code file contains natural-language instructions, status messages, and generated report content entirely in Chinese, including the module docstring and runtime output. Under the policy, forcing a specific language without user opt-in is a locale/language policy violation unless the constraint is explicitly documented and justified as region-specific.

Content

No source excerpt is available for this finding.

Tainted flow: 'filepath' from os.environ.get (line 510, 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 · roic_calc.py (reported line 512)May include surrounding context.

python
os.makedirs(output_dir, exist_ok=True)
    filepath = os.path.join(output_dir, filename)

    with open(filepath, "w", encoding="utf-8") as f:
        f.write(report)

    print(f"\n[DONE] 报告已保存: {filepath}")

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

This code file contains natural-language strings in the module docstring and CLI help output that are exclusively Chinese. Under the policy, forcing a specific language without opt-in is a natural-language policy violation unless the locale restriction is clearly justified, which is not indicated here.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The SEC/港股/美股 path is not calculation-grade despite the skill claiming precise ROIC support. It relies on ticker-to-CIK shortcuts, filing-year guessing, HTML document heuristics, regex extraction from stripped text, and default values for missing fields, which can silently produce materially incorrect financial inputs and mislead downstream investment analysis.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
99% confidence
Finding

The comment states the parser uses iXBRL data attributes for precision, but the code immediately strips HTML tags and performs free-text regex matching. This mismatch is dangerous because users and downstream components may trust the extraction as structured and reliable when it is actually brittle and prone to wrong-number capture from narrative text or multi-period tables.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The code comment says A-share values are converted from 万元 to 元, but no multiplication is performed, so values may be off by orders of magnitude. In a finance skill, this can directly corrupt ROIC numerator/denominator calculations and lead to severely wrong outputs while appearing internally consistent.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
77% confidence
Finding

Natural-language content in the skill documentation appears to force a specific language for all users. There is no indication that Chinese is optional, selectable, or required for a justified region-specific purpose.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The markdown instructs the agent to automatically fetch external data from a finance-data API but does not disclose network access to the user or require confirmation. This is risky because it can transmit user-selected tickers, timing, or analysis context externally without informed consent, and it may surprise users who expect an offline calculation based only on provided documents.

Content

No source excerpt is available for this finding.

Unverifiable Dependency: nonebot2 has 2 known advisory(ies) (CVE-2024-21624 (NoneBot Potential Information Leak in User-Constructed Message Templates); CVE-2024-21624 (nonebot2 is a cross-platform Python asynchronous chatbot framework written in Py)), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
86% confidence
Finding

The manifest includes nonebot2 without an exact version pin, and known advisories exist for some releases of that package. Because the installed version cannot be verified from this file alone, there is a credible risk that vulnerable versions could be pulled during installation.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
94% confidence
Finding

The dependency is specified with only a minimum version bound, which allows future installs to resolve to different releases over time. This weakens build reproducibility and can unintentionally pull in vulnerable or breaking versions through the software supply chain.

Content

Scanner excerpt · requirements.txt (reported line 2)May include surrounding context.

text
nonebot2[all]>=2.3.0
nonebot-adapter-onebot>=2.4.0
nonebot-plugin-apscheduler>=0.3.0
aiohttp>=3.9.0

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
94% confidence
Finding

Using an unpinned version for this package means installations are not deterministic and may later resolve to a compromised or vulnerable release. While not an immediately exploitable code flaw by itself, it increases supply-chain risk and makes incident response and auditing harder.

Content

Scanner excerpt · requirements.txt (reported line 3)May include surrounding context.

text
nonebot2[all]>=2.3.0
nonebot-adapter-onebot>=2.4.0
nonebot-plugin-apscheduler>=0.3.0
aiohttp>=3.9.0

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
97% confidence
Finding

The aiohttp dependency is not pinned, so deployments may install different versions depending on time and resolver state. Given aiohttp's history of security advisories, this creates avoidable uncertainty about whether affected versions are being installed.

Content

Scanner excerpt · requirements.txt (reported line 4)May include surrounding context.

text
nonebot2[all]>=2.3.0
nonebot-adapter-onebot>=2.4.0
nonebot-plugin-apscheduler>=0.3.0
aiohttp>=3.9.0

Unverifiable Dependency: aiohttp has 16 known advisory(ies) (CVE-2024-52303 (aiohttp has a memory leak when middleware is enabled when requesting a resource ); CVE-2026-54279 (aiohttp: Host-Only Cookies Become Domain Cookies After CookieJar Persistence); CVE-2026-34514 (AIOHTTP has CRLF injection through multipart part content type header constructi) +13 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
95% confidence
Finding

aiohttp has multiple known security advisories, and the unpinned requirement prevents verification that a safe release will be installed. In a network-facing assistant or bot environment, pulling an affected aiohttp version could expose the service to request-handling, cookie, header, or resource-exhaustion issues depending on the resolved release.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
85% confidence
Finding

The manifest emphasizes ROIC calculation and analysis for listed companies, but does not mention creating and persisting output files. The code generates a report and saves it under a workspace directory, which goes beyond pure calculation/analysis behavior as described.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Low
Category
Not specified by scanner
Confidence
79% confidence
Finding

The skill's purpose is financial ROIC analysis, but the implementation accesses the process environment via OPENCLAW_WORKSPACE to choose where to write output. Environment inspection is not an obvious requirement of ROIC computation itself and is not declared in the manifest description.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

Defaulting SEC-extracted data currency to CNY for U.S./Hong Kong filings without detection can contaminate all downstream comparisons and ratio interpretation. In a multi-market ROIC tool advertised as precise, silent currency mislabeling creates a meaningful integrity risk because users may compare or aggregate figures across issuers under a false assumption of normalization.

Content

No source excerpt is available for this finding.