Back to skill

Security audit

随机数生成服务

Security checks for vulnerabilities and agentic risk

Overview

This skill is a remote random-number service, but it stores an API key in plaintext and does not clearly warn that the service can see generated values that users may treat as secrets.

Install only if you trust XiaoBenYang with both your API key and every random value generated by the service. Do not use this skill to create passwords, API tokens, encryption keys, recovery codes, nonces, or other confidential security material unless the provider trust and retention model is acceptable. Treat the saved .env API key as a local plaintext secret that may need rotation if exposed.

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/config.py:45
Finding

API Key Persisted in an Unprotected Plaintext Environment File

Content
View full analysis
bool: """将API key保存到.env文件""" try: env_path = Path(".env") lines = [] if env_path.exists(): lines = env_path.read_text(encoding="utf-8").splitlines() found = False new_lines = [] for line in lines: if line.startswith("XBY_APIKEY="): new_lines.append(f"XBY_APIKEY={api_key}") found = True else: new_lines.append(line) if not found: new_lines.append(f"XBY_APIKEY={api_key}") env_path.write_text("\n".join(new_lines) + "\n", encoding="utf-8") os.environ["XBY_APIKEY"] = api_key return True except Exception as e: print(f"保存API key失败: {e}") return False ``` The Skill instructions explicitly direct the agent to collect and save the credential: ```markdown - First use: if `.env` does not contain `XBY_APIKEY`, the agent must ask the user for the API key. - After receiving the key, call `scripts.config.set_api_key(api_key)` to save it. ``` ### Technical Analysis The Skill solicits an API credential and persists it as plaintext in a `.env` file relative to the process's current working directory. The implementation uses `Path.write_text()` without explicitly creating the file with owner-only permissions such as mode `0600`. The relative path also means the credential may be written outside the intended project directory when the Skill is launched from another working directory. Before writing, the implementation does not verify that `.env` is a regular file owned by the expected user, nor does it reject symbolic links. It reads and rewrites the d ...[truncated 1854 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/call_api.py:49
Finding

Security-Sensitive Random Values Are Generated by and Disclosed to a Remote Service

Content
View full analysis
HttpResult: """调用小笨羊MCP工具""" url = f"{settings.base_url}/api" mcp_id = mcp_id or settings.mcp_id api_key = get_api_key() if not api_key: raise UpstreamError("API密钥未设置,请先调用 set_api_key()") headers = { "XBY-APIKEY": api_key, "func": tool_name, "mcpid": mcp_id, "Content-Type": "application/json", } # data = {k: str(v) if v is not None else "" for k, v in params.items()} t0 = time.time() try: resp = self._session.post( url=url, headers=headers, data=json.dumps(params), timeout=settings.timeout_seconds, ) ``` The wrappers send all random-generation operations to the remote API, including random bytes and strings: ```python def generate_random_bytes( length: Optional[int] = 32.0, encoding: Optional[str] = "hex" ) -> Dict[str, Any]: arguments = { "length": length, "encoding": encoding } return call_api("1777316659559427", "generate_random_bytes", arguments) ``` ```python def generate_random_string( length: Optional[int] = 16.0, charset: Optional[str] = "alphanumeric", count: Optional[int] = 1.0 ) -> Dict[str, Any]: arguments = { "length": length, "charset": charset, "count": count } return call_api("1777316659559427", "generate_random_string", arguments) ``` ### Technical Analysis Despite describing the outputs as cryptographically secure, the Skill does not generate them locally. Every random result is generated or supplied by `https://m ...[truncated 2354 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • 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
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (29)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The skill also instructs reading, persisting, and managing API credentials and service configuration despite claiming to be a simple random-generation service. This expands the attack surface to credential handling and local configuration storage without clearly disclosing those behaviors, making misuse or secret exposure more likely.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The skill also instructs reading, persisting, and managing API credentials and service configuration despite claiming to be a simple random-generation service. This expands the attack surface to credential handling and local configuration storage without clearly disclosing those behaviors, making misuse or secret exposure more likely.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file implements a generic upstream MCP/API invocation wrapper driven by caller-controlled mcp_id, tool_name, and params rather than enforcing a narrow random-number-generation operation. In a skill advertised as a cryptographically secure random number service, this capability expansion can let downstream users or agents invoke arbitrary remote tools through the configured backend, creating an unintended proxy/confused-deputy channel with the service's API key.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The file configures a remote 'gaokao' service with an API endpoint and credential handling, which directly conflicts with the declared purpose of a cryptographically secure random-number service. This kind of capability mismatch is dangerous because it can conceal undeclared network access and secret use behind an unrelated skill description, undermining user trust and making covert data routing or repurposing easier.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/config.py (reported line 13)May include surrounding context.

