Back to skill

Security audit

Skill for OpenClaw: Converts classical Chinese to vernacular Chinese, supporting multiple e-book formats for full-text conversion.

Security checks for vulnerabilities and agentic risk

Overview

The skill matches its stated translation purpose, but it needs review because its XML/EPUB parser can expose local files from malicious documents while the docs overstate its safety.

Review before installing. Use it only on trusted EPUB/XHTML files or in a sandbox without sensitive local files, because a crafted document may cause local file contents to appear in the generated output. Also expect limited translation quality unless the implementation is completed, and prefer pinned dependencies before production use.

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

Error
Location
scripts/translator.py:133
Finding
XML External Entity Resolution in Untrusted XHTML and EPUB Documents## Vulnerability Details **File Location**: `scripts/translator.py:133-134` and `scripts/translator.py:176-177` **Duplicate Location**: `classical-chinese-translator/scripts/translator.py:133-134` and `classical-chinese-translator/scripts/translator.py:176-177` **Vulnerability Type**: XML External Entity exposure through insufficiently hardened XML parsing **Risk Level**: High **Vulnerable code in XHTML processing:** ```python # Parse XML safely parser = etree.XMLParser(recover=True, encoding='utf-8') root = etree.fromstring(content.encode('utf-8'), parser) ``` **Vulnerable code in EPUB document processing:** ```python # Parse and translate XHTML content content = item.get_content().decode('utf-8') parser = etree.XMLParser(recover=True, encoding='utf-8') root = etree.fromstring(content.encode('utf-8'), parser) ``` ### Technical Analysis The Skill parses attacker-controlled XHTML and EPUB document content with `lxml.etree.XMLParser` without explicitly disabling DTD loading and external entity resolution. The parser is created without security controls such as `resolve_entities=False`, `load_dtd=False`, and `no_network=True`. In affected lxml/libxml2 configurations, a malicious document can include a `DOCTYPE` declaration defining an external entity that points to a locally readable file. If the entity is resolved during parsing, its contents become part of the parsed XML tree. The application subsequently processes paragraph content through `itertext()`: ```python original_text = ''.join(p_elem.itertext()) ``` It then places that text into a newly generated paragraph and serializes the document to the selected output file. Consequently, resolved local-file content can be persisted in the translated output. The use of `recover=True` further weakens strict input validation because malformed XML is repaired where possible instead of being rejected. This can make it more difficult to enforce assumptions a ...[truncated 1867 chars]
Remediation
## Remediation Suggestions 1. Create a hardened parser that explicitly disables external entities, DTD loading, and network access: ```python parser = etree.XMLParser( encoding='utf-8', resolve_entities=False, load_dtd=False, no_network=True, recover=False ) ``` 2. Apply the hardened parser consistently to direct XHTML processing and every document item extracted from an EPUB. 3. Reject documents containing `DOCTYPE` or entity declarations before parsing when these features are not required: ```python if b'<!DOCTYPE' in raw_content.upper() or b'<!ENTITY' in raw_content.upper(): raise ValueError("DTD and entity declarations are not permitted") ``` 4. Use strict parsing with `recover=False`. Report malformed input to the user instead of silently repairing and processing it. 5. Consider using `defusedxml` or an equivalent hardened XML-processing layer where compatible with the document workflow. 6. Add regression tests containing: - An external entity referencing a local file. - Parameter entities and nested entity declarations. - Network-based external entities. - Malformed XML that previously succeeded through recovery mode. - Malicious XHTML embedded inside an EPUB. 7. Ensure tests verify that no referenced content appears in the parsed tree or generated output and that prohibited declarations cause processing to fail safely.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (27)

Ae3

High
Category
analysis-evasion
Confidence
90% confidence
Finding
Text artifact contains embedded NUL bytes

Ae3

High
Category
analysis-evasion
Confidence
90% confidence
Finding
Text artifact contains embedded NUL bytes

Ae3

High
Category
analysis-evasion
Confidence
90% confidence
Finding
Text artifact contains embedded NUL bytes

Ae4

Medium
Category
analysis-evasion
Confidence
80% confidence
Finding
Suspicious Unicode normalization or mixed-script content

Ae4

Medium
Category
analysis-evasion
Confidence
80% confidence
Finding
Suspicious Unicode normalization or mixed-script content

Ae4

Medium
Category
analysis-evasion
Confidence
80% confidence
Finding
Suspicious Unicode normalization or mixed-script content

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
The README states the skill provides translation from Classical Chinese to modern vernacular Chinese, which imposes a specific output language/locale behavior. Under the policy, forcing a specific language is a violation unless the user is given a language choice or the locale restriction is clearly justified as region-specific.

Natural-Language Policy Violations

Medium
Confidence
96% confidence
Finding
The overview states the skill translates Classical Chinese texts specifically into modern vernacular Chinese, which is a language-choice constraint expressed in natural language. Because the document does not present this as an opt-in or configurable language preference, it can violate a policy requiring user language choice.

Natural-Language Policy Violations

Medium
Confidence
92% confidence
Finding
The README states the skill provides translation from Classical Chinese to modern vernacular Chinese as a fixed behavior. This is a language-policy concern because it forces a specific output language/locale without mentioning any user-selectable alternative or opt-in.

Natural-Language Policy Violations

Medium
Confidence
90% confidence
Finding
These lines define the translation standard as complete modernization into natural modern Chinese, with no indication that users may request another target language or retain classical phrasing. That imposes a language constraint in natural-language instructions without opt-in.

Natural-Language Policy Violations

