Back to skill

Security audit

彩票预测 V2.15

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly behaves like an offline lottery predictor, but the package also includes unrelated ClawHub publishing automation and weak database input handling that deserve review before installation.

Install only if you specifically want a Chinese-language, local SQLite-based lottery analysis tool, and treat its predictions as entertainment rather than financial advice. Do not run auto_publish.sh or provide ClawHub tokens unless you intentionally want to publish this package from your account. Use a dedicated lottery database path, not a sensitive SQLite database, until the --lottery input is allowlisted and the extra publishing files are removed from the installable package.

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/v2.15_prediction.py:55
Finding

SQL Injection Through an Unvalidated SQLite Table Identifier

Content
View full analysis

Vulnerability Details

File Location: scripts/v2.15_prediction.py, lines 55-73 and 287-296
Vulnerability Type: SQL injection through an unvalidated identifier
Risk Level: Medium

Vulnerable Code

python
def get_history_data(conn: sqlite3.Connection, lottery_type: str = "ssq", limit: int = None) -> List[Dict]:
    """获取历史数据"""
    conn.row_factory = sqlite3.Row
    cursor = conn.cursor()
    
    query = f"SELECT * FROM {lottery_type} ORDER BY issue DESC"
    if limit:
        query += f" LIMIT {limit}"
    
    cursor.execute(query)
    rows = cursor.fetchall()
    
    return [dict(row) for row in rows]

def get_latest_issue(conn: sqlite3.Connection, lottery_type: str = "ssq") -> str:
    """获取最新已开奖期号"""
    cursor = conn.cursor()
    cursor.execute(f"SELECT issue FROM {lottery_type} ORDER BY issue DESC LIMIT 1")
    row = cursor.fetchone()
    return row[0] if row else None

The affected value originates from an unrestricted command-line argument:

python
parser.add_argument("--lottery", type=str, default="ssq", help="彩种(ssq/dlt)")

It is passed directly to the vulnerable functions:

python
latest_issue = get_latest_issue(conn, args.lottery)
history = get_history_data(conn, args.lottery, limit=3430)

Technical Analysis

The --lottery argument is controlled by the caller and is interpolated directly into two SQL statements as a table identifier. No allowlist or identifier validation is applied.

SQLite parameter placeholders cannot be used for table identifiers. Consequently, dynamic identifiers must be selected from a fixed mapping or strictly validated before query construction. The current implementation permits a caller to introduce SQL syntax such as a subquery, compound query, comment marker, or computationally expensive expression.

Python's sqlite3.Cursor.execute() generally prevents execution of multiple statements in one call, w ...[truncated 2155 chars]

Remediation
View remediation

Remediation Suggestions

  1. Restrict the command-line argument to supported values:

    python
    parser.add_argument(
        "--lottery",
        choices=("ssq", "dlt"),
        default="ssq",
        help="Lottery type"
    )
    
  2. Map logical values to fixed identifiers at the database boundary:

    python
    LOTTERY_TABLES = {
        "ssq": "ssq",
        "dlt": "dlt",
    }
    
    def resolve_lottery_table(lottery_type: str) -> str:
        try:
            return LOTTERY_TABLES[lottery_type]
        except KeyError:
            raise ValueError("Unsupported lottery type")
    
  3. Use only the resolved table name when constructing SQL:

    python
    table = resolve_lottery_table(lottery_type)
    query = f'SELECT * FROM "{table}" ORDER BY issue DESC LIMIT ?'
    cursor.execute(query, (limit,))
    
  4. Validate the value again inside every database-facing function rather than relying only on command-line parsing. This protects future non-CLI callers.

  5. Avoid returning raw database exception text to untrusted callers. Return a stable error code and record detailed diagnostics only in a protected local log.

  6. Add negative tests using unexpected identifiers, SQL comment markers, subqueries, and compound-query syntax. Verify that all such input is rejected before reaching SQLite.

T09 · Insecure Skill Coding Practices

Note
Location
auto_publish.sh:15
Finding

Predictable Shared Temporary Files in the Publishing Script

Content
View full analysis

Vulnerability Details

File Location: auto_publish.sh, lines 15-23
Vulnerability Type: Insecure temporary-file handling and local race condition
Risk Level: Low

Vulnerable Code

bash
clawhub publish "$SKILL_PATH" \
  --slug lottery-predictor-v2-15 \
  --name "彩票预测 V2.15" \
  --version 2.15.0 \
  --changelog "初始发布:基于 V2.15 数学模型的彩票预测技能" \
  2>&1 | tee /tmp/publish_attempt_$ATTEMPT.log

# 检查是否成功
if grep -q "Published" /tmp/publish_attempt_$ATTEMPT.log; then
  echo "✅ 发布成功!"
  echo "✅ 发布成功!" >> /Users/lic/.openclaw/workspace/skills/lottery-predictor-v2.15/PUBLISH_RESULT.md
  exit 0

Technical Analysis

The script writes ClawHub command output to predictable filenames such as /tmp/publish_attempt_1.log. The shared /tmp directory is commonly writable by every local user.

The script does not:

  • Create a private temporary directory.
  • Use mktemp for unpredictable filenames.
  • Verify that the destination is a regular file owned by the invoking user.
  • Set a restrictive umask.
  • Atomically associate the generated log with the subsequent success check.

A local attacker may pre-create a matching path as a symbolic link or manipulate the file between the tee operation and the grep check. Whether symbolic-link following succeeds can depend on operating-system hardening, mount options, and file ownership; therefore, the issue is environment-dependent but remains unsafe portable shell behavior.

The success condition is also based only on the presence of the text Published, rather than the actual exit status of clawhub publish. Because the command is piped into tee, the script does not preserve and verify the publisher's status.

Attack Path

  1. A local attacker predicts that the maintainer will run auto_publish.sh.
  2. The attacker creates or races a path such as /tmp/publish_attempt_1.log.
  3. The path is configured as a symbolic link to anothe ...[truncated 1182 chars]
Remediation
View remediation

Remediation Suggestions

  1. Create a private, unpredictable temporary directory and enforce restrictive permissions:

    bash
    #!/usr/bin/env bash
    set -o errexit
    set -o nounset
    set -o pipefail
    umask 077
    
    LOG_DIR="$(mktemp -d "${TMPDIR:-/tmp}/lottery-publish.XXXXXX")"
    trap 'rm -rf -- "$LOG_DIR"' EXIT
    
  2. Store each attempt log inside that directory:

    bash
    LOG_FILE="$LOG_DIR/publish_attempt_${ATTEMPT}.log"
    
  3. Preserve and validate the publisher's exit status instead of relying exclusively on output text:

    bash
    set +e
    clawhub publish "$SKILL_PATH" \
      --slug lottery-predictor-v2-15 \
      --name "彩票预测 V2.15" \
      --version 2.15.0 \
      --changelog "Initial release" \
      2>&1 | tee "$LOG_FILE"
    publish_status="${PIPESTATUS[0]}"
    set -e
    
    if [[ "$publish_status" -eq 0 ]]; then
        echo "Publication succeeded"
        exit 0
    fi
    
  4. If output validation is still required, combine it with a successful exit status rather than treating a text match as authoritative.

  5. Never run this script as root. Publication requires only the maintainer account's ClawHub credentials and project-file access.

  6. Avoid logging tokens, authorization headers, or other credentials if future versions of the CLI print diagnostic authentication information.

Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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 (22)

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The declared description presents a mathematical lottery prediction tool, but the provided code does not implement any prediction logic, statistical algorithms, or recommendation generation. Instead, it is an operational deployment script whose primary purpose is to publish the skill to ClawHub, record results, and retry on failure. This is a materially different purpose and includes undeclared capabilities such as automated publishing and file writes. Therefore, the description does not accurately represent the supplied code chunk.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

声明强调的是“预测工具”,核心能力应是基于若干数学模型计算并输出推荐号码。但代码仅实现了一个 verify.py 验证脚本:接收预测号码和实际开奖号码,计算命中情况、命中率展示以及中奖等级。这属于开奖后的结果核验,而不是号码预测。代码中没有均值回归、正态分布、大数定律、卡方检验等算法实现,也没有任何生成推荐号码的逻辑。因此代码实际行为与声明用途存在明显且实质性的偏差。

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This markdown file contains user-facing operational instructions exclusively in Chinese, including the title, steps, labels, and support guidance. Under the language/locale policy rule, forcing a single language without user opt-in or a documented region-specific justification is a natural-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

SQP-3 applies to all file types and covers natural-language policy violations such as forcing a specific language without user opt-in. This publishing guide presents all operational instructions only in Chinese, and the file does not indicate that the skill or audience is explicitly Chinese-language or region-specific.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The manifest description and the entire user-facing documentation are presented only in Chinese, with no indication that other languages are supported or that language selection is optional. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is clearly documented and justified.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This report promotes and validates a lottery-number prediction skill without any warning that the output may influence users' financial decisions or encourage gambling-like behavior. Because the document repeatedly states the skill is ready for release, highlights monetization, and presents successful prediction workflows, it can materially increase user trust in a financially consequential and inherently unreliable activity.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This shell script contains natural-language comments and status output entirely in Chinese, including its title and success/failure messages. Under the policy, forcing a specific language without user opt-in or a documented locale-specific reason is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The script performs automated skill publication and persistent logging, which is outside the declared purpose of a lottery prediction tool. This creates an unexpected capability boundary violation: anyone invoking or packaging the skill may trigger repository/platform side effects unrelated to prediction, increasing the risk of unauthorized publication or supply-chain misuse.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The presence of a clawhub publish operation gives the skill an unrelated deployment capability that could publish artifacts to an external platform. In the context of an end-user lottery tool, this is dangerous because it expands the attack surface to account, registry, or marketplace actions that a user would not reasonably expect.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The documentation describes a Markov model where the next state depends on the current state and mentions odd/even and size transitions. The actual code does not model transition probabilities or state sequences at all; it merely checks whether a number appeared in the latest draw and assigns a fixed score, which contradicts the stated algorithm.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The inline documentation claims time-series analysis of temporal trends, annual patterns, and periodic behavior. The implementation does not compute trends, seasonality, or time-dependent structure; it simply assigns scores from a 10-draw recency count, which is a much narrower heuristic than documented.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The documentation says this component uses a Poisson distribution to model event counts and support consecutive-number or same-tail probabilities. The code does not calculate any Poisson probability mass, rate parameter, or count-process model; it only computes an empirical adjacency co-occurrence ratio, which contradicts the documented intent.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The manifest description says the skill is a 双色球 prediction tool based on seven mathematical models and provides red TOP10 and blue TOP4 recommendations. In code, the seven-model ensemble is applied only to red balls, while blue balls are scored solely by occurrence frequency, which does not match the described V2.15 algorithmic basis for the overall predictor.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This Python file contains natural-language documentation and CLI help text in Chinese, but it does not provide any user opt-in, alternate language, or explanation that the skill is intended only for a Chinese-speaking audience. That can violate language/locale policy when a skill implicitly forces one language for all users.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The argparse description and help strings are all written in Chinese, which makes the CLI effectively single-language without user choice. Under the policy, language restrictions should either be optional for users or explicitly justified as locale-specific.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

The entire status document is written in Chinese and does not indicate that other languages or locales are supported. Under the stated policy, forcing a specific language without user opt-in can be a natural-language policy violation unless the locale restriction is explicitly documented and justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

This markdown file contains user-facing operational guidance only in Chinese, including headings, instructions, and support information. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is explicitly documented and justified, which is not present here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

This markdown file contains user-facing title and release information entirely in Chinese, including the skill name and pricing details. Because the file does not indicate that the skill is region-specific or provide any user language choice, it may violate the language/locale policy requiring opt-in or documented justification for a forced locale.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

This markdown file is entirely written in Chinese and the only invocation example uses a Chinese natural-language prompt ("帮我预测双色球 2026035 期"). There is no indication that users may interact in other languages or that the Chinese-only behavior is an intentional, documented locale restriction, which can violate language/locale policy requirements.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
78% confidence
Finding

SQP-3 applies to all file types and covers natural-language locale policy issues. The entire report is written in Chinese with no indication that language selection is optional or that the skill is intentionally limited to a Chinese-speaking or region-specific audience.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
81% confidence
Finding

The package description and author fields are presented only in Chinese, which can constitute a language/locale policy issue if the skill is expected to support a broader audience and does not offer any language choice or opt-in. There is no indication in this manifest that the locale is intentionally restricted or that users can select an alternative language.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
88% confidence
Finding

This code file includes user-facing documentation and CLI help context in a single enforced language/locale, which can violate language-choice policy when no alternative or opt-in is provided. The issue is reinforced by additional Chinese user-facing messages later in the script, indicating the skill assumes one language by default rather than offering a choice.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.