Back to skill

Security audit

OpenClaw Teaching

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly matches its teaching and document-generation purpose, but one script uses unsafe local import precedence that could run unintended Python code in some deployments.

Review this skill before installing in a shared or multi-skill environment. The main concern is the unsafe docx import path in generate_docs.py; install it only in an isolated environment or after removing that path manipulation. Also treat delete and restore commands as data-changing operations and keep backups of the knowledge base.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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)

T08 · Insecure Dependencies

Warning
Location
scripts/generate_docs.py:19
Finding

Python Import-Path Precedence Enables Local Dependency Hijacking

Content
View full analysis

Vulnerability Details

File Location: scripts/generate_docs.py, lines 19–22
Vulnerability Type: Local dependency hijacking through unsafe Python import-path manipulation
Risk Level: Medium

Vulnerable Code

python
# 添加父目录到路径以导入模块
sys.path.insert(0, str(Path(__file__).parent.parent.parent / 'docx' / 'scripts'))

try:
    from docx import Document

Technical Analysis

The script prepends an external sibling directory, ../../docx/scripts, to sys.path before importing docx. Index 0 gives this directory precedence over the normal Python package search locations, including the installed python-docx dependency.

Consequently, a file named docx.py or a package named docx in that sibling directory can shadow the legitimate dependency. Python executes top-level module code during import, so a malicious replacement could run arbitrary Python code as soon as the document-generation script starts.

The project documentation declares python-docx as the dependency but does not disclose or validate this alternative local module source. Exploitation requires an attacker to control or modify the sibling docx/scripts directory or influence how the project is deployed alongside another component.

Attack Path

  1. The attacker obtains write access to the sibling docx/scripts directory, or distributes a manipulated adjacent component containing that path.
  2. The attacker creates docx.py or a docx package containing malicious top-level Python code.
  3. A user or Agent invokes scripts/generate_docs.py, including for PPT generation because the import occurs at startup.
  4. The script inserts the attacker-controlled directory at the beginning of sys.path.
  5. Python resolves from docx import Document against the malicious local module before the legitimate installed package.
  6. The malicious module executes with the privileges of the invoking process.

Impact Assessment

Successful exploitation provides arbitrary Python c ...[truncated 582 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove the import-path modification:
python
sys.path.insert(0, str(Path(__file__).parent.parent.parent / 'docx' / 'scripts'))
  1. Import the installed python-docx package through Python’s standard package resolution:
python
try:
    from docx import Document
    from docx.shared import Inches, Pt, RGBColor
    from docx.enum.text import WD_ALIGN_PARAGRAPH
    from docx.enum.style import WD_STYLE_TYPE
except ImportError:
    ...
  1. Declare dependencies in a dedicated dependency manifest and pin reviewed versions, preferably with integrity hashes.

  2. Run the Skill in an isolated virtual environment so unrelated sibling directories cannot influence dependency resolution.

  3. If shared local code is genuinely required, package it under a unique project namespace rather than using the third-party package name docx.

  4. Avoid adding broad or externally writable directories to sys.path. Where unavoidable, resolve and validate the expected path, verify ownership and permissions, and reject symlinks or unexpected package contents.

  5. Add an automated test that verifies the loaded docx module originates from the approved virtual environment or package installation location.

Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (15)

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 · KNOWLEDGE_BASE.md (reported line 98)May include surrounding context.

bash
# 复制配置模板
cp .env.example .env

# 编辑配置文件
nano .env

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 · KNOWLEDGE_BASE.md (reported line 101)May include surrounding context.

cp .env.example .env

编辑配置文件

nano .env

text

#### 步骤 4: 启动服务

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The documented behavior does not align with the detected implementation: the skill claims PPT/Word export while analysis indicates only text/Markdown export and additional undeclared backup, restore, or search functionality. This mismatch is security-relevant because reviewers and users cannot accurately assess what the skill actually does, and hidden or undeclared capabilities can expand the attack surface or enable unintended file operations.

Content

No source excerpt is available for this finding.

External Transmission

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · KNOWLEDGE_BASE.md (reported line 365)May include surrounding context.

bash
# 获取技能列表
curl -X GET https://api.openclaw.io/api/skills

# 创建新技能
curl -X POST https://api.openclaw.io/api/skills \

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · KNOWLEDGE_BASE.md (reported line 365)May include surrounding context.

bash
# 获取技能列表
curl -X GET https://api.openclaw.io/api/skills

# 创建新技能
curl -X POST https://api.openclaw.io/api/skills \

External Transmission

Medium
Category
Data Exfiltration
Confidence
50% confidence
Finding

Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Content

Scanner excerpt · KNOWLEDGE_BASE.md (reported line 368)May include surrounding context.

bash
# 获取技能列表
curl -X GET https://api.openclaw.io/api/skills

# 创建新技能
curl -X POST https://api.openclaw.io/api/skills \

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The file's instructional content, headings, and usage descriptions are all presented in Chinese, which can function as a forced language choice for users. The document does not indicate that the skill is region-specific or provide an alternative language option or opt-in.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding

The skill describes capabilities that read from and write to local files, including a fixed output directory, but it does not declare any explicit tool scope or permission boundaries. Missing scope declarations make it harder to constrain or audit file access, increasing the chance of overbroad filesystem operations or abuse if the skill is invoked in a broader runtime than intended.

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 file contains natural-language strings and documentation entirely in Chinese, including the module docstring and later CLI/help text, which forces a specific language for users. Under the policy, language constraints should either be optional/opt-in or clearly justified as region-specific, neither of which is present here.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The delete_knowledge operation permanently removes matched content after creating a backup, but it provides no confirmation prompt, dry-run preview, or explicit warning before modifying the knowledge base. In a content-management skill, this increases the chance of accidental or scripted destructive changes, especially because title matching is regex-based and the CLI exposes deletion as a single-step command.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The restore_backup function overwrites the current knowledge file with the specified backup immediately after only checking that the file exists, without any confirmation or validation that the target backup is expected. This can cause silent rollback or loss of recent updates if invoked mistakenly or with an attacker-controlled path in an automated workflow.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

该知识库标题及全文内容均以中文呈现,未说明这是面向特定中文受众的区域性文档,也未提供语言选择或用户自定义语言的说明。根据语言/区域策略,未经用户选择而默认强制单一语言可能构成自然语言政策问题。

Content

No source excerpt is available for this finding.

Vague Triggers

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

This plain-text file includes a skill description and feature list, but it does not define how the skill is invoked or what phrases should or should not activate it. Without specific trigger wording or boundaries, the activation scope is ambiguous and could lead to unintended invocation in systems that infer triggers from descriptive text.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
92% confidence
Finding

The natural-language skill description and usage statement are written in Chinese, which can imply a fixed language experience without an explicit opt-in or justification. The file does not state that the skill is intended only for Chinese-speaking users or offer any language-choice guidance.

Content

No source excerpt is available for this finding.

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
90% confidence
Finding

This markdown file includes commands to generate PPT/Word files and to add new knowledge entries, which are user-data-affecting operations. The usage section does not include any warning or disclosure that these commands will create output files and may modify the knowledge base content.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.