Medium
Confidence
89% confidence
Finding
The document states the translation must use 'natural modern Chinese' and completely avoid classical syntax, which imposes a fixed language/locale style. Under the policy, forcing a specific language or locale without user opt-in is a natural-language policy concern unless the constraint is explicitly optional or justified as region-specific.

Natural-Language Policy Violations

Medium
Confidence
87% confidence
Finding
The overview states the skill translates Classical Chinese texts specifically into modern vernacular Chinese, which is a language/locale constraint expressed in natural language. Because the description does not mention any user choice or opt-in for output language, it may violate the policy against forcing a specific language without user opt-in.

Session Persistence

Medium
Category
Rogue Agent
Content
echo "Building ${SKILL_NAME} v${VERSION}..."

# Create dist directory
mkdir -p ${OUTPUT_DIR}

# Create package structure
Confidence
60% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Session Persistence

Medium
Category
Rogue Agent
Content
echo "Building ${SKILL_NAME} v${VERSION}..."

# Create dist directory
mkdir -p ${OUTPUT_DIR}

# Create package structure
Confidence
60% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Natural-Language Policy Violations

Medium
Confidence
79% confidence
Finding
The package description states the skill translates Classical Chinese texts specifically to modern vernacular Chinese. This hard-codes a language/output locale preference in natural-language metadata without indicating that users can choose another target language or explicitly opt in, which can violate language-choice policy.

Intent-Code Divergence

Medium
Confidence
94% confidence
Finding
The module docstring presents the skill as a high-quality Classical Chinese translator, yet the implementation mainly appends glossary explanations and leaves key modernization logic unimplemented. In particular, `modernize_syntax` explicitly contains placeholder logic that performs no actual archaic-term replacement, and `ensure_complete_modernization` returns the input unchanged despite claims of quality assurance.

Intent-Code Divergence

Medium
Confidence
97% confidence
Finding
In `process_xhtml_file`, the docstring says the function processes an XHTML file with translation, and line L140 computes `translated_content`. However, `translated_content` is never used; instead, the function serializes `root` directly at L144. Since `_translate_xhtml_content` mutates `root`, translation may still occur, but the presence of an unused translated result directly contradicts the documented processing flow and indicates intent/code divergence in the implementation.

Natural-Language Policy Violations

Low
Confidence
72% confidence
Finding
The description states the skill translates Classical Chinese texts to modern vernacular Chinese, which imposes a specific output language. The README does not indicate any user opt-in or language-selection mechanism, so it may conflict with language/locale choice expectations.

Missing User Warnings

Low
Confidence
86% confidence
Finding
This README includes a command that creates or overwrites an output EPUB file, which is a file-write operation affecting user data. The markdown does not include any warning, note, or caution about output-file creation/overwrite behavior or where translated content will be written.

Missing User Warnings

Low
Confidence
76% confidence
Finding
The README says the skill preserves original EPUB/HTML structure while replacing content and shows commands that generate translated output files, which are user-data-affecting operations. Although backup-related options are mentioned later, the usage/overview sections do not clearly warn users that files will be rewritten or that they should preserve originals when processing valuable books.

Unpinned Dependencies

Low
Category
Supply Chain
Content
"author": "OpenClaw Assistant",
  "license": "MIT",
  "dependencies": {
    "ebooklib": "^0.17.1",
    "lxml": "^4.9.0"
  },
  "openclaw": {
Confidence
92% confidence
Finding
Using a caret version for ebooklib allows installation of newer compatible releases that have not been reviewed with this skill, creating supply-chain risk and reducing build reproducibility. If an upstream release is compromised or introduces a security regression, users of the skill could inherit the issue during dependency resolution.

Unpinned Dependencies

Low
Category
Supply Chain
Content
"license": "MIT",
  "dependencies": {
    "ebooklib": "^0.17.1",
    "lxml": "^4.9.0"
  },
  "openclaw": {
    "skillVersion": "1.0",
Confidence
96% confidence
Finding
Using a caret version for lxml permits automatic adoption of future minor/patch releases, which can expose the skill to unreviewed dependency changes. Because lxml is a parsing library often used on untrusted document content, a compromised or vulnerable upstream version could materially affect the safety of this translation skill.

Intent-Code Divergence

Low
Confidence
79% confidence
Finding
`translated_content` is assigned from `_translate_xhtml_content(root)` but never used when writing the output file. The code writes `etree.tostring(root, ...)`, so the comment/documented intent of writing the translated content does not match the concrete variable flow in the implementation.

Unpinned Dependencies

Low
Category
Supply Chain
Content
"author": "OpenClaw Assistant",
  "license": "MIT",
  "dependencies": {
    "ebooklib": "^0.17.1",
    "lxml": "^4.9.0"
  },
  "openclaw": {
Confidence
92% confidence
Finding
The dependency uses a caret range, which allows newer minor/patch versions to be installed without explicit review. This can introduce supply-chain risk or unexpected behavior if an upstream release is compromised or incompatible, though the package.json alone does not indicate active malicious behavior.

Unpinned Dependencies

Low
Category
Supply Chain
Content
"license": "MIT",
  "dependencies": {
    "ebooklib": "^0.17.1",
    "lxml": "^4.9.0"
  },
  "openclaw": {
    "skillVersion": "1.0",
Confidence
92% confidence
Finding
The lxml dependency is specified with a caret range, allowing automatic adoption of later compatible releases. In a skill that processes potentially untrusted ebook/XML content, unreviewed dependency changes can increase exposure to supply-chain compromise or parser-related regressions.

Static analysis

No suspicious patterns detected.