T09 · Insecure Skill Coding Practices
- Location
bin/xhs-pusher.mjs:93- Finding
Arbitrary Command Execution Through Shell Command Injection
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This Xiaohongshu publishing skill is purpose-aligned but handles live account cookies and posting through unsafe scripts that could expose credentials or run unintended local commands.
Review carefully before installing. Use only a dedicated or test Xiaohongshu account, do not paste real cookies into shell commands, never commit cookie files or backups, and run the tool in an isolated workspace. The package should be fixed to use safe argument passing, strict file permissions, a .gitignore for credential files, pinned dependencies, and explicit warnings before live or scheduled posting.
bin/xhs-pusher.mjs:93Arbitrary Command Execution Through Shell Command Injection
scripts/xhs_save_cookie.sh:75Arbitrary Python Code Execution Through Source-Code Interpolation
scripts/xhs_save_cookie.sh:57Path Traversal and Out-of-Directory Cookie File Writes
scripts/xhs_save_cookie.sh:128Plaintext Session Cookies May Be Exposed Locally or Committed to Git
SKILL.md:34Unpinned and Non-Reproducible Third-Party Dependency Installation
声明描述的核心功能是“小红书内容发布技能”,重点在 cookie 管理和 xhs-kit 自动化发布。但实际代码完全没有涉及小红书、cookie、xhs-kit、内容发布流程或相关 API 调用,而是执行 Git/GitHub 代码仓库推送操作。其主要目的与声明用途实质性不一致,且访问/操作的资源从预期的小红书发布环境变成了 GitHub 远程仓库,因此应判定为明显不匹配。
Referenced artifact was not completely inspected
node ./bin/xhs-pusher.mjs --help
Referenced artifact was not completely inspected
node ./bin/xhs-pusher.mjs --help
Referenced artifact was not completely inspected
node ./bin/xhs-pusher.mjs --help
Referenced artifact was not completely inspected
node ./bin/xhs-pusher.mjs --help
YARA rule matched a known malware signature (reverse shell, backdoor, ransomware, C2 framework, or info stealer).
--switch new_account
## 生产环境建议
### 每日发布脚本
```bash
#!/bin/bash
# daily_publish.sh
DATE=$(date +%Y-%m-%d)
./xhs.sh \
--cookie cookies.json \
--title "每日更新 $DATE" \
--content "今日分享..." \
--image "/path/to/images/${DATE}.jpg" \
--tag 每日更新 \
--tag 生活记录
echo "$(date): 发布成功" >> /var/log/xhs_publish.log
# 每天10点发布
0 10 * * * cd /Users/Zhuanz/.openclaw/workspace && ./xhs.sh --cookie cookies.json --title "早安" --content "..." --image morning.jpg
# 每天20点发布
0 20 * * * cd /Users/Zhuanz/.openclaw/workspace && ./xhs.sh --cookie cookies.json --title "晚安" --content "..." --image night.jpg
--cookie 参数指定文件--switch 切换# 查看完整帮助
./xhs.sh --help
# �
The guide explicitly instructs users to push a repository for a skill centered on cookie management and automation, including the option to make the repository public, but it does not warn about the risk of accidentally committing authentication cookies, local config files, or publishing scripts containing sensitive session data. In the context of a Xiaohongshu posting skill, leaked cookies could allow account takeover or unauthorized posting, making this a real security weakness in the documentation even if no secret is directly shown in this file.
The README encourages centralized storage and routine handling of live account cookies but does not warn that these cookies are authentication secrets equivalent to account credentials. In a skill specifically built for automated posting, this omission increases the chance that users will store, share, or commit reusable session tokens insecurely, leading to account takeover or misuse if the files are exposed.
The README provides one-command publishing workflows without clearly warning that these commands act on real authenticated accounts and can create live posts, alter account state, or trigger platform enforcement. In the context of a social-media publishing skill, users may test commands against production accounts by default, causing unintended content publication or policy violations.
The skill advertises file-based cookie management and explicitly instructs users to create, copy, back up, and symlink credential files, but it does not declare any tool scope or permissions. That mismatch weakens least-privilege controls and can cause an agent to perform file reads/writes on sensitive credential material without clear user visibility or policy gating.
The documentation encourages collecting, storing, reusing, backing up, and switching authenticated cookie files for a real user account, but only gives a brief note about permissions and does not clearly warn about account takeover, session hijacking, privacy leakage, or policy/compliance risks. In this skill context, cookies are the core authentication mechanism, so normalizing long-term local storage materially increases the blast radius if files are exposed or mishandled.
The manifest describes a skill for Xiaohongshu publishing with cookie management and xhs-kit-based automation, but this file implements that by invoking arbitrary local shell scripts via child_process.execSync. Spawning shell commands and requiring users to copy executable scripts from ~/.openclaw/workspace introduces a general code-execution capability that is not explicitly justified by the stated purpose itself.
The cookie save command accepts raw session cookie material on the command line and interpolates it into a shell command. This exposes credentials to shell history and process inspection, and unsafe shell construction can let specially crafted cookie values inject additional commands.
The publish command forwards user-controlled title, content, tags, image paths, scheduling data, and cookie paths into a shell command that executes an external script. Besides undisclosed transmission of sensitive/authenticated content, this creates a strong command-injection risk if any argument contains shell metacharacters, potentially leading to arbitrary local command execution.
The quick-start repeatedly instructs users to pass cookie JSON files directly to publishing commands and even names active/backup account cookie files, but it never warns that these files are bearer authentication material equivalent to logged-in session tokens. In practice this encourages insecure handling, copying, and storage of account credentials and increases the chance of account takeover if the files are exposed through logs, backups, repos, or shared workspaces.
The cron examples schedule unattended execution of live posting commands against a real account without emphasizing that these are real account actions or advising safeguards. This can cause unintended or repeated posts, misuse on the wrong account, and persistent automated activity if a machine is shared or the schedule is forgotten.
The document instructs users to store and use live authentication cookies from JSON files for account publishing, but the safety guidance is minimal and appears much later. Cookies are effectively bearer tokens for the associated Xiaohongshu accounts, so mishandling them can enable account takeover, unauthorized posting, privacy exposure, and cross-account misuse.
The backup instructions tell users to archive all cookie files into a tar.gz without any requirement to encrypt the archive or store it in a protected location. Because the archive would contain reusable session cookies for multiple accounts, anyone who obtains the backup could restore active sessions and publish or access accounts without the original credentials.
The package description is written entirely in Chinese ("小红书内容发布技能 - 规范化cookie管理 + xhs-kit自动化发布") and provides no indication that users may choose another language or locale. Under the stated policy, hard-coding a single language without opt-in can be a natural-language policy violation.
The user-facing comments and console output are written entirely in Chinese, which effectively forces a specific language for anyone using the skill. Under the policy, locale or language constraints should either be optional for the user or clearly justified as region-specific.
The info command prints sensitive cookie fields such as access tokens, session identifiers, and other authentication values to the terminal, only truncating them rather than masking them. Terminal output is often captured in scrollback, recordings, logs, screenshots, or shared shells, so exposing even partial token values materially increases credential leakage risk in a publishing automation workflow.
The script copies the active cookie file into a default working file (cookies.json), duplicating live authentication material in a predictable location. This increases the chance of accidental disclosure through other tools, commits, backups, or weaker filesystem permissions, especially because these cookies appear sufficient to act as a logged-in XiaoHongShu session.
The script persists live authentication cookies to disk as JSON files and even creates an active symlink, but it does not warn the user that these are bearer credentials equivalent to account access. In this skill context, the cookies are specifically for automating Xiaohongshu publishing, so compromise of these files could allow unauthorized posting, account takeover actions within the session scope, or reuse of authenticated state by other local users/processes.
The script converts and writes authentication cookies into a fixed local file name (cookies.json) without prompting before overwrite, setting restrictive permissions, or warning that sensitive credentials are being materialized on disk. In this skill’s context, those cookies are the account’s live publishing credentials, so accidental overwrite, unintended reuse, or exposure via other local processes/tools can lead to account takeover or unauthorized posting.
The guide forces a single language presentation throughout the file, and there is no indication that users may choose another language or that the skill is intended only for a Chinese-language audience. Under the stated policy, fixed language behavior without user opt-in can be a natural-language policy violation.