Back to skill

Security audit

ocusMind - AI Brain Fog Clearer (Agent 脑雾清除神器)

Security checks for vulnerabilities and agentic risk

Overview

FocusMind mainly performs context analysis, but it includes under-disclosed file, export, and optional webhook capabilities plus unsafe HTML report output that should be reviewed before use.

Review this skill before installing. It appears to be a real context-analysis utility, but use it only with explicit input and output paths, avoid HTML export for untrusted or shared conversation content until output escaping is fixed, and do not enable webhook or file notifications unless you are comfortable sending/storing context-derived report data.

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/export.py:150
Finding

Stored HTML Injection in Exported Reports

Content
View full analysis

Vulnerability Details

File Location: scripts/export.py, lines 150–166
Vulnerability Type: Stored HTML injection caused by missing output encoding
Risk Level: Medium

Vulnerable Code

python
if goals.get('main_goal'):
    html += f"    <h3>核心目标</h3>\n    <p>{goals['main_goal']}</p>\n"

if goals.get('sub_goals'):
    html += "    <h3>子目标</h3>\n    <ul>\n"
    for g in goals['sub_goals']:
        status = "✓" if g.get('completed') else "○"
        cls = "done" if g.get('completed') else ""
        html += f'        <li class="{cls}">{status} {g["content"]}</li>\n'
    html += "    </ul>\n"

if goals.get('pending'):
    html += "    <h3>待完成</h3>\n    <ul>\n"
    for p in goals['pending']:
        html += f"        <li>{p}</li>\n"
    html += "    </ul>\n"

The affected fields are derived from conversation content without sanitization. For example, scripts/extract_goals.py, lines 37–53, returns user-controlled message text:

python
for msg in messages[:5]:
    if msg.get("role") != "user":
        continue

    content = msg.get("content", "")

    for keyword in GOAL_KEYWORDS:
        if keyword in content:
            sentences = re.split(r'[。.!?]', content)
            for sent in sentences:
                if keyword in sent and len(sent) > 5:
                    return sent.strip(), "initial"

    if len(content) > 10:
        return content[:200], "initial"

Technical Analysis

Exporter.to_html() constructs an HTML document by directly interpolating goal data into element bodies. The main_goal, sub_goals[].content, and pending[] values can originate from untrusted conversation messages processed by extract_goals().

No contextual HTML escaping is applied to these values. Consequently, HTML tags and event-handler attributes are interpreted as active markup rather than displayed as text. Although the summary field is partially escaped elsewhere in to_html(), that protection does not cover the affected goal fie ...[truncated 1869 chars]

Remediation
View remediation

Remediation Suggestions

Apply contextual HTML escaping to every dynamic value before inserting it into the report:

python
from html import escape

if goals.get("main_goal"):
    main_goal = escape(str(goals["main_goal"]))
    html += f"    <h3>Core Goal</h3>\n    <p>{main_goal}</p>\n"

if goals.get("sub_goals"):
    html += "    <h3>Sub-goals</h3>\n    <ul>\n"
    for goal in goals["sub_goals"]:
        status = "✓" if goal.get("completed") else "○"
        css_class = "done" if goal.get("completed") else ""
        safe_class = escape(css_class, quote=True)
        safe_status = escape(status)
        safe_content = escape(str(goal.get("content", "")))
        html += (
            f'        <li class="{safe_class}">'
            f"{safe_status} {safe_content}</li>\n"
        )
    html += "    </ul>\n"

if goals.get("pending"):
    html += "    <h3>Pending</h3>\n    <ul>\n"
    for item in goals["pending"]:
        html += f"        <li>{escape(str(item))}</li>\n"
    html += "    </ul>\n"

Additional hardening should include:

  1. Escape all other dynamic HTML fields, including recommendations, labels, summaries, and future metadata.

  2. Prefer a template engine with automatic escaping rather than manual string concatenation.

  3. Do not rely on input sanitization alone; perform output encoding for the exact destination context.

  4. Add a restrictive Content Security Policy to generated reports, such as:

    html
    <meta http-equiv="Content-Security-Policy"
          content="default-src 'none'; style-src 'unsafe-inline'; img-src data:">
    
  5. Add regression tests containing <script> elements, event-handler attributes, quotes, ampersands, malformed tags, and encoded payloads.

  6. Verify generated reports display malicious test strings literally and do not create executable DOM elements.

Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (37)

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

Telemetry and runtime statistics collection are not inherently malicious, but they materially change the privacy profile of a skill that processes agent context. Undisclosed collection of usage, timing, and error data can expose sensitive operational metadata and undermines informed consent.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

Telemetry and runtime statistics collection are not inherently malicious, but they materially change the privacy profile of a skill that processes agent context. Undisclosed collection of usage, timing, and error data can expose sensitive operational metadata and undermines informed consent.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

Telemetry and runtime statistics collection are not inherently malicious, but they materially change the privacy profile of a skill that processes agent context. Undisclosed collection of usage, timing, and error data can expose sensitive operational metadata and undermines informed consent.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

Telemetry and runtime statistics collection are not inherently malicious, but they materially change the privacy profile of a skill that processes agent context. Undisclosed collection of usage, timing, and error data can expose sensitive operational metadata and undermines informed consent.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