python
model_config = SettingsConfigDict(
        env_prefix="XBY_GAOKAO_",
        env_file=".env",
        env_file_encoding="utf-8",
        extra="ignore",
    )

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/config.py (reported line 32)May include surrounding context.

python
model_config = SettingsConfigDict(
        env_prefix="XBY_GAOKAO_",
        env_file=".env",
        env_file_encoding="utf-8",
        extra="ignore",
    )

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/config.py (reported line 31)May include surrounding context.

python
default_year: int = 2025

    def model_post_init(self, __context):
        # 强制从 .env 文件读取 XBY_APIKEY
        env_path = Path(".env")
        if env_path.exists():
            content = env_path.read_text(encoding="utf-8")

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/config.py (reported line 39)May include surrounding context.

python
default_year: int = 2025

    def model_post_init(self, __context):
        # 强制从 .env 文件读取 XBY_APIKEY
        env_path = Path(".env")
        if env_path.exists():
            content = env_path.read_text(encoding="utf-8")

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

Persisting an external API key to .env is unrelated to a random-number generator's stated function and introduces long-lived credential storage into a skill that should not need it. In misleading context, this expands the blast radius of compromise by leaving secrets on disk and enabling undeclared external-service access later.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
90% confidence
Finding

This function is explicitly designed to persist an API key into a plaintext .env file, creating durable local secret storage. In the context of a misdeclared random-number service, this is more dangerous because it introduces unnecessary credential collection and retention that could support undeclared external communications or expose secrets through filesystem access.

Content

Scanner excerpt · scripts/config.py (reported line 48)May include surrounding context.

python
def save_api_key_to_env(api_key: str) -> bool:
    """将API key保存到.env文件"""
    try:
        env_path = Path(".env")
        lines = []
        if env_path.exists():
            lines = env_path.read_text(encoding="utf-8").splitlines()

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill declares no explicit tool scope or permission boundaries even though its documented behavior includes environment access, file reads/writes, and network use. In an agent setting, missing scope constraints increases the chance of over-broad execution and makes it harder for users or platforms to enforce least privilege.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill explicitly instructs the agent to ask the user for an API key and save it, but provides no warning about storage location, retention, masking, or access controls. In practice this can lead to unnecessary collection of secrets, plaintext persistence in .env files, and accidental exposure to other tools, logs, or future sessions.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The workflow example references an unrelated school-search function while the rest of the document claims to provide random-generation tools. Such contradictory instructions are a strong indicator of copy-paste drift or repurposed code, which can cause the agent to invoke unintended capabilities or route user input to the wrong backend.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The code exposes a reusable external API calling primitive that sends authenticated requests to a configurable upstream using headers derived from local secrets and caller-supplied function names/parameters. Even if the upstream is trusted, embedding this generic capability inside a narrowly scoped randomness skill increases attack surface and may permit misuse of the service credentials for unintended external actions.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
99% confidence
Finding

The class docstring states this is a '高考Skill配置', which directly contradicts the advertised random-number service. Such inconsistencies are a supply-chain red flag because they suggest code reuse from another project or intentional mislabeling, both of which reduce transparency and can hide unrelated capabilities.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
76% confidence
Finding

User-visible natural-language strings and documentation in this file are exclusively Chinese, including messages such as the save-failure output. This can indicate a language policy issue because the skill does not offer a language choice or document that it is intentionally Chinese-only for a justified region-specific use case.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The code writes a sensitive API key to .env without any user-facing warning, confirmation, or notice about persistent storage. This is dangerous because users may assume a transient in-memory setting while the secret is actually being stored on disk, where it may be exposed via backups, logs, repository mistakes, or local compromise.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
74% confidence
Finding

The document is primarily written in Chinese, but the user-intent mapping and tool descriptions are presented only in English, with no indication that the user can choose their preferred language. This can amount to a language/locale policy issue because the skill imposes mixed language behavior without explicit opt-in or documented justification.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The documented project structure still uses a gaokao-related package name, directly conflicting with the claimed random-number service. While not by itself exploitable code, this inconsistency increases suspicion that the skill wraps unrelated components and can mislead operators during review, deployment, or incident response.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
97% confidence
Finding

The dependency requests is specified with only a lower bound (>=2.31.0), so builds may resolve to different versions over time. This weakens supply-chain control and makes it hard to verify whether deployed environments include vulnerable or incompatible releases, especially for a network-facing random-number service that may make outbound HTTP calls.

Content

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

text
requests>=2.31.0
pydantic>=2.7.0
pydantic-settings>=2.2.0
python-dotenv>=1.0.1

Unverifiable Dependency: requests has 16 known advisory(ies) (CVE-2014-1830 (Exposure of Sensitive Information to an Unauthorized Actor in Requests); CVE-2024-47081 (Requests vulnerable to .netrc credentials leak via malicious URLs); CVE-2024-35195 (Requests `Session` object does not verify requests after making first request wi) +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
92% confidence
Finding

requests has known advisories, and because the manifest does not pin an exact version, it is impossible to determine from this file alone whether the installed release is affected. In a service context, an HTTP client library with unresolved version ambiguity can expose the system to credential leakage, TLS/verification issues, or other network-related weaknesses if a vulnerable release is installed.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
96% confidence
Finding

pydantic is unpinned and may resolve to any future version above 2.7.0, reducing reproducibility and making security posture unverifiable. Because this package is central to validation and settings handling, unexpected upstream changes or vulnerable releases could affect parsing behavior or expose the service to denial-of-service risks.

Content

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

text
requests>=2.31.0
pydantic>=2.7.0
pydantic-settings>=2.2.0
python-dotenv>=1.0.1

Unverifiable Dependency: pydantic has 4 known advisory(ies) (CVE-2021-29510 (Use of "infinity" as an input to datetime and date fields causes infinite loop i); CVE-2024-3772 (Pydantic regular expression denial of service); CVE-2021-29510 (Pydantic is a data validation and settings management using Python type hinting.) +1 more), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
90% confidence
Finding

pydantic has published advisories, but the loose version specifier prevents verification that the deployed version is safe. Because this package governs data validation, a vulnerable version could enable denial of service or unsafe parsing behaviors depending on how inputs are processed by the service.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

pydantic-settings is declared with a floating lower-bound version, which allows unreviewed future releases into deployments. For a service that likely loads configuration and secrets from environment or files, this creates uncertainty around security fixes and around regressions in secret-loading behavior.

Content

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

text
requests>=2.31.0
pydantic>=2.7.0
pydantic-settings>=2.2.0
python-dotenv>=1.0.1

Unverifiable Dependency: pydantic-settings has 1 known advisory(ies) (CVE-2026-58203 (pydantic-settings: NestedSecretsSettingsSource follows symlinks outside secrets_)), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
88% confidence
Finding

pydantic-settings has at least one known advisory and the current manifest does not allow verification of the installed version. Given its likely role in loading secrets and configuration, unresolved version ambiguity can matter if the application reads from filesystem-backed secret sources or similar paths.

Content

No source excerpt is available for this finding.