Back to skill

Security audit

Lobster Doctor

Security checks for vulnerabilities and agentic risk

Overview

This skill is a workspace maintenance tool, but some commands can broadly move files and rewrite installed skill metadata with weaker controls than the documentation promises.

Review before installing. Use only read-only/report modes first, avoid running cleanup without --dry-run, and do not run skill-slim apply unless you intentionally want this tool to rewrite other installed skills. Treat generated reports as potentially sensitive because they can include session identifiers, agent names, skill inventory, cron details, and messaging-channel targets.

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)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/lobster_doctor.py:829
Finding

Cleanup Performs Destructive Workspace Changes Without Mandatory Preview or Confirmation

Content
View full analysis

Vulnerability Details

File Location: scripts/lobster_doctor.py:829-971
Vulnerability Type: Unsafe destructive file operations without confirmation
Risk Level: Medium

Evidence

python
def cmd_cleanup(dry_run=False):
    if dry_run:
        print(f"🦞 龙虾医生 — 模拟清理 ({datetime.now().strftime('%Y-%m-%d %H:%M')})\n")
    else:
        print(f"🦞 龙虾医生 — 自动清理 ({datetime.now().strftime('%Y-%m-%d %H:%M')})\n")

    today = datetime.now().strftime('%Y-%m-%d')
    backup = BACKUP_DIR / today
    if not dry_run:
        backup.mkdir(parents=True, exist_ok=True)

    # Clean stale scripts from the workspace root.
    stale_extensions = {'.py', '.js', '.html', '.txt', '.log', '.json'}
    for f in list(WORKSPACE.iterdir()):
        if not f.is_file() or f.name in CORE_FILES:
            continue
        if f.name.startswith('.'):
            continue
        if f.suffix in stale_extensions and file_age_days(f) > STALE_DAYS_PY_JS_HTML:
            if dry_run:
                print(f"  🗑️ [模拟] {f.relative_to(WORKSPACE)}")
            else:
                f.rename(backup / f.name)

    # Remove empty directories.
    for d in list(WORKSPACE.rglob('*')):
        if not d.is_dir() or d == WORKSPACE:
            continue
        if any(part in PROTECTED_DIRS for part in d.parts):
            continue
        try:
            if not any(d.iterdir()):
                if not dry_run:
                    d.rmdir()
        except (OSError, PermissionError):
            pass

    # Archive old memory logs.
    memory_dir = WORKSPACE / "memory"
    if memory_dir.exists():
        cutoff = datetime.now() - timedelta(days=MEMORY_LOG_MAX_DAYS)
        for f in memory_dir.glob('*.md'):
            if f.name == 'README.md' or f.name == 'heartbeat-state.json':
                continue
            try:
                mtime = datetime.fromtimestamp(f.stat().st_mtime)
       
...[truncated 3665 chars]
Remediation
View remediation

Remediation Suggestions

  1. Make preview mode the default:

    • Run cleanup as a dry run unless an explicit --apply flag is present.
    • Do not treat the absence of --dry-run as authorization for mutation.
  2. Require informed confirmation:

    • Produce an exact manifest containing every source path, destination path, selection reason, size, and operation.
    • Require interactive confirmation or a separately issued apply command.
    • Consider binding approval to a hash of the preview manifest so the applied set cannot differ from the reviewed set.
  3. Protect memory consistently:

    • Remove memory processing from generic cleanup.
    • Require the dedicated memory-archive --apply command for memory changes.
    • Preserve files marked as important and expose retention thresholds as explicit configuration.
  4. Replace broad age-based classification:

    • Use an allowlist of known temporary directories and filename patterns.
    • Never classify arbitrary .py, .js, .json, or .md files as disposable solely because of modification time.
    • Require per-file approval for files outside dedicated cache or temporary directories.
  5. Improve recovery:

    • Use collision-resistant, path-preserving backup destinations.
    • Write a machine-readable restoration manifest.
    • Implement an atomic rollback command and verify backups before moving source files.
  6. Add regression tests proving that protected files, memory files, intentionally duplicated paths, and unapproved files remain unchanged.

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/skill_slim.py:318
Finding

Skill Slimming Rewrites Unrelated User-Wide and Package-Managed Skills

Content
View full analysis

Vulnerability Details

File Location: scripts/skill_slim.py:17-23, 318-365
Vulnerability Type: Excessive filesystem scope and unsafe modification of third-party Skill metadata
Risk Level: Medium

Evidence

The scan includes system-installed, user-wide, and workspace-local Skill directories:

python
WORKSPACE = Path.home() / ".openclaw" / "workspace"