Telemetry and runtime statistics collection are not inherently malicious, but they materially change the privacy profile of a skill that processes agent context. Undisclosed collection of usage, timing, and error data can expose sensitive operational metadata and undermines informed consent.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding

The skill advertises executable components and integrations implying file I/O and possible network activity, but it declares no explicit tool scope or permissions boundary. In an agent environment, this can cause the skill to receive broader capabilities than users expect, increasing the chance of unintended file access, report export, webhook delivery, or other side effects.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

The activation criteria are broad enough to match many normal agent situations, making over-invocation likely. In a skill that may summarize, cache, write files, or trigger other actions, broad triggering increases the chance of unnecessary processing of sensitive context and unexpected side effects.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

An ambiguous automatic-trigger description makes it unclear when the skill will activate or what it may do once triggered. In the presence of possible file, cache, or network behaviors, unclear automation reduces user control and can lead to unanticipated handling of sensitive context.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
85% confidence
Finding

The manifest describes a skill for clearing mental fog by checking context health, summarizing context, and restoring focus. In addition to those analysis functions, the code provides a cache-clearing command and a report export command that writes artifacts to user-specified files, which are broader operational capabilities not conveyed by the manifest description.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The cmd_clear_cache command performs a destructive state-changing operation by clearing cached data immediately, but the only user-facing message appears after the action has already happened. There is no confirmation prompt, prior warning, or explanatory comment/docstring telling users that invoking the cache command will delete stored cache contents.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
80% confidence
Finding

A skill described as helping an agent regain clarity would reasonably analyze provided context and return results, but this command exports reports to an arbitrary output path. Persistent file generation is a separate capability from context analysis and is not obviously required by the manifest's stated purpose.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code includes natural-language strings that force a specific language/locale for documentation and interaction. The stated policy flags locale constraints unless the skill offers user choice or clearly documents a justified region-specific limitation, which is not present here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The formatted report returned by this function contains Chinese-only headings and labels, making the skill's output language fixed rather than user-selectable. Under the policy, forcing a specific language without opt-in is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This code forces a specific language/locale for the skill's interface, help text, and status messages. The file does not offer any user language selection or indicate that the tool is intentionally region-specific, which can violate language/locale policy requirements.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

This REPL exposes arbitrary local file load/save operations even though the advertised skill purpose is context cleanup and summarization. In an agent-skill setting, capability drift matters: unnecessary filesystem access expands the attack surface and can enable unintended reading of sensitive local files or overwriting files if the skill is invoked with untrusted input.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The code allows arbitrary file paths in both open(filepath, 'r') and open(filepath, 'w'), giving the REPL unrestricted local file read/write capability. In the context of a 'focus/cleanup' skill, this access is unjustified and dangerous because it could expose secrets from local files or modify user data if an agent or user is tricked into using crafted paths.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
78% confidence
Finding

Natural-language strings and documentation in this file are exclusively Chinese, including the module description and user-visible warning text returned by the heartbeat hook. There is no indication that users can choose a language or that the locale restriction is documented as intentional and justified.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

When the trigger condition is met, the code automatically runs summarization and goal extraction over the full context without any explicit user notice, consent, or scoping controls. In an agent setting, context may contain sensitive user prompts, secrets, or private task history, so silently transforming and possibly surfacing that data increases privacy and data-handling risk.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This code file contains natural-language descriptions and user-facing output in a single fixed language. Under the policy, forcing a specific language without user opt-in is a locale-policy violation unless the restriction is explicitly justified or the user is given a choice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The recommendation strings and labels returned by the analysis are user-visible outputs, but they are fixed to Chinese. Because the file provides no mechanism for selecting language or documenting a justified locale constraint, this violates the language/locale policy.

Content

No source excerpt is available for this finding.

Dynamic import via __import__()

Medium
Category
Dangerous Code Execution
Confidence
75% confidence
Finding

Dynamic import() can load arbitrary modules at runtime, bypassing static analysis and potentially importing malicious code.

Content

Scanner excerpt · scripts/check_context.py (reported line 140)May include surrounding context.

python
# 记录历史
        self.history.append({
            "timestamp": __import__("time").time(),
            "score": result["score"],
            "level": result["level"],
            "token_count": result["details"]["token_count"]

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The report formatter constructs all headings, labels, and recommendation presentation in Chinese only. This is a natural-language locale restriction in the code and does not include opt-in, selection, or justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The module’s docstrings and user-facing descriptions are entirely in Chinese, indicating a fixed language/locale expectation. There is no visible opt-in, fallback, or documentation that this exporter is intentionally region-specific, which conflicts with the policy against forcing a specific language without user choice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

This code includes natural-language docstrings and user-facing output in Chinese, and later emits formatted markdown headings and labels only in Chinese. Under the policy, forcing a specific language without user opt-in is a locale-policy violation unless the restriction is explicitly documented and justified.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The module's human-readable docstrings, status messages, and notification content are written in Chinese throughout, with no indication that language is configurable or intentionally limited to a Chinese-only audience. This creates a language/locale policy concern because the skill imposes a specific language without user opt-in.

Content

No source excerpt is available for this finding.