Back to skill

Security audit

数据库访问服务

Security checks for vulnerabilities and agentic risk

Overview

This skill is framed as database metadata lookup but also exposes raw SQL execution and stores API credentials locally, so users should review the access boundary before installing.

Install only if you trust the remote XiaoBenYang MCP service and the API key is scoped to data you are comfortable exposing. Treat this as a database-query skill, not just metadata lookup; avoid using privileged database credentials, review the remote backend permissions, and keep the .env file out of source control and shared directories.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • 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
Findings (3)

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/tools.py:42
Finding

Unrestricted Client-Supplied SQL Is Forwarded to the Database Service

Content
View full analysis
Dict[str, Any]: """ MCP Tool to execute a SQL query. Args: query: A SQL query string provided by the client. Returns: JSON-formatted query results as a string or an error message. """ arguments = { "query": query } return call_api("1819483683233802", "sql_query", arguments) ``` ### Technical Analysis The `sql_query` function accepts an arbitrary SQL string and forwards it directly to the remote MCP database service. The code does not restrict the query to read-only operations, enforce a single statement, allowlist accessible schemas or tables, impose a result limit, or reject data-definition and data-modification statements. This capability also exceeds the Skill's stated database-metadata purpose. Although the final behavior depends on validation and database privileges configured by the remote service, this client establishes no least-privilege boundary of its own. If the upstream service executes queries under a role with write or administrative permissions, the caller may be able to access or alter resources beyond metadata retrieval. ### Attack Path 1. A user or attacker supplies a malicious query through the Skill's `sql_query` capability. 2. The agent passes the query to `scripts.tools.sql_query`. 3. The function places the unmodified query in the API request body. 4. `call_api` transmits it to the remote `sql_query` tool. 5. If the upstream database role permits the requested operation, the statement executes with that role's privileges. 6. The attacker may retrieve unauthorized records, alter or delete data, change database objects, or consume database resources. Example classes of dangerous input include unr ...[truncated 667 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/call_api.py:51
Finding

Environment-Controlled API Base URL Can Redirect API Credentials

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/config.py:42
Finding

API Key Is Persisted in Plaintext Without Explicit File-Permission Hardening

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 API key is written directly into a plaintext `.env` file in the current working directory. The implementation does not explicitly create the file with owner-only permissions, verify ownership of an existing file, reject symbolic links, or use an atomic secure-file creation procedure. The resulting access level depends on the host operating system, current `umask`, existing file permissions, directory permissions, and deployment model. In shared or improperly configured environments, another local principal may be able to read the key. Storing the file in the project directory also increases the possibility of accidental source-control inclusion, artifact packaging, or backup exposure. ### Attack Path 1. A user supplies a valid API key as directed by the Skill. 2. `set_api_key` calls `save_api_key_to_env`. 3. The function writes the raw key into `.env` using ordinary text-file operations. 4. The file receives existing permissions or permission ...[truncated 917 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
99% confidence
Finding

Although the skill is presented as metadata retrieval, it exposes a tool for executing arbitrary SQL queries supplied by the client. In context, that is far more dangerous than listing tables or schemas because it can enable unauthorized reads, data modification, deletion, or administrative actions depending on backend permissions.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Although the skill is presented as metadata retrieval, it exposes a tool for executing arbitrary SQL queries supplied by the client. In context, that is far more dangerous than listing tables or schemas because it can enable unauthorized reads, data modification, deletion, or administrative actions depending on backend permissions.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

Although the skill is presented as metadata retrieval, it exposes a tool for executing arbitrary SQL queries supplied by the client. In context, that is far more dangerous than listing tables or schemas because it can enable unauthorized reads, data modification, deletion, or administrative actions depending on backend permissions.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The manifest advertises only database metadata retrieval, but the documented toolset includes arbitrary SQL query execution. This discrepancy can cause security review bypass or unsafe deployment because the declared trust boundary is narrower than the actual capability.

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")

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

The file implements storage and retrieval of an external API key in both .env and process environment even though the declared skill purpose is only database metadata retrieval. That capability expands the trust boundary and enables credential collection/persistence that is not clearly necessary for the stated function, increasing the risk of secret misuse or unintended exfiltration if the skill is invoked in a broader agent environment.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
81% confidence
Finding

This function is specifically designed to persist an API key into a local .env file, creating a durable plaintext credential store in the working directory. In the context of a skill advertised for database metadata retrieval, that is more dangerous because users may not expect local secret storage and the key may be exposed through filesystem reads, backups, or accidental repository inclusion.

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

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The skill metadata and description claim the service is only for database metadata retrieval, but the exposed sql_query function allows arbitrary SQL supplied by the client to be executed through the backend API. This creates a capability mismatch that can enable unauthorized data access, modification, or destructive operations if a user or downstream agent trusts the manifest and invokes the skill in a lower-risk context.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding

The skill declares no explicit tool scope or permissions, yet its documented behavior requires environment access, file reads/writes, and network/API interaction. This creates an under-declared capability boundary, making it harder for reviewers and users to understand what the skill can actually do and increasing the risk of unintended secret handling or external data exfiltration.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
79% confidence
Finding

The skill content is presented entirely in Chinese and names the skill in Chinese, effectively constraining interaction to a specific language without any opt-in or alternative. The policy requires that language constraints be optional or explicitly justified, which is not documented here.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The top-level description frames the skill as a metadata utility, but the same file later documents arbitrary SQL execution. In this context, the mismatch is especially dangerous because metadata access sounds low risk, while raw SQL execution can have broad confidentiality, integrity, and availability consequences.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The skill documents execution of arbitrary SQL queries without warning users about destructive operations or data exposure. Because the provided query comes from the client and no safety constraints are described, the skill may be used for deletion, alteration, or sensitive data extraction with little friction.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The documentation contradicts the manifest by describing broader behavior than metadata retrieval, which undermines transparency and safe review. Even if not overtly malicious, this inconsistency increases the chance that users authorize a skill they do not fully understand.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The class docstring identifies the configuration as belonging to a Gaokao-related skill, which conflicts with the manifest's database access service identity. This inconsistency is a supply-chain trust signal because it suggests code reuse, repackaging, or mislabeling that can hide capabilities users did not expect.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The code can persist a supplied API key to a local .env file without showing that such persistence is necessary for database metadata retrieval. Local secret persistence increases exposure to accidental disclosure through filesystem access, backups, source control mistakes, or later reuse by unrelated components.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The function silently persists the API key to .env and also exports it into the current process environment without any user-facing warning or consent flow. Users may provide a credential expecting transient use, but the implementation creates durable local storage that can be discovered by other tools, users, or future processes.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
97% confidence
Finding

The dependency specifier requests>=2.31.0 is unpinned, so builds may resolve to different future versions over time. This weakens supply-chain integrity and makes it harder to ensure the installed version is free from known vulnerabilities or breaking changes.

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

requests has multiple known advisories, and because the manifest does not pin a specific version, it is impossible to confirm from this file alone whether deployments are using an affected release. In a database access service, HTTP client behavior may be security-sensitive if it is used for remote integrations, metadata fetching, or credentialed outbound requests.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
97% confidence
Finding

The dependency specifier pydantic>=2.7.0 allows uncontrolled upgrades to any later release. This creates a supply-chain risk because vulnerable or incompatible versions could be installed 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, but the unpinned requirement prevents verification that a safe version is installed. Since this service handles database metadata, any parsing or validation library should be tightly controlled because malformed input could potentially trigger denial-of-service or validation bypass issues if an affected version is selected.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
96% confidence
Finding

The dependency specifier pydantic-settings>=2.2.0 is not pinned to an exact version, so installation results can vary across environments and over time. This makes it difficult to verify whether deployed instances are affected by known advisories or regressions.

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 version range in this manifest does not prove whether the deployed version is patched. In a service that likely loads configuration and secrets, settings-handling flaws can become more relevant because they may affect how secret material or filesystem-backed configuration is resolved.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.