SKILL_DIRS = [
    Path.home() / ".npm-global" / "lib" / "node_modules" / "openclaw" / "skills",
    Path.home() / ".openclaw" / "skills",
    WORKSPACE / "skills",
]

CORE_SKILLS = {
    "lobster-doctor",
}

The apply operation writes modified metadata back to every qualifying discovered Skill except the single protected Skill:

python
def cmd_apply(skills):
    """应用精简"""
    print("🦞 龙虾医生 — 技能瘦身执行中...\n")

    modified = 0
    backup_dir = WORKSPACE / ".cleanup-backup" / "skill-slim"

    for name, info in sorted(skills.items()):
        if name in CORE_SKILLS:
            continue

        slim = clean_description(info['raw_desc'])
        content = info['content']

        raw_clean = info['raw_desc'].strip().strip('"\'')
        raw_clean = re.sub(r'^\s*>\s*', '', raw_clean, flags=re.MULTILINE).strip()
        raw_clean = re.sub(r'\s+', ' ', raw_clean)

        if len(raw_clean) <= len(slim):
            continue

        backup_dir.mkdir(parents=True, exist_ok=True)
        backup_path = backup_dir / f"{name}_SKILL.md"
        if not backup_path.exists():
            with open(backup_path, 'w', encoding='utf-8') as f:
                f.write(content)

        old_fm_match = re.match(r'^---\s*\n(.*?)\n---', content, re.DOTALL)
        if not old_fm_match:
            continue

        old_fm = old_fm_match.group(1)
        new_fm = re.sub(
            r'^description:.*$',
            f'description: {slim}',
            old_fm,
            flags=re.MULTILINE
        )

        new_c
...[truncated 3279 chars]
Remediation
View remediation

Remediation Suggestions

  1. Enforce least privilege:

    • Restrict write operations to WORKSPACE / "skills" by default.
    • Treat package-managed and shared user-level Skills as read-only.
    • Require separate, explicit scope flags for any non-workspace directory.
  2. Require granular authorization:

    • Display each proposed Skill modification and its exact diff.
    • Require explicit per-Skill approval or an allowlist supplied by the user.
    • Do not infer consent to rewrite all installed Skills from a general slimming request.
  3. Preserve security and routing semantics:

    • Parse frontmatter with a YAML parser rather than regular expressions.
    • Preserve activation conditions, exclusion clauses, safety restrictions, and capability boundaries.
    • Reject changes when required semantic fields cannot be identified reliably.
  4. Use safe write procedures:

    • Write to a temporary file in the same directory.
    • Validate syntax and content before atomically replacing the original.
    • Preserve permissions and ownership metadata.
  5. Improve backups:

    • Preserve the original directory hierarchy in the backup.
    • Include a timestamp or content hash in every backup filename.
    • Create a new backup for every modification instead of reusing the first backup indefinitely.
    • Provide a tested restoration command.
  6. Add tests covering package-managed Skills, shared Skills, multiline YAML descriptions, quoted values, routing exclusions, repeated applications, and restoration.

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

Vague Triggers

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

The skill metadata and description use very broad, conversational trigger language for a maintenance skill that can perform impactful actions like cleanup and skill modification. This increases the chance of accidental invocation from ordinary user speech, potentially leading the agent to initiate destructive or privacy-affecting maintenance workflows without clear user intent.

Content

No source excerpt is available for this finding.

Vague Triggers

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The README advertises generic phrases like '做个体检' and '清理一下' as sufficient to activate file-scanning and cleanup behaviors. Because these phrases overlap with normal conversation, an agent may route unrelated user requests into this skill, causing unintended workspace inspection or cleanup proposals in a sensitive maintenance context.

Content

No source excerpt is available for this finding.

Vague Triggers

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The usage section explicitly states the skill will 'automatically understand and execute' direct natural-language requests, reinforcing unconstrained activation for operations that inspect files, analyze skills, and perform cleanup. In the context of a workspace-maintenance skill, that ambiguity makes accidental execution more dangerous than in a read-only or narrowly scoped tool.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

This finding indicates an even stronger description-behavior mismatch: the skill is presented as a workspace doctor but apparently benchmarks skill routing, scans local skill directories, and runs evaluation logic unrelated to the advertised end-user maintenance tasks. Such hidden or unrelated behavior increases the risk of unauthorized data exposure and deceptive operation because users would not reasonably expect broad metadata scanning or benchmarking from the published description.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

This finding indicates an even stronger description-behavior mismatch: the skill is presented as a workspace doctor but apparently benchmarks skill routing, scans local skill directories, and runs evaluation logic unrelated to the advertised end-user maintenance tasks. Such hidden or unrelated behavior increases the risk of unauthorized data exposure and deceptive operation because users would not reasonably expect broad metadata scanning or benchmarking from the published description.

