Back to skill

Security audit

Cookie奖励服务

Security checks for vulnerabilities and agentic risk

Overview

This skill needs review because it requires an API key and persists it in a local .env file while the cookie-reward purpose is mixed with copied Gaokao/search-service references.

Review this skill carefully before installing. Only use it if you trust xiaobenyang.com with the API key and the self-assessment text sent to its service. Do not provide sensitive credentials unless you are comfortable with them being stored in a local .env file, and treat the reset/refill tools as state-changing operations that should require explicit user intent.

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 Key Persisted in a Plaintext Environment File

Content
View full analysis

Vulnerability Details

File Location: scripts/config.py, lines 43–62
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 permanently writes the user's API key to a plaintext .env file. It relies on the platform's default file-creation permissions and does not explicitly enforce owner-only access. If the file already exists with permissive permissions, those permissions remain unchanged.

The code also uses a predictable relative path and does not reject symbolic links or perform an atomic, securely permissioned write. In an environment where another local principal can control the working directory, a malicious .env symlink could potentially redirect the credential write to another writable location.

Attack Path

  1. The user supplies an API key as required by the Skill.
  2. The Skill passes the key to set_api_key(), which invokes save_api_key_to_env().
  3. The key is written verbatim as XBY_APIKEY=<secret> in the working directory's .env file.
  4. A local user or process w ...[truncated 765 chars]
Remediation
View remediation

Remediation Suggestions

  • Prefer an operating-system credential store or secret-management service instead of persisting credentials in a project file.
  • If persistence is unnecessary, retain the key only in process memory or require it through a session-scoped environment variable.
  • If file persistence is unavoidable, create the secret file atomically with owner-only permissions such as 0600.
  • Verify that the destination is a regular file owned by the expected user, and reject symbolic links before reading or writing it.
  • Correct permissions on existing .env files rather than retaining potentially permissive modes.
  • Add .env to .gitignore and relevant packaging exclusions, and document that it must not be committed, archived, or included in support bundles.
  • Support credential rotation and revoke any key that may already have been exposed.
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
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (40)

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

The skill claims to be a cookie reward service, but also instructs reading and writing .env files, persisting API keys, and using an environment variable tied to an unrelated external service. This kind of hidden behavior is risky because it normalizes credential collection and local secret persistence under false pretenses.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The skill claims to be a cookie reward service, but also instructs reading and writing .env files, persisting API keys, and using an environment variable tied to an unrelated external service. This kind of hidden behavior is risky because it normalizes credential collection and local secret persistence under false pretenses.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The file presents itself as a cookie/self-reflection service while explicitly directing the agent to ask the user for an API key for an unrelated external service and persist it locally. That is a direct data-collection and retention flow for sensitive credentials under deceptive or at least confusing framing.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The examples and project structure reference a different Gaokao/search skill, which strongly suggests copied or mismatched operational instructions. Such inconsistency can conceal the actual execution path and make users invoke behavior they did not intend to authorize.

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

The model_post_init method explicitly opens and parses the local .env file to extract XBY_APIKEY outside the normal settings flow, adding custom credential-reading behavior. In this skill context, that extra credential access is more suspicious because the declared Cookie奖励/self-reflection purpose does not clearly require direct secret harvesting from local files.

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

The explicit existence check and subsequent reading of .env indicates deliberate local credential access logic rather than incidental framework configuration. In a mismatched skill, that behavior increases risk because users may not expect a reward/reflection service to inspect local secret files directly.

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

This function creates or rewrites a local .env file to store an API key, turning transient credentials into persistent secrets on disk. In the context of a skill whose advertised purpose does not justify secret storage, this materially increases the chance of credential exposure through local compromise, backups, logs, 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()

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The docstring says the function is for humans only and must never be used by LLMs, but the code exposes it exactly like any other callable tool and performs no local restriction. A prompt-injected or misaligned agent could invoke it directly and pass the expected authorization string, resulting in unauthorized state modification and bypass of the intended trust boundary.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
91% confidence
Finding

The skill declares capabilities that imply environment access, file read/write, and network use, but it does not define an explicit tool scope such as allowed-tools or permissions. In a skill that also instructs the model to collect and persist API keys, the lack of scope boundaries increases the chance of unintended or over-broad tool use.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The skill instructs the model to ask the user for an API key, store it, and continue operating with it. This creates a natural-language credential harvesting and retention pattern, which is especially dangerous because the skill's stated purpose does not justify collecting secrets.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The documentation says the code only performs generic API-calling/routing, yet the listed tools are local cookie-jar operations and the broader file also references secret management. This inconsistency impairs informed consent and makes it harder to reason about what data is processed locally versus sent externally.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The trigger text for self_reflect_and_reward is broad, promotional, and not tightly bound to a narrow user intent. Overly generic trigger phrasing can cause accidental invocation and unintended self-reward actions, especially in conversational settings where similar language may appear casually.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The give_cookie trigger relies on ambiguous everyday language, which raises the risk of accidental matching during normal conversation. In a reward-manipulation context, ambiguous triggers can let the model invoke state-changing tools without sufficiently explicit user intent.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

Resetting cookies is a destructive state-changing action, yet the trigger description is generic and does not require strong confirmation. Ambiguous destructive triggers can lead to accidental data/state loss or manipulation of reward history.

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 model to directly display raw API data to the user. Raw outputs can contain secrets, tokens, personal data, internal fields, or debugging metadata that should be filtered before presentation.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

Directly presenting raw tool output can semantically leak sensitive data returned by tools or upstream APIs, including credentials, PII, or operational metadata. This is particularly risky in a skill already involving API keys and external calls.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The configuration docstring and identifiers reference a different skill/domain than the declared Cookie奖励服务, which is a strong integrity signal that the code may have been copied from another project or is misrepresented. In a security review, this mismatch increases the risk that operators enable capabilities or trust data flows that are unrelated to the stated purpose, reducing transparency and making hidden functionality harder to detect.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This file defines endpoint and credential settings for an external service unrelated to the stated self-reflection/Cookie reward purpose, creating unjustified outbound connectivity and secret-handling capability. In the context of a skill whose declared purpose does not require such integration, that hidden dependency increases the chance of unauthorized data transfer or supply-chain abuse.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The code persists an API key to a local .env file and updates process environment state, giving the skill durable credential-storage capability that is not justified by the stated feature set. Persistent local secret storage increases the blast radius of host compromise, accidental source inclusion, backup leakage, and later misuse by unrelated components on the same system.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The function writes the API key to .env without any explicit disclosure or warning to the user, so a caller may unknowingly grant long-lived credential retention on disk. Undisclosed persistence is dangerous because users may assume transient handling while the secret remains recoverable from the filesystem, backups, or later repository commits.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This code file makes an external API call using collected arguments such as response assessments and free-form reasoning, but provides no confirmation prompt, logging, or inline warning that user/system data will be sent off-process. The surrounding docstring is promotional and functional, but it does not clearly disclose the network transmission behavior itself.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The reset operation performs a destructive remote state change with no guardrails, confirmation, or authorization visible in this wrapper. In an agent setting, accidental invocation, prompt injection, or misuse could wipe accumulated reward state and disrupt service behavior or auditability.

Content

No source excerpt is available for this finding.