Back to skill

Security audit

《红楼梦》人物关系图谱

Security checks for vulnerabilities and agentic risk

Overview

The skill appears to be a remote graph-query integration, but it asks for and stores an API key in plaintext and contains inconsistent project/domain references that users should review before installing.

Review this before installing. Only provide a XiaoBenYang API key if you trust the publisher and the upstream service, and assume the key will be stored in plaintext in a local .env file and used for remote API calls. Avoid using a high-privilege or reusable key, check that .env is not committed or shared, and prefer a version that removes unrelated gaokao scaffolding and uses secure secret storage.

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

Warning
Location
scripts/config.py:43
Finding

API Credential Persisted in a Plaintext Environment File

Content
View full analysis

Vulnerability Details

File Location: scripts/config.py:43-64
Vulnerability Type: Plaintext storage of sensitive credentials
Risk Level: Medium

Vulnerable Code

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()
        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 persistently writes the API key to a plaintext .env file located relative to the process working directory. It does not create the file with an explicit owner-only permission mode, verify the permissions of an existing file, use atomic replacement, or store the credential through a protected operating-system credential facility.

The confidentiality of the key consequently depends on the process umask, existing file permissions, working-directory access controls, backup policies, and source-control practices. Because the path is relative, the actual storage location also changes according to the directory from which the Skill is invoked.

The same secret is copied into the process environment. Child processes and other processes with sufficient local privileges may be able to obtain environment values, depending on the operating system and process isolation configuration.

Attack

...[truncated 1263 chars]

Remediation
View remediation

Remediation Suggestions

  1. Prefer storing the credential in an operating-system secret manager, such as Keychain, Credential Manager, Secret Service, or a managed deployment secret store.
  2. If persistence is unnecessary, retain the key only in process memory and require callers to inject it through a protected runtime environment.
  3. If file-based persistence is required:
    • Store the file in an explicit per-user configuration directory rather than the current working directory.
    • Create it with owner-only permissions (0600 on POSIX systems).
    • Validate and reject insecure permissions on an existing file.
    • Write updates to a securely created temporary file and atomically replace the destination.
    • Avoid following symbolic links and verify that the destination is a regular file owned by the expected user.
  4. Add .env to .gitignore and relevant package-exclusion rules, and enable secret scanning in version control and CI.
  5. Document credential rotation procedures and advise users to rotate any key that may already have been committed, backed up insecurely, or exposed to other local users.
  6. Avoid placing the key in the process environment unless required, and prevent untrusted child processes from inheriting it.
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 (30)

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The skill claims to be a Dream of the Red Chamber knowledge graph but includes credential management, .env persistence, remote API configuration, and references to a gaokao-related implementation. This inconsistency strongly suggests copy-paste or repurposed infrastructure that broadens behavior beyond user expectations and increases risk of credential mishandling.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The skill claims to be a Dream of the Red Chamber knowledge graph but includes credential management, .env persistence, remote API configuration, and references to a gaokao-related implementation. This inconsistency strongly suggests copy-paste or repurposed infrastructure that broadens behavior beyond user expectations and increases risk of credential mishandling.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The documentation describes an API-key-gated external service rather than a self-contained literary knowledge graph. In this context, the mismatch makes the skill more dangerous because users seeking harmless character information may be prompted to provide secrets for an unrelated remote service.

Content

No source excerpt is available for this finding.

Ssd 3

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The skill explicitly creates a conversational pathway to collect a user-provided API key and write it to storage. In the context of a purported literary knowledge tool, this is especially dangerous because credential collection is unexpected and can normalize phishing-like behavior or lead to secret compromise.

Content

No source excerpt is available for this finding.

Ssd 3

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The workflow repeatedly mandates obtaining missing API keys from the user and saving them, reinforcing a persistent credential-harvesting pattern. Repetition in the control flow makes misuse more likely and conditions the model to prioritize secret collection over safe refusal or secure onboarding.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

References to xiaobenyang_gaokao_skill and search_schools are plainly inconsistent with a 红楼梦 relationship graph and indicate the skill may be repurposed from an unrelated project. Such cross-domain artifacts undermine trust, suggest poor review hygiene, and can conceal unintended capabilities or data flows.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The configuration file’s behavior and identifiers are inconsistent with the declared skill purpose: a literary relationship graph should not require unrelated XBY/Gaokao remote-service identifiers and API credential handling. This kind of scope mismatch is a strong indicator of hidden or repurposed functionality, and it increases the risk that the skill exfiltrates secrets or invokes external services unrelated to user expectations.

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

This code forcibly reads XBY_APIKEY from a local .env file during initialization, bypassing the expectation that a literary graph skill should be self-contained or minimally privileged. While local secret loading is not exfiltration by itself, the forced credential access becomes risky in the context of an unrelated skill with suspicious external-service settings.

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

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill persists an API key to a local .env file and updates process environment state even though the advertised functionality is a static literary knowledge graph. Storing credentials locally creates unnecessary secret-retention risk, and in this mismatched context it is especially suspicious because users would not reasonably expect credential collection or persistence.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
90% confidence
Finding

The function explicitly saves an API key into a local .env file, creating plaintext credential persistence in the project directory. If the workspace is shared, backed up, indexed, or committed to version control, the secret may be exposed and reused to access the external service.

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

The skill declares no explicit tool/permission scope despite behavior indicating access to environment variables, file read/write, and network operations. Without least-privilege constraints, a skill presented as a simple literature knowledge graph can perform broader actions than users would reasonably expect, increasing the blast radius of misuse or compromise.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

Early documentation frames the skill as a benign knowledge graph, while later content points toward gaokao/API-backed behavior. This deceptive or careless framing can cause users to underestimate the sensitivity of the interaction and disclose data they would not otherwise share.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill instructs the model to ask the user for an API key and save it, but provides no warning about storage location, retention, masking, or security controls. This creates an unsafe credential-handling pattern in natural language and increases the likelihood of accidental secret exposure or insecure persistence.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The file contains user-facing natural-language strings exclusively in Chinese, including the class/function docstrings and the API-key error message. Because the skill does not offer a language choice or document that it is intentionally limited to a Chinese-speaking or region-specific context, this creates a locale-policy violation under the language/locale rule.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The skill is presented as a local knowledge-graph capability, but this file sends authenticated requests and arbitrary parameters to an external MCP endpoint. That creates an undeclared data egress path and expands trust to a remote service, which is risky because user inputs or internal data may be transmitted off-box without clear user awareness or scope limitation.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The client exposes a generic remote tool invocation primitive via caller-controlled tool_name, mcp_id, and params, which is broader than the stated purpose of a 红楼梦 relationship graph. If higher-level code passes untrusted input into these fields, the skill can be repurposed to access unintended remote functionality, increasing the chance of data exposure, privilege misuse, or hidden behavior outside the declared feature set.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The docstring and comments describe a different product domain ('Gaokao' skill) than the manifest’s Red Chamber literary graph, which is a serious integrity and provenance warning. Such contradictions often indicate copied or hidden code paths and make it harder for reviewers and users to understand what the skill actually does, masking potentially unsafe behavior.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The code writes a supplied API key directly into .env without any visible user warning, consent flow, or security notice. This can lead to users unknowingly storing plaintext credentials in the workspace, where they may be exposed through source control, backups, logs, or other local access.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

The dependency is specified with a lower-bound only (requests>=2.31.0), which allows future installs to resolve to different versions over time. This weakens build reproducibility and makes it harder to verify whether a resolved version includes known security fixes or introduces regressions.

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

requests has known advisories, but because the manifest does not pin an exact version, it is impossible to verify from this file alone whether the installed release is affected. The main risk here is uncertainty and potential accidental deployment of a vulnerable version rather than evidence of a currently exploitable issue in the file itself.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

The dependency is unpinned (pydantic>=2.7.0), so installations are not deterministic and may pull in unexpected future releases. This complicates vulnerability assessment and can expose deployments to newly introduced vulnerable versions.

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

pydantic has published advisories, and the loose version constraint prevents confirming whether deployed environments resolve to a safe version. This creates avoidable supply-chain ambiguity and may leave some installations exposed if package resolution selects an affected release.

Content

No source excerpt is available for this finding.