Content

No source excerpt is available for this finding.

Vague Triggers

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The trigger phrases are common conversational Chinese utterances such as asking to clean up or check health, which are likely to appear in ordinary dialogue. Overly broad activation increases the chance the skill runs unintentionally and performs workspace-modifying actions like cleanup, backup creation, or metadata rewriting without the user deliberately invoking the skill.

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/lobster_doctor.py (reported line 40)May include surrounding context.

python
"AGENTS.md", "SOUL.md", "USER.md", "MEMORY.md", "TOOLS.md",
    "HEARTBEAT.md", "IDENTITY.md", "PROGRESS.md", "INTEL-DIRECTIVE.md",
    "BOOTSTRAP.md", "KB-SYNC-GUIDE.md", "package.json", "package-lock.json",
    ".env", ".openclaw", ".git", ".gitignore",
    ".model_override", ".openclaw-model-override",
}

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

The skill documentation is entirely in Chinese and presents all invocation guidance in that language, with no indication that users may choose another language or that the locale restriction is intentional. This can be a language-policy issue when a skill effectively requires one language without opt-in or documented justification.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
86% confidence
Finding

The skill advertises actions like cleanup, backup creation, and skill slimming, which imply file reads, file writes, and possibly shell execution, yet it declares no explicit tool scope or permission boundaries. That makes the operational authority ambiguous and can lead to over-broad execution if the platform grants default access, especially for a skill that modifies workspace content.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The statement that the skill works when the user simply ‘says a phrase’ makes activation scope ambiguous and suggests low-friction invocation for potentially sensitive operations. In the context of a workspace-management skill, ambiguity is more dangerous because accidental activation could lead to file inspection or modification across the workspace.

Content

No source excerpt is available for this finding.

Vague Triggers

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The description claims very broad capabilities and effortless activation ('说句话就能用' / 'just say a sentence and it works'), which can overstate what the skill will do and encourage users to invoke powerful maintenance actions without understanding scope or safeguards. In a workspace health/cleanup skill, this is more dangerous because the advertised actions include cleanup, skill slimming, memory archiving, and cron inspection, all of which can affect data, configuration, or automation state.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The description is written partly in Chinese and implicitly targets a specific language experience without clear user opt-in. This can create consent and comprehension issues if users do not understand the wording, especially for a skill that performs workspace maintenance actions; misunderstanding prompts or capability descriptions can lead to unintended invocation or trust in actions the user did not fully comprehend.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
97% confidence
Finding

The file's user-facing description and command help text are written in Chinese, and subsequent output strings throughout the script also assume Chinese-language interaction. This imposes a specific language/locale without any opt-in or documented justification, which matches the language-policy violation criteria.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The skill enumerates and analyzes all agent session history files under ~/.openclaw/agents, which is outside the declared workspace-health scope and may expose metadata about other agents and conversations. Even though it only reads size, turns, IDs, and timestamps, this broad cross-session inspection expands data access beyond least privilege and can reveal sensitive operational information.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
87% confidence
Finding

The weekly-report feature reads OpenClaw channel configuration and extracts enabled push-channel details such as Feishu targets. This extends the skill from local maintenance into discovery of external communication configuration, which can disclose messaging topology and potential destinations for later exfiltration or misuse.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
84% confidence
Finding

The notification helper imports subprocess-capable plumbing for outbound messaging despite not being necessary for core workspace cleanup. Even though the current function returns False and does not execute a command, this adds an unnecessary execution pathway adjacent to external messaging logic, increasing the attack surface and making future unsafe command construction more likely.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The weekly report persists workspace and session summaries to disk and echoes them to the terminal without any privacy warning or consent flow. Those summaries include session IDs, agent names, token volumes, skill inventory, and channel-related hints, which can leak sensitive operational context to local observers or future tools that index the report files.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The module docstring states '中文技能描述尽量用中文', which sets a language preference in natural-language instructions. This is a locale/language policy concern because it directs skill content toward a specific language without indicating user choice or opt-in.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

This Python file contains user-facing natural-language text entirely in Chinese, including the module description and later console output/test cases, but does not indicate that Chinese is optional or that the tool is intentionally region-specific. Under the policy, forcing a specific language without user opt-in is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The comment and report text describe detection of '高占用低使用' skills, but the implementation sets calls to 0 with an inline note that direct call counts cannot be obtained. This means the code is not actually measuring low usage and the documentation/report framing overstates what the analysis proves.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The module docstring and usage text describe this tool as focused on token analysis and one-click description slimming of SKILL.md content. However, the duplicates command implements a separate capability for detecting overlapping skills and recommending disabling one, which goes beyond description slimming as stated.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.