T09 · Insecure Skill Coding Practices
- Location
scripts/lake/lake_setup.py:280- Finding
Unsafe YAML Deserialization Enables Arbitrary Code Execution
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This is a coherent Lakebook conversion skill, but it handles untrusted archives and URLs in ways that could overwrite files, execute unsafe YAML payloads, make unexpected network requests, or mutate the Python environment.
Install or run this only in a disposable, sandboxed environment and only on lakebook files you trust. Disable downloads unless you need them, avoid running it from directories containing important temp data, and prefer a reviewed fork that uses safe tar extraction, yaml.safe_load, contained filenames, URL allowlisting, size limits, and explicit dependency installation.
scripts/lake/lake_setup.py:280Unsafe YAML Deserialization Enables Arbitrary Code Execution
scripts/lake/lake_reader.py:7Lakebook Archive Path Traversal During Tar Extraction
scripts/lake/lake_handle.py:224Attachment Filename Traversal Permits Arbitrary File Writes
scripts/lake/lake_handle.py:232Unrestricted Resource Downloads Enable SSRF and Resource Exhaustion
scripts/lake/lake_setup.py:738Predictable Temporary Directory Can Cause Unrelated Data Deletion
scripts/startup.py:8Automatic Installation of Unpinned Runtime Dependencies
YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).
�量、类型分布 2. 成功转换的文档 - 列出所有成功转换的文件 3. 转换失败的文档 - 列出失败原因 4. 图片下载统计 - 成功/失败的图片 5. 附件下载统计 - 成功/失败的附件 6. 过期链接 - 无法下载的资源 7. 需要手动处理的内容 - 汇总需要人工介入的项目
pip install git+https://github.com/luhuiwang/lakebook-to-md.git
git clone https://github.com/luhuiwang/lakebook-to-md.git
cd lakebook-to-md/scripts
pip install -r requirements.txt
将本仓库克隆到 AionUi 的 skills 目录:
git clone https://github.com/luhuiwang/lakebook-to-md.git \
~/.config/AionUi/config/skills/lakebook-to-md
# 基本转换
python scripts/startup.py -l 你的导出文件.lakebook -o 输出文件夹
# 或者 pip 安装后直接使用
lak
The skill advertises behavior that reads and writes local files, downloads remote resources, and invokes a Python entrypoint, but it does not declare any explicit tool scope or permissions. This creates a trust and review gap: an operator may invoke the skill without realizing it can access the filesystem, make network requests, and execute shell/Python commands, increasing the chance of unintended data exposure or unsafe execution in permissive environments.
The skill states that it automatically downloads images and attachments, but it does not prominently warn that running the conversion will initiate outbound network requests and persist remote content from the exported document onto local disk. Because lakebook content may contain untrusted or expired signed URLs, this can cause unexpected data egress, retrieval from attacker-controlled endpoints, and storage of untrusted files in the output directory.
The parser downloads URLs embedded in the input document via requests.get(download_src), so an attacker controlling the .lakebook content can trigger arbitrary outbound HTTP requests during conversion. This is a classic SSRF-style behavior and also enables unexpected data egress, internal service probing, or retrieval of untrusted content, even though the feature is intended to fetch attachments.
This code automatically fetches attachment content from remote URLs and writes the results to local disk, but there is no confirmation prompt and no user-facing disclosure at the point of execution. The only visible handling is internal bookkeeping and error reporting, which does not warn the user that external resources will be downloaded and saved locally.
Image/resource handling also performs automatic requests.get(src) based on document-controlled src values, which expands the attack surface beyond pure file conversion. A crafted document can cause the converter to contact arbitrary remote endpoints and save attacker-chosen content locally, creating SSRF and untrusted file ingestion risks.
The function retrieves remote resources with requests.get and saves them to local paths, but it provides no user-facing disclosure before performing the network access and file write. The failure print at L300 only appears on error and does not inform the user that the skill will contact remote URLs and persist files when successful.
The code uses tarfile.extractall() on an attacker-controlled .lakebook archive without validating member paths. This is a classic path traversal issue: crafted tar entries containing absolute paths or '../' can write outside the intended extraction directory, potentially overwriting arbitrary files on the host. In a conversion skill that processes imported user files, this context makes the issue more dangerous because untrusted archives are expected input.
The code parses YAML from metadata using yaml.load(..., yaml.Loader), which can construct arbitrary Python objects from attacker-controlled YAML. Because the skill processes imported .lakebook content and explicitly treats embedded metadata as input, a malicious archive could trigger unsafe deserialization during conversion, potentially leading to code execution or other unsafe object instantiation.
meta = json_obj["meta"]
meta_obj = json.loads(meta)
book_yml = meta_obj["book"]["tocYml"]
books = yaml.load(book_yml, yaml.Loader)
for book in books:
if book.get("uuid"):
global_context.id_and_book[book["uuid"]] = book
Output size or generation rate is not bounded. Unbounded output enables denial-of-service through resource exhaustion, log flooding, or context-window stuffing.
# 自动调整列宽
for col in ws.columns:
max_length = 0
column = col[0].column_letter
for cell in col:
try:
This script writes converted Markdown, Excel, and report files to disk and also deletes the temporary directory with shutil.rmtree, but the code provides no explicit warning or confirmation about these filesystem changes beyond generic progress messages. Under SQP-2 for code files, safety-relevant file writes/deletions should have some visible disclosure when the code itself performs them.
A document-conversion startup script should not need to modify the Python environment during normal execution, yet this code installs dependencies automatically if imports fail. That behavior gives the skill unexpected package-management capability and can trigger execution of third-party installer code, making the converter more dangerous than its stated purpose suggests.
The script silently performs pip installation when imports are missing, without warning, confirmation, or meaningful audit visibility. Silent dependency installation is risky because users may unknowingly permit network access and execution of package installation hooks, which is especially inappropriate for a file-conversion utility handling untrusted content.
The script executes a subprocess to run pip and install dependencies at runtime from a local requirements.txt file. While the command is not obviously user-injection prone, invoking package installation during startup expands the skill's execution capability, can pull and execute arbitrary package install code from the Python packaging ecosystem, and creates supply-chain risk if requirements are tampered with or unpinned.
req = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "requirements.txt"
)
subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", req, "-q"])
def main():
The natural-language documentation is entirely presented in Chinese, and there is no indication that users may choose another language or that the locale restriction is intentional and justified. Under the stated policy, forcing a specific language without user opt-in can be a language/locale policy violation.
This markdown file states that the tool automatically downloads attachments and generates output files, which affects user data and performs network activity. While the behavior is described functionally, there is no clear cautionary warning that running the conversion will fetch remote resources and write them to disk unless disabled.
Dependency has known vulnerabilities (CVEs). Using packages with unpatched security flaws exposes the environment to known exploits.
Dependency has known vulnerabilities (CVEs). Using packages with unpatched security flaws exposes the environment to known exploits.
The natural-language description is written only in Chinese, which can impose a language expectation without offering users a language or locale choice. Under the policy, language-specific behavior or presentation should either be optional or clearly justified as region-specific.
PyYAML is specified with only a minimum version, so installs may resolve to versions with known security issues depending on the environment or mirror state. In a tool that converts exported content and may process untrusted data, dependency ambiguity increases supply-chain and parser-risk exposure, especially if unsafe YAML loading is used elsewhere in the project.
Requests is not pinned to a specific safe release, so deployments may pick up versions affected by published advisories. Because this skill explicitly supports automatic attachment downloads, an HTTP client dependency with uncertain patch level is more security-relevant than in an offline-only tool and could expose users to credential leakage, TLS, redirect, or request-handling flaws.
openpyxl is not pinned, leaving the installed version unverifiable against known XML-related issues. Since this skill generates Excel output from imported document content, using an unpinned spreadsheet library can increase exposure to parser or workbook-generation vulnerabilities in some environments.
The function prints user-facing messages only in Chinese ("无下载失败项" and "共 ... 个下载失败项"). This imposes a specific language on all users without any opt-in or localization mechanism, which matches the language/locale policy violation criteria.
The docstring is written only in Chinese, which imposes a language choice in user- or developer-facing natural language without offering an alternative or opt-in. Under the stated policy, locale or language constraints should be optional or clearly justified.
This returned message is hard-coded in Chinese and would be shown in output regardless of user language preference. That creates a language-policy issue because the skill forces a specific locale without explicit opt-in or justification.
No suspicious patterns detected.