Back to skill

Security audit

字符索引字符串处理工具

Security checks for vulnerabilities and agentic risk

Overview

This skill performs simple string operations by sending user text to an external authenticated API and storing the API key in a local plaintext .env file, which needs review before use.

Install only if you are comfortable sending all processed strings to the Xiaobenyang MCP service and storing the API key in a plaintext .env file in the working directory. Avoid using it on secrets, proprietary code, personal data, or regulated content unless the publisher provides clearer data-handling and credential-storage assurances.

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

T05 · Unauthorized Access and Privilege Escalation

Error
Location
scripts/call_api.py:47
Finding

User-Supplied Text Is Transmitted to an External Service Without Clear Disclosure

Content
View full analysis

Vulnerability Details

File Location: scripts/tools.py:20-25 and scripts/call_api.py:47-77
Vulnerability Type: Excessive external data disclosure and violation of least privilege
Risk Level: High

Vulnerable Code

python
arguments = {
    "text": text,
    "char": char,
    "n": n
}

return call_api("1777419060716547", "find_nth_char", arguments)
python
def call_tool(
    self,
    mcp_id: str,
    tool_name: str,
    params: dict[str, Any],
) -> 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,
        )

Technical Analysis

The tool wrappers place complete user-supplied strings into an argument dictionary and pass that dictionary to call_api. The API client serializes the parameters as JSON and sends them to https://mcp.xiaobenyang.com/api, together with the user's API key.

This behavior applies throughout scripts/tools.py, including character indexing, substring extraction, regular-expression matching, replacement, and counting operations. These deterministic string operations could be implemented locally and do not inherently require external network access. Sending their complete input to a third party therefore exceeds the minimum access needed to perform the advertised task.

Although the documentation states that an API is called, it does not clearly explain that the entire input text will leave the local environment. Us ...[truncated 1351 chars]

Remediation
View remediation

Remediation Suggestions

  1. Implement the deterministic string-processing operations locally so user content does not leave the environment.
  2. If remote processing is essential, obtain explicit informed consent before transmitting content.
  3. Clearly document:
    • The destination host.
    • The exact fields transmitted.
    • Whether request bodies are logged.
    • Data retention and deletion policies.
    • Any subprocessors or additional recipients.
  4. Provide a local-only mode and make it the default for sensitive inputs.
  5. Detect and redact likely credentials, tokens, and other secrets before network transmission.
  6. Minimize request contents so only strictly necessary data is sent.
  7. Add configurable outbound-host allowlisting and prevent runtime redirection to untrusted destinations.
  8. Add tests confirming that local operations do not unexpectedly generate network traffic.

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/config.py:43
Finding

API Key Is Persisted in a Plaintext .env File Without Enforced Restrictive Permissions

Content
View full analysis

Vulnerability Details

File Location: scripts/config.py:43-65
Vulnerability Type: Insecure plaintext credential storage
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 application writes the API key directly into a plaintext .env file relative to the process's current working directory. It does not use an operating-system credential store, explicitly create the file with mode 0600, verify file ownership, protect against symbolic-link substitution, or confirm that the chosen working directory is private.

Because Path.write_text follows symbolic links and uses ordinary process defaults, the effective protection depends on the current directory, existing file permissions, and process umask. If the file already exists with broad permissions, rewriting it does not necessarily restrict those permissions. A relative path also increases the risk of storing the secret in an unintended project or repository directory.

The documentation instructs the agent to collect and persist the key, so this storage behavior is part of the expected workflow rather than an exceptional code path.

Attack Path

  1. The Skill determines that no API ...[truncated 1138 chars]
Remediation
View remediation

Remediation Suggestions

  1. Prefer session-only environment variables or an operating-system credential manager instead of filesystem persistence.
  2. If file storage is unavoidable:
    • Use a dedicated, user-specific configuration directory.
    • Create the file atomically with permissions set to 0600.
    • Verify that the file is owned by the expected user.
    • Reject symbolic links and other unexpected file types.
    • Restrict the parent directory to the owning user.
  3. Avoid deriving the credential path from an uncontrolled current working directory.
  4. Add .env to version-control ignore rules and exclude it from archives, container build contexts, diagnostics, and backups where appropriate.
  5. Do not print, log, or include the key in exception messages.
  6. Provide users with key rotation and revocation guidance.
  7. On systems where the existing file may have permissive access, validate and correct its permissions before reading or updating it.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (36)

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The English description similarly presents a deterministic local string tool, while the workflow and project structure describe credential loading, persistent API-key storage, and external configuration management. Such hidden stateful and networked behavior creates a trust boundary violation and can lead to unanticipated credential exposure or data exfiltration.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

The English description similarly presents a deterministic local string tool, while the workflow and project structure describe credential loading, persistent API-key storage, and external configuration management. Such hidden stateful and networked behavior creates a trust boundary violation and can lead to unanticipated credential exposure or data exfiltration.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The skill claims to be a local character-index processor, yet it requires an API key and mandates remote API usage. For the stated task, this dependency is unjustified and increases the chance that user text and secrets are sent to an unrelated external service under misleading pretenses.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

