Back to skill

Security audit

publish-knowledge-health-checker

Security checks for vulnerabilities and agentic risk

Overview

This knowledge-base checker is mostly purpose-aligned, but its repair and scheduling features can delete or rewrite files and include unsafe generated scripts that require careful review.

Install only after reviewing the repair and scheduling behavior. Back up the knowledge base first, avoid running generated auto-fix scripts without manual inspection, do not enable cron/email/Feishu delivery unless you explicitly want persistent scheduled runs, and treat generated HTML reports as potentially containing local path information.

Vulnerability Patterns
  • System PersistenceInstalls backdoors, hooks, services, or scheduled tasks that survive the run
  • 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 (4)

T06 · System Persistence

Error
Location
SKILL.md:293
Finding
Recurring Cron Task Creates Cross-Session Persistence<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:293-297` and `SKILL.md:407-411` **Vulnerability Type**: Scheduled-task persistence **Risk Level**: Critical ### Vulnerable Code Snippet ```cron 0 9 * * 0 /path/to/health_check.py ``` The Skill instructs the agent to create this recurring cron task when a user requests weekly knowledge-base checks. ### Technical Analysis The documented workflow goes beyond generating a one-time report and directs the installation of a cron entry that survives the current Skill invocation and subsequent agent sessions. This constitutes system persistence because the referenced program executes automatically every Sunday without requiring another user interaction. The cron command shown in the Skill uses a placeholder script location and does not define ownership checks, integrity validation, restrictive permissions, logging safeguards, or a removal procedure. If the referenced script or any parent directory is writable by another user or process, the scheduled task can become a persistent arbitrary-code execution mechanism. The documentation also proposes delivering output to email or Feishu, although the project does not contain an implementation of that transmission behavior. Therefore, no data-exfiltration finding is asserted. ### Attack Path 1. A user asks the Skill to perform automatic weekly checks. 2. Following `SKILL.md`, the agent installs a cron entry referencing `health_check.py`. 3. The cron entry remains active after the current Skill run and agent session end. 4. The referenced script executes automatically every Sunday. 5. If an attacker later replaces the script or compromises a writable directory in its path, attacker-controlled code executes under the account that owns the cron entry. ### Impact Assessment The scheduled process runs with the privileges of the user whose crontab was modified. An attacker able to replace the referenced script could repeatedly access, modify, or delete ever ...[truncated 105 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Do not install a cron entry automatically as part of the normal Skill workflow. - Generate a disabled example and require explicit, informed confirmation immediately before installation. - Display the exact schedule, executable path, output destination, and removal command. - Resolve and validate an absolute script path rather than using a placeholder or relative path. - Require the script and all parent directories to be owned by the intended user and not writable by untrusted principals. - Consider copying a reviewed script to a dedicated, permission-restricted location before scheduling it. - Use a minimal execution environment, explicit `PATH`, restrictive `umask`, execution timeouts, and controlled log permissions. - Provide a command that reliably removes the scheduled task. - Require separate consent before configuring email, Feishu, or any other external delivery destination. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
scripts/auto_fix.py:78
Finding
Shell Command Injection in Generated Bash Repair Script<![CDATA[ ## Vulnerability Details **File Location**: `scripts/auto_fix.py:78-100` **Vulnerability Type**: Shell command injection through unsafe code generation **Risk Level**: High ### Vulnerable Code Snippet ```python for item in results['broken_links']: target = item['target'] source = item['source'] quoted_source = quote_path(source) quoted_target = quote_path(target) similar = find_similar_filename(target, existing_files) if similar: quoted_similar = quote_path(similar) script_lines.append(f'sed -i \'\' \'s/\\[\\[{target}\\]\\]/[[{similar}]]/g\' {quoted_source}') fix_count += 1 ``` ### Technical Analysis Although `source` is escaped with `shlex.quote()`, the `target` and `similar` values are interpolated directly into a single-quoted `sed` expression. The calculated `quoted_target` and `quoted_similar` variables are not used in the generated command. A single quote in either value can terminate the shell's quoted `sed` argument. Newline characters can also introduce additional commands into the generated script. Consequently, a crafted wiki-link target or manipulated results JSON can alter the generated Bash program. The resulting file is written to disk and assigned executable permissions at `scripts/auto_fix.py:137-142`, increasing the likelihood that a user will execute the injected content. The Skill documentation explicitly encourages users to review and then run generated repair scripts. ### Attack Path 1. An attacker places a crafted wiki link in a Markdown file scanned by `health_check.py`, or supplies a manipulated results JSON file. 2. The crafted target contains shell-sensitive characters such as a single quote followed by command syntax. 3. `auto_fix.py` inserts the value directly into the single-quoted `sed` program. 4. The generator writes the malicious Bash script and marks it executable. 5. The user executes the generated repair script as recommended by the Skill. 6. The injected c ...[truncated 446 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Avoid generating shell commands from scanned content. Perform replacements directly in Python using file APIs. - If Bash generation is mandatory, pass untrusted values as positional arguments to a fixed helper rather than interpolating them into shell source. - Treat shell escaping and `sed` escaping as separate contexts; `shlex.quote()` alone does not safely encode a value embedded inside a `sed` expression. - Reject targets containing control characters, including carriage returns, line feeds, and null bytes. - Generate scripts without executable permissions by default. - Require an explicit opt-in before changing permissions or executing a generated script. - Add tests using single quotes, double quotes, backslashes, newlines, semicolons, command substitutions, glob characters, and delimiter characters. - Prefer backups or transactional modifications before changing knowledge-base files. ]]>

T09 · Insecure Skill Coding Practices

Error
Location
scripts/auto_fix.py:174
Finding
Python Source Injection Through Unsafely Embedded Knowledge-Base Path<![CDATA[ ## Vulnerability Details **File Location**: `scripts/auto_fix.py:174-186` **Vulnerability Type**: Generated Python code injection **Risk Level**: High ### Vulnerable Code Snippet ```python script_content = f'''#!/usr/bin/env python3 """ Knowledge-base automatic repair script """ import os import shutil from pathlib import Path KNOWLEDGE_BASE = "{results["scan_path"]}" BACKUP_DIR = "backup_" + Path(KNOWLEDGE_BASE).name ``` ### Technical Analysis The `scan_path` value is interpolated directly into a double-quoted Python string literal in generated source code. It is not serialized as a Python literal and is not validated for quotes, backslashes, or newline characters. A malicious path can terminate the `KNOWLEDGE_BASE` string and append executable Python statements. This path can originate from an attacker-controlled results JSON file or from a deliberately crafted filesystem path used during scanning. The vulnerability is distinct from shell injection: the generated payload is interpreted by the Python parser when the repair script is subsequently executed. ### Attack Path 1. An attacker supplies a results JSON document with a crafted `scan_path`, or causes a scan to operate on a directory with a specially constructed name. 2. `generate_python_fix_script()` inserts the path directly into generated Python source. 3. The crafted path closes the string literal and introduces Python statements. 4. The user executes the generated Python repair script. 5. The injected statements run before or during the normal repair workflow. ### Impact Assessment The injected Python code executes with the privileges of the user launching the repair script. It can read, modify, copy, or delete any data available to that user, not merely files below the intended knowledge-base path. It can also invoke local processes or create additional persistence. No independent privilege-escalation mechanism is present. ]]>
Remediation
<![CDATA[ ## Remediation Suggestions - Do not embed runtime data directly in generated Python source. - Store the repair plan in a separate JSON file and have a fixed, reviewed Python program load it at runtime. - If embedding is unavoidable, serialize the value with `repr()` or `json.dumps()` rather than surrounding it manually with quotation marks. - Canonicalize and validate the path before use. - Reject null bytes and control characters. - Ensure resolved repair targets remain beneath the approved knowledge-base root. - Generate scripts without executable permissions by default and require explicit review. - Add tests for paths containing quotes, backslashes, Unicode characters, newlines, and Python syntax. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/report_generator.py:272
Finding
HTML Injection Through Unescaped Scan Path<![CDATA[ ## Vulnerability Details **File Location**: `scripts/report_generator.py:272-275` **Vulnerability Type**: HTML and script injection **Risk Level**: Medium ### Vulnerable Code Snippet ```python <div class="header"> <h1>Knowledge-Base Health Report</h1> <div class="path">{results['scan_path']}</div> </div> ``` ### Technical Analysis The scan path is inserted directly into the generated HTML document without calling the existing `escape_html()` helper. Other attacker-influenced fields in `generate_issues_html()` are escaped, but this field is not. If `scan_path` contains HTML markup, it can terminate the `div` content and inject arbitrary elements. A payload containing a script-capable element or event handler can execute JavaScript when the generated local report is opened. The report includes no restrictive Content Security Policy to limit inline script execution. The vulnerability can be reached through a crafted results JSON file or, depending on filesystem support, through a malicious directory name. ### Attack Path 1. An attacker controls a results JSON file or the name of a scanned directory. 2. The `scan_path` value contains malicious HTML. 3. `generate_report()` inserts the value into the report without contextual escaping. 4. The report is written to an HTML file. 5. The user opens the generated report in a browser. 6. The injected markup alters the report or executes JavaScript in the local-file context. ### Impact Assessment Exploitation can falsify report content, mislead the user, trigger navigation, or run browser-side JavaScript. Browser protections generally constrain local-file pages, but exact access depends on the browser and launch configuration. The project does not load remote scripts or implement direct data transmission, so external exfiltration is not asserted without an additional attacker-controlled channel. ]]>
Remediation
<![CDATA[ ## Remediation Suggestions - Escape the value before interpolation: ```python escaped_scan_path = escape_html(results['scan_path']) ``` - Insert only `escaped_scan_path` into the HTML template. - Apply context-appropriate escaping to every dynamic field, including numeric fields if result files are not trusted. - Add a restrictive Content Security Policy that disallows external resources and unauthorized inline execution. - Consider using a template engine with automatic HTML escaping enabled. - Validate result JSON against a strict schema before rendering. - Add regression tests with element-closing tags, event handlers, quotes, ampersands, and script-capable markup. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
Findings (25)

Tp4

High
Category
MCP Tool Poisoning
Confidence
88% confidence
Finding
The core purpose is mostly aligned: the script is indeed a knowledge-base health checker that scans Markdown notes, detects empty/low-quality files, broken wiki links, content density issues, and graph/network properties. However, the declared description materially overstates several capabilities not present in the code. There is no implementation for Notion-specific or Logseq-specific parsing/import; the scan is limited to local .md files. There is also no visual report/card generation—results are returned as JSON. Finally, the description promises automatic repair suggestions, but the code only reports findings and scores without producing fixes or recommendations. No obvious unrelated or dangerous undeclared behavior is present; the mismatch is due to overstated features in the description.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
# 知识库自动修复脚本(需人工审查后执行)

# 1. 删除空壳文件
rm "memory/drafts/待研究.md"
rm "memory/temp/quick-note.md"

# 2. 修复断链(搜索相似文件名)
Confidence
96% confidence
Finding
The skill includes generated shell commands using rm to delete files classified as 'empty shell' notes. This is dangerous because heuristic classification can be wrong, paths may be broader than intended, and users may execute the script with little scrutiny, causing irreversible data loss in a personal knowledge base.

Tool Parameter Abuse

High
Category
Tool Misuse
Content
# 1. 删除空壳文件
rm "memory/drafts/待研究.md"
rm "memory/temp/quick-note.md"

# 2. 修复断链(搜索相似文件名)
sed -i '' 's/\[\[wave-function\]\]/[[wave-function-theory]]/g' "memory/physics/quantum-mechanics.md"
Confidence
96% confidence
Finding
This second rm example reinforces a pattern of destructive, parameterized shell output driven by analysis results. In the skill context, file paths originate from repository contents and heuristics, so mistakes or path-handling issues can translate directly into user-triggered deletion of legitimate notes.

Lp3

Medium
Category
MCP Least Privilege
Confidence
89% confidence
Finding
The skill describes capabilities that require filesystem reads, file writes, and shell/script generation, but it declares no explicit tool scope or permission boundaries. In an agent environment, missing least-privilege constraints increases the chance that the skill can be invoked with broader access than intended, especially because later sections discuss report generation, browser opening, cron setup, and fix-script creation.

Natural-Language Policy Violations

Medium
Confidence
81% confidence
Finding
The manifest description and the entire user-facing documentation are written in Chinese, with no indication that the skill can operate in other languages or adapt to user preference. Under the policy, forcing a specific language without opt-in is a natural-language policy violation unless the locale constraint is clearly documented and justified.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The skill prominently promotes automatic repair and later provides destructive deletion examples, but it lacks a strong upfront warning about data-loss risk. Users may treat generated fixes as routine maintenance and execute removal commands on notes that are merely short, placeholder, or misclassified.

Context-Inappropriate Capability

Medium
Confidence
84% confidence
Finding
Optional HTTP checking of external links introduces network access to third-party servers, which goes beyond strictly local document analysis. This can leak browsing patterns, internal document references, or sensitive URLs embedded in the knowledge base, and may contact attacker-controlled endpoints during analysis.

Context-Inappropriate Capability

Medium
Confidence
95% confidence
Finding
The skill expands from local knowledge-base analysis into cron persistence and outbound delivery to Feishu/email, which materially broadens its operational scope. That introduces risks of unauthorized persistence, data exfiltration of scan results, and execution beyond the user's immediate session, none of which are necessary for a basic health checker.

Natural-Language Policy Violations

Medium
Confidence
94% confidence
Finding
This markdown file contains user-facing natural-language content entirely in Chinese, including headings and evaluation notes, with no indication that users may choose another language. The policy for this category requires flagging language or locale constraints unless the skill explicitly offers opt-in or documents a justified regional limitation.

Natural-Language Policy Violations

Medium
Confidence
93% confidence
Finding
The file presents all user-facing natural-language content in Chinese, including headings, descriptions, and release instructions. Under the policy rule, forcing a specific language without user opt-in is a natural-language policy violation unless the locale restriction is explicitly documented and justified.

Natural-Language Policy Violations

Medium
Confidence
94% confidence
Finding
This code file contains natural-language docstrings and runtime messages entirely in Chinese, starting with the module description and continuing through generated script comments and CLI output. Under the policy rule for language/locale, this is a violation because the skill imposes a specific language without any opt-in, fallback, or documented region-specific justification.

Description-Behavior Mismatch

Medium
Confidence
90% confidence
Finding
The script generates executable shell code that can delete files and rewrite content based entirely on scan results. Even though it warns the user to review first and uses shell escaping for file paths, this still turns analyzer output into actionable destructive operations, which is risky if the input data is wrong, manipulated, or over-broad.

Natural-Language Policy Violations

Medium
Confidence
92% confidence
Finding
The document declares `lang="zh-CN"`, and the visible UI text throughout the page is exclusively in Chinese. Under the policy rule, forcing a specific language or locale without user opt-in or a documented justification is a natural-language policy violation.

Context-Inappropriate Capability

Medium
Confidence
95% confidence
Finding
The report embeds a specific local filesystem path (/Users/mac/.openclaw/workspace/memory) directly in page content, which leaks host-specific environmental information to anyone who can view or receive the report. This is unnecessary for a health summary and can aid reconnaissance by revealing usernames, directory structure, workspace naming, and probable operating system details.

Ssd 3

Medium
Confidence
97% confidence
Finding
The plain-text disclosure of a user-specific local path exposes sensitive contextual metadata in a generated artifact that may be shared externally. In this skill context, reports are intended for diagnostics and export, so leaking workstation paths is more dangerous because the artifact is likely to leave the local environment and provide useful reconnaissance data to third parties.

Natural-Language Policy Violations

Medium
Confidence
91% confidence
Finding
This Python file contains user-facing natural-language documentation and status messages exclusively in Chinese, starting with the module docstring and continuing throughout the script. Under the language/locale policy, forcing a specific language without user opt-in is a violation unless the locale restriction is explicitly justified or a choice is offered.

Intent-Code Divergence

Medium
Confidence
97% confidence
Finding
The file defines an HTML escaping helper and uses it in generate_issues_html, but the main HTML template still interpolates unescaped data such as results['scan_path'] and multiple score/stat fields directly into the document. If any of these values can be influenced by untrusted input, an attacker could inject HTML or script into the generated report, which would execute when the report is opened in a browser.

Vague Triggers

Medium
Confidence
94% confidence
Finding
The trigger phrase asks to 'check my knowledge base health' without any scope, path, repository, or confirmation constraints, and the expected behavior says to scan a default path and generate a report. In an agent skill, this can cause unintended activation during normal conversation and may lead to broad local content enumeration or analysis of files the user did not explicitly select.

Vague Triggers

Medium
Confidence
92% confidence
Finding
The 'deep analysis' trigger is broad and the expected workflow includes network-structure analysis, connected components, and weak-link reporting, which implies extensive traversal and metadata extraction across the knowledge base. Without explicit constraints, exclusions, or consent for depth and scope, this increases the risk of over-collection, accidental activation, and costly or privacy-invasive analysis.

Missing User Warnings

Low
Confidence
89% confidence
Finding
The documentation mentions external HTTP link validation but does not clearly warn that this may contact third-party servers and reveal metadata. While lower severity than direct destructive actions, the omission can cause users to unknowingly expose internal link targets or analysis timing to external services.

Natural-Language Policy Violations

Low
Confidence
85% confidence
Finding
The markdown file is entirely written in Chinese, including the title and section headings, with no indication that the skill supports other languages or that Chinese is required for a specific regional purpose. This can violate a language/locale policy when a skill implicitly mandates one language without user opt-in.

Description-Behavior Mismatch

Low
Confidence
88% confidence
Finding
The docstring and function name describe a stronger Python auto-fix script, but the emitted script only backs up, prints candidate deletions, and explicitly leaves broken-link repair as TODO. This creates a mismatch between the claimed automatic repair behavior and what the generated script actually does.

Intent-Code Divergence

Low
Confidence
86% confidence
Finding
The inline documentation claims this Python variant is '更强大', yet its emitted logic comments out deletion and leaves broken-link repair unimplemented, while the shell script performs actual `rm` and `sed` operations. This is an active contradiction between documentation and behavior rather than a mere omission.

Natural-Language Policy Violations

Low
Confidence
88% confidence
Finding
The module docstring and all user-facing strings are written exclusively in Chinese, and the generated HTML explicitly sets `lang="zh-CN"`. This indicates a fixed language/locale choice without any opt-in or explanation that the skill is intended only for a Chinese-language context.

Vague Triggers

Low
Confidence
83% confidence
Finding
The prompt about having many 'empty shell files' is conversational and can overlap with ordinary discussion of note quality, making accidental routing to the skill more likely. While narrower than a full health scan, it still authorizes file inspection behavior without clear boundaries on which knowledge base or directory is in scope.

Static analysis

No suspicious patterns detected.