Back to skill

Security audit

my_stock_report_skill

Security checks for vulnerabilities and agentic risk

Overview

This stock-report skill has a coherent purpose, but it runs local analysis commands and automatically archives full report contents to a fixed DingTalk workspace, so users should review it before installing.

Install only if you intend reports to be uploaded to the specified DingTalk workspace and stored in the linked document/table systems. Before use, confirm the DingTalk destination, restrict ticker/analyst/language inputs to known-safe values, and prefer a local-only or confirmation-gated variant if reports may contain sensitive research or proprietary notes.

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

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:17
Finding

Potential Shell Command Injection Through Unvalidated Analysis Parameters

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 17–19
Vulnerability Type: Shell command injection
Risk Level: High

Complete Code Snippet:

markdown
### 1. 构建分析命令
根据用户指令构建命令,固定使用 `run_cli.py`:
- **基础模式**:`./venv/bin/python3 run_cli.py -t {标的编码} -a {analysts} -l {language} -n`
- **示例**:如果用户要求“启动报告引擎分析 AAPL,只要基本面”,则执行 `./venv/bin/python3 run_cli.py -t AAPL -a fundamental -l Chinese -n`;若未明确指定分析师组合,则默认传入 `-a social,news,market,fundamental`。

Technical Analysis

The Skill instructs the agent to interpolate user-derived ticker, analyst, and language values directly into a textual command. It does not require allowlist validation, safe quoting, metacharacter rejection, or execution through a structured argument vector.

If an implementation follows this instruction by passing the assembled string to a shell, shell operators within any substituted value may be interpreted as command syntax rather than data. The flaw is conditional on shell-based execution; direct process invocation with separately supplied arguments would substantially reduce this risk.

Attack Path

  1. An attacker invokes the Skill using an explicitly recognized trigger phrase.
  2. The attacker supplies a ticker, language, or analyst value containing shell metacharacters and an additional command.
  3. The agent substitutes that value into the documented command template.
  4. The generated command is executed through a shell without validation or safe argument separation.
  5. The shell interprets the injected operators and executes the attacker-supplied command with the privileges of the agent process.

Impact Assessment

Successful exploitation could provide arbitrary command execution under the account running the Skill. The attacker could read or modify files accessible to that account, access locally available application credentials or tokens, tamper with generated reports, or use the process's permitted network acce ...[truncated 192 chars]

Remediation
View remediation

Remediation Suggestions

  • Validate ticker symbols with a restrictive allowlist appropriate to supported markets, such as ^[A-Z][A-Z0-9.-]{0,9}$, after normalizing case.
  • Restrict the analyst parameter to an explicit set such as social, news, market, and fundamental; parse combinations as individual values and reject unknown entries.
  • Restrict the language parameter to explicitly supported language names or codes.
  • Invoke Python through a process API using a structured argument array, for example:
    python
    subprocess.run(
        [
            "./venv/bin/python3",
            "run_cli.py",
            "-t", ticker,
            "-a", ",".join(analysts),
            "-l", language,
            "-n",
        ],
        check=True,
        shell=False,
    )
    
  • Never concatenate user-controlled values into a command passed to sh, bash, shell=True, os.system, or an equivalent shell interpreter.
  • Reject control characters and shell metacharacters as defense in depth, log validation failures, and add tests covering separators, substitutions, redirections, quoting, and newline injection.
  • Run the analysis process with least privilege and limit its filesystem, credential, and network access to reduce impact if validation is bypassed.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (3)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill explicitly instructs the agent to upload locally generated report contents, conclusions, and structured summaries to DingTalk documents and a management table, but it does not require explicit user consent or a user-facing disclosure that data will be transmitted to third-party services and archived. This creates a real data exfiltration and retention risk, especially because reports may contain proprietary analysis, sensitive prompts, or user-supplied investment research that the user may have expected to remain local.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
96% confidence
Finding

The skill contains an explicit external API call to DingTalk that overwrites document content with local files such as decision.txt and complete_report.md. In context, this is more dangerous because the skill mandates automatic transmission of full report artifacts and then further persists derived data into another management system, increasing both exposure surface and long-term retention without any visible security gating or minimization.

Content

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

md
- 使用上述父节点 nodeId,创建名为 `{标的}_最终结论_{YYYYMMDD_HHMMSS}` 的文档,并获取其在线 URL 及 docKey。
   - 使用上述父节点 nodeId,创建名为 `{标的}_完整报告_{YYYYMMDD_HHMMSS}` 的文档,并获取其在线 URL 及 docKey。
3. **写入正文内容**:
   - 使用 docKey,分别调用 `POST https://api.dingtalk.com/v1.0/doc/suites/documents/{docKey}/overwriteContent?operatorId={OPERATOR_ID}`。
   - 将 `decision.txt` 写入“最终结论”文档;将 `complete_report.md` 写入“完整报告”文档。

### 3. 多维表结构化录入,直接 使用`my_stock_report_mgnt_skill` 技能

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
89% confidence
Finding

The file specifies Chinese as the default output language for reports, and the workflow examples continue using Chinese unless the user explicitly overrides it. This imposes a language choice by default rather than offering neutral user selection or opt-in.

Content

No source excerpt is available for this finding.