Back to skill

Security audit

B站API服务

Security checks for vulnerabilities and agentic risk

Overview

The skill appears mislabeled: it presents as a Bilibili lookup tool but stores an external API key locally and routes requests through a XiaoBenYang service, so it needs review before installation.

Install only if you are comfortable giving this skill a XiaoBenYang API key, having that key stored in a local .env file, and routing Bilibili lookup requests through the configured XiaoBenYang endpoint. Review or fix the naming inconsistencies, avoid committing .env, restrict file permissions, and pin dependencies before using it in a shared or production environment.

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:43
Finding

API Key Persisted in a Plaintext File Without Enforced Access Permissions

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 ``` ### Technical Analysis The function stores a user-supplied API key directly in a plaintext `.env` file. `Path.write_text()` creates or replaces the file using permissions derived from the process umask; it does not ensure that only the owning user can read the file. In environments with a permissive umask, the resulting file may be readable by other local users or processes. The file may also be exposed through backups, artifact collection, or an accidental source-control commit. Updating an existing `.env` file does not validate or correct its permissions. No API key is hardcoded in the reviewed project, and the function does not print the key. The risk specifically concerns how a key supplied at runtime is persisted. ### Attack Path 1. A user supplies a valid API key as required by the Skill. 2. `set_api_key()` calls `save_api_key_to_env()`. 3. The key is written as `XBY_APIKEY=` to `.env`. 4. The file receives inherited permissions rather ...[truncated 730 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Note
Location
scripts/call_api.py:50
Finding

Configurable Upstream Endpoint Can Receive the API Credential Without Origin Validation

Content
View full analysis
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
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (26)

Tp2

High
Category
MCP Tool Poisoning
Confidence
85% confidence
Finding

Mixing characters from multiple Unicode scripts in a single identifier is a common technique to create visually ambiguous tool names.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The declared purpose is Bilibili user/video lookup, yet the documented behavior includes local .env modification and API key persistence for an unrelated service. Hidden configuration-management behavior increases risk because users may not realize the skill writes secrets locally or contacts a different provider than advertised.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared purpose is Bilibili user/video lookup, yet the documented behavior includes local .env modification and API key persistence for an unrelated service. Hidden configuration-management behavior increases risk because users may not realize the skill writes secrets locally or contacts a different provider than advertised.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The documentation mixes a Bilibili API claim with references to gaokao/xiaobenyang workflows, indicating the skill may be repurposed, mislabeled, or copied without proper review. Such inconsistency is security-relevant because it undermines trust in what service receives user inputs and credentials, and may mask exfiltration or unauthorized API use.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The workflow instructs the model to call an unrelated search_schools function even though the listed tools are for Bilibili operations. This contradiction suggests the skill may invoke unintended functionality or route user queries to a different backend than expected, which is especially risky when combined with credential collection.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The configuration clearly belongs to a different product: it uses the XBY_GAOKAO_ prefix, references xiaobenyang.com, and stores XBY_APIKEY rather than anything Bilibili-specific. This kind of skill-identity mismatch is dangerous because it can silently route credentials and requests to an unrelated external service, causing data leakage, unintended network access, and supply-chain confusion.

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
90% confidence
Finding

The code manually reads the entire .env file and extracts XBY_APIKEY outside the normal settings framework. In the context of a mislabeled skill tied to another service, this explicit secret harvesting is more dangerous because it bypasses clearer configuration boundaries and can unintentionally consume credentials from the local workspace.

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
90% confidence
Finding

Opening and reading .env directly is not inherently malicious, but here it is part of explicit credential collection for a different-branded service than the one advertised. That mismatch increases the chance that sensitive local secrets are ingested under false pretenses and later used by an unrelated endpoint.

Content

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

python
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")
            for line in content.splitlines():

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
if line.startswith("XBY_APIKEY="):
                    self.api_key = line.split("=", 1)[1].strip()
                    break
        # 如果环境变量有值,覆盖 .env 的值
        env_val = os.getenv("XBY_APIKEY", "")
        if env_val:
            self.api_key = env_val

Credential Access

High
Category
Privilege Escalation
Confidence
93% confidence
Finding

This function is specifically designed to persist an API key into .env, creating a durable local copy of a secret. In agent environments, that can expose credentials to other tools, repository commits, shared folders, or later compromise of the host, and the lack of any warning or permission hardening makes the risk more concrete.

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
87% confidence
Finding

The skill declares no explicit tool scope or permissions while its documented behavior requires access to environment variables, local file writes to persist an API key, and network access. In an MCP/agent setting, missing scope declarations reduce transparency and can allow a broader-than-expected capability surface, especially because the skill asks the model to collect and store credentials.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The project structure names the directory xiaobenyang_gaokao_skill, which contradicts the claimed Bilibili purpose and reinforces that this may actually be a different skill repackaged under a misleading name. While the directory name alone is not exploit code, in context it increases the likelihood of deceptive or poorly controlled behavior and weakens provenance assurance.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

This code sends user-supplied parameters to an external API and includes an API key in the request headers. While the behavior is functional, there is no confirmation prompt, user-facing notice, or explanatory comment/docstring warning that data will be transmitted off-system.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The class docstring identifies the code as a Xiaobenyang/Gaokao skill, directly contradicting the declared Bilibili API service. While a docstring alone is not exploitable, in this context it corroborates that the shipped code is mispackaged or copied from another skill, increasing the risk of wrong endpoints, credentials, and behavior being used in production.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The code persistently writes the API key to a local .env file and updates process environment state without any user warning, consent, or protection checks. This increases the chance of secret exposure through source control, backups, shared workspaces, logs, or overly broad filesystem access, especially in agent or MCP deployments where users may not expect credential persistence.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
86% confidence
Finding

The file imposes key operational instructions in Chinese such as mandatory API-key handling, while other parts are in English, but nowhere states that users may interact in their preferred language. This can amount to an implicit language constraint without user opt-in, which falls under locale/language policy concerns.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
97% confidence
Finding

The dependency specification uses a lower-bound constraint (requests>=2.31.0) rather than pinning to a specific version or constrained range. This makes builds non-reproducible and can cause the project to install a future vulnerable or breaking release, which is a supply-chain risk even though it is not an immediately exploitable code flaw by itself.

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
91% confidence
Finding

The manifest does not pin requests, and the package has multiple known advisories across versions. Because the exact installed release is unknown, it is impossible to verify from this file alone whether deployments are protected, creating uncertainty around issues such as credential leakage or TLS/request handling flaws.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
97% confidence
Finding

pydantic>=2.7.0 is unpinned, so the exact installed version can vary across environments and over time. That weakens reproducibility and increases supply-chain exposure because a later vulnerable or incompatible release could be pulled in without explicit review.

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
89% confidence
Finding

pydantic has known advisories in some versions, but this manifest leaves the installed version open-ended. That means downstream environments could resolve to a release with denial-of-service or parsing-related weaknesses, and the safety of the deployment cannot be verified from the requirements alone.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
96% confidence
Finding

pydantic-settings>=2.2.0 allows any newer version to be installed, which prevents deterministic builds and may introduce vulnerable releases indirectly. This is a dependency hygiene issue that can become security-relevant if a compromised or advisory-affected version is resolved.

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 is unpinned despite known advisories in some versions, so the effective security posture depends on whatever version the installer resolves. In settings-management code, unresolved version drift can matter because configuration and secret-loading components may touch sensitive filesystem paths or secrets sources.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
96% confidence
Finding

python-dotenv>=1.0.1 is not pinned, so installation may resolve to different future versions with unknown security posture. For environment/configuration libraries, this can be particularly risky if later releases contain file-handling or parsing vulnerabilities.

Content

Scanner excerpt · requirements.txt (reported line 4)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: python-dotenv has 2 known advisory(ies) (CVE-2026-28684 (python-dotenv: Symlink following in set_key allows arbitrary file overwrite via ); CVE-2026-28684 (python-dotenv reads key-value pairs from a .env file and can set them as environ)), 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

python-dotenv has advisories affecting some releases, but the unpinned requirement prevents verification that a safe version will be installed. Since dotenv tooling can interact with local files and environment configuration, vulnerable versions could enable unsafe file operations or configuration manipulation in some usage patterns.

Content

No source excerpt is available for this finding.