Requiring API-key collection and an external service for basic character indexing is disproportionate to the stated functionality. This creates unnecessary credential collection and outbound data flow, which materially increases security and privacy risk without a legitimate need established in the manifest.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

The workflow instructs the model to call tools and return raw API data even though the listed functions appear to be simple deterministic string utilities. This contradiction indicates the actual outputs may come from an opaque remote service, making data exposure and misleading results more likely.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

This file implements a generic outbound API client that can invoke arbitrary upstream tools via caller-controlled tool_name, mcp_id, and JSON parameters, which exceeds the stated purpose of a character-index string processing skill. In an agent skill context, this creates a capability expansion risk: the skill can be used as a general networked action proxy, enabling unintended data exfiltration or unauthorized remote operations through the external MCP service.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

The code retrieves an API key and sends it to an external service in request headers, giving this skill authenticated outbound network access that is not justified by local string manipulation alone. In a skill environment, authenticated external connectivity materially increases the blast radius because malicious or mis-scoped tool invocations could send sensitive inputs or trigger privileged actions on the remote service.

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

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The file includes logic to read, update, and persist credentials locally, which materially exceeds the expected scope of a string-processing utility. In skill ecosystems, unjustified secret-management capability increases the chance of credential collection, accidental leakage, or repurposing of the skill for unauthorized external service access.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
91% confidence
Finding

This code forcibly reads a local .env file to extract a specific API credential outside the normal typed settings flow. That custom secret-harvesting behavior broadens credential access and bypasses clearer configuration boundaries, which is especially concerning given the mismatch between the skill's stated purpose and the presence of external API credential logic.

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

This section prioritizes an environment-provided XBY_APIKEY and sets it into application state, confirming that the skill actively consumes an external credential. In context, this is dangerous because it operationalizes credential use for functionality unrelated to the manifest-described string-processing task, increasing the chance of unauthorized external access or hidden service dependency.

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

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

This code adds secret-handling and persistence behavior to a skill whose stated purpose is character-index string processing. It writes an externally supplied API key into a local .env file and process environment without clear scope justification, creating unnecessary credential exposure and persistence risk if the skill is invoked in untrusted or shared environments.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

This function is explicitly designed to save an API key into a local .env file, creating plaintext on-disk persistence of a secret. In a shared development, CI, or agent environment, that can lead to credential theft through file access, accidental commits, logs, backups, or unrelated tooling that reads workspace files.

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

The skill omits any explicit tool-scoping or permissions declaration even though the documentation indicates access to environment variables, file writes, and network/API usage. In an agent setting, undeclared capabilities reduce reviewability and can allow broader-than-expected credential handling or outbound communication.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The skill name and description are entirely in Chinese, and the operational instructions are written only in Chinese without stating that this is a region-specific or language-specific tool. This can impose a language/locale constraint on use without user opt-in, which matches the policy-violation category for forced language behavior.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The skill tells the agent to ask the user for an API key and save it, but it does not disclose that the credential will be persisted or explain storage implications. Users may provide sensitive secrets without informed consent, and persisted credentials increase theft and misuse risk.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The documented normal flow requires soliciting a user API key, persisting it, and then using it for external calls. Routine collection and storage of user credentials inside a skill expands the attack surface and can lead to credential leakage or unauthorized reuse.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The project structure includes an API client and the return-value section directs exposure of raw API responses, which conflicts with the identity of a local string processing skill. This broadens the data-handling surface and can leak unexpected fields from upstream services to the user.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill instructs the model to directly display raw API-returned data, creating a semantic data-leak path from the upstream service to the end user. If the external service returns debug information, identifiers, or sensitive content, the agent would expose it without review or minimization.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
75% confidence
Finding

Natural-language strings in this file are exclusively in Chinese, including the client description and user-facing error/status messages. The file does not indicate that Chinese is optional, user-selected, or required for a documented region-specific purpose, which can violate language/locale policy expectations.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

The API key is silently fetched and transmitted in the XBY-APIKEY header without any disclosure or consent mechanism in this code path. While sending an API key in a header is normal for authenticated APIs, the security issue here is the undisclosed use of credentials and external transmission within a skill whose stated purpose does not imply remote authenticated access.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
99% confidence
Finding

The docstring identifies the code as configuration for a different skill ('小笨羊高考Skill'), which conflicts with the declared identity of this package. This mismatch is suspicious because it suggests code reuse or hidden functionality, making it harder for reviewers to trust the declared scope and increasing the likelihood that unrelated network/credential behavior was bundled in unintentionally or deceptively.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The function persists an API key to .env automatically with no user-facing warning, consent, or discussion of storage location. Plaintext secret persistence can expose credentials to other local users, backup systems, source-control mistakes, or later unintended disclosure by tools that read project files.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The module presents itself as local string-processing utilities, but imports a remote API helper and routes all operations through it. That means arbitrary caller-provided text is transmitted off-host for trivial operations, creating an unexpected data-exfiltration and trust-boundary issue inconsistent with the stated functionality.

Content

No source excerpt is available for this finding.