Back to skill

Security audit

体彩兑奖

Security checks for vulnerabilities and agentic risk

Overview

This lottery checker is mostly purpose-aligned, but it disables certificate checks when fetching financially relevant lottery results, so users should review it before relying on it.

Install only if you are comfortable with a lottery-checking script that contacts the Sports Lottery API and currently bypasses TLS certificate verification. Treat its results as informational and verify any potential winnings through official channels; the TLS bypass should be fixed before relying on the output.

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
scripts/check_lottery.py:79
Finding

TLS Certificate and Hostname Verification Disabled

Content
View full analysis

Vulnerability Details

File Location: scripts/check_lottery.py, lines 79–82 and 103
Vulnerability Type: Improper TLS certificate validation
Risk Level: High

Vulnerable Code

python
import ssl
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE

# Build the query URL
params = {
    "gameNo": config["game_no"],
    "provinceId": "0",
    "isVerify": "1",
    "termLimits": "1"
}
query_string = "&".join([f"{k}={v}" for k, v in params.items()])
full_url = f"{config['url']}?{query_string}"

req = urllib.request.Request(
    full_url,
    headers={
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
        "Referer": "https://www.lottery.gov.cn/",
        "Accept": "application/json"
    }
)

with urllib.request.urlopen(req, timeout=15, context=ctx) as resp:
    data = json.loads(resp.read().decode())

Technical Analysis

The code creates a default TLS context but then explicitly disables its two essential server-authentication controls:

  • ctx.check_hostname = False prevents verification that the certificate belongs to webapi.sporttery.cn.
  • ctx.verify_mode = ssl.CERT_NONE accepts certificates that are untrusted, expired, self-signed, or issued for another host.

Although the API URL uses HTTPS, these settings remove server identity authentication. Encryption alone does not prevent an active network attacker from terminating the connection with an arbitrary certificate and returning forged JSON.

The response is parsed and trusted without an independent authenticity check. Its draw result, prize details, pool balance, and sales amount are subsequently used to calculate and display financially relevant lottery results.

Attack Path

  1. A user invokes the Skill to check one or more lottery tickets.
  2. The script connects to the configured lottery API over a network controlled or intercepted by an attacker, such as a compromised router, malicious Wi-Fi ...[truncated 1248 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove the custom settings that disable certificate and hostname verification.
  2. Use Python's default verified TLS behavior:
python
with urllib.request.urlopen(req, timeout=15) as resp:
    data = json.loads(resp.read().decode("utf-8"))

Alternatively, retain an explicit default context without weakening it:

python
import ssl

ctx = ssl.create_default_context()

with urllib.request.urlopen(req, timeout=15, context=ctx) as resp:
    data = json.loads(resp.read().decode("utf-8"))
  1. Do not use ssl.CERT_NONE or set check_hostname to False in production.
  2. If the runtime requires a private or unusual trust chain, install the appropriate CA certificate and load it through ssl.create_default_context(cafile=...) rather than bypassing validation.
  3. Validate the response schema and expected data types before using API fields. This does not replace TLS verification, but it limits malformed or unexpected data handling.
  4. Return a clear failure when certificate validation fails; never silently retry with an insecure SSL context.
  5. Add an automated test using an untrusted or hostname-mismatched certificate and verify that the request is rejected.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • 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)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

A description-behavior mismatch is dangerous because reviewers and users may authorize a narrowly scoped 大乐透 checker while the underlying implementation supports additional lottery types or broader logic not disclosed in SKILL.md. That hidden or undocumented functionality increases the attack surface and can mask unexpected processing, data handling, or external requests beyond the stated purpose.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The code explicitly disables TLS hostname checking and certificate verification before calling the remote lottery API. This allows a man-in-the-middle attacker to spoof the API endpoint, tamper with draw results or prize data, and feed false information to users while the script treats it as trusted official data.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill documentation indicates behavior that depends on external lottery data, but the skill declares no explicit tool scope or permissions for network access. Missing scope declarations weaken reviewability and allow a skill to use data-fetching capabilities without clear user or platform visibility into what external access is required.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The module description and all user-facing strings are in Chinese, and the script is fixed to a China-specific lottery workflow. There is no indication that users can opt into another language or that the locale restriction is explicitly documented as a deliberate regional limitation.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The manifest states the skill is for 中国福利彩票体育彩票大乐透批量查询, implying a narrowly scoped 大乐透 checker. However, the code defines API configuration and prize mappings for multiple unrelated lottery games, expanding behavior beyond the stated description.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
95% confidence
Finding

The manifest description and all user-facing instructions are entirely in Chinese, and the skill does not indicate any language preference, opt-in, or alternative locale support. Under the policy, forcing a specific language without user choice can be a natural-language policy violation unless the locale constraint is clearly documented and justified.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
94% confidence
Finding

The docstring and inline comment say the main entry point supports only 大乐透, while the same file includes parsing and winner-checking implementations for pl3, pl5, and 7xc. This creates an intent mismatch in the file's documentation because the documented scope contradicts the broader implemented capability.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.