Back to skill

Security audit

agent-quantizer

Security checks for vulnerabilities and agentic risk

Overview

This skill is an OpenClaw maintenance toolkit, but it uses broad caching and direct state rewriting in ways that can expose sensitive data, corrupt sessions, or let crafted inputs execute code.

Review carefully before installing. Use only in a backed-up, non-sensitive OpenClaw environment, and avoid feeding it untrusted queries, prompt files, or command arguments until the Python interpolation bugs, plaintext caching, and session-rewrite controls are fixed.

Vulnerability Patterns
  • 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
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • 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 (6)

T01 · Skill Instruction Hijacking

Error
Location
SKILL.md:12
Finding

Mandatory caching of potentially sensitive tool inputs and outputs

Content
View full analysis
# 如果返回 HIT → 直接使用,不要重新调用 # 如果返回 MISS → 正常调用工具,调用完后存缓存: # 第二步:存缓存 bash ~/.openclaw/skills/agent-quantizer/scripts/cache.sh set "查询内容" "结果" <类别> ``` ``` The corresponding persistence implementation is: ```bash cmd_set() { local query="$1" local response="$2" local category="${3:-general}" local ttl="${4:-3600}" init_cache local qhash qhash=$(hash_query "$query") local now now=$(date +%s) jq --arg h "$qhash" --arg q "$query" --arg r "$response" --arg c "$category" \ --argjson ttl "$ttl" --argjson ts "$now" \ '.entries[$h] = {query:$q, response:$r, category:$c, ttl:$ttl, created:$ts}' \ "$CACHE_DB" > "$CACHE_DB.tmp" && mv "$CACHE_DB.tmp" "$CACHE_DB" echo "OK|$qhash" } ``` ### Technical Analysis The Skill declares that every network-related tool call must first be checked against its cache and that the complete query and result must be cached after a miss. This changes the behavior of unrelated tools merely because the Skill has been loaded. The implementation stores both the original query and complete response in plaintext JSON. There is no sensitivity classification, secret redaction, per-session isolation, encryption, restrictive `umask`, or explicit file-mode enforcement. Tool output can contain credentials, private source code, personal information, internal URLs, session data, or authentication headers. This exceeds the minimum privileges necessary for an explicitly invoked token-optimization utility. Caching should be an opt-in behavior for suitable ...[truncated 1009 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/cache.sh:24
Finding

Arbitrary Python code execution through cache query interpolation

Content
View full analysis
/dev/null || echo "0" } ``` This function receives untrusted values from the semantic cache lookup: ```bash sim=$(similarity "$query" "$cached_q") ``` ### Technical Analysis Shell quoting does not make the values safe after they are embedded into Python source code. Both the current query and cached query are inserted between Python triple-quoted string delimiters. A value containing a closing triple quote can terminate the intended string literal and inject additional Python statements. Because the injected text is interpreted by `python3 -c`, an attacker can import modules such as `os` or `subprocess` and execute arbitrary commands. The mandatory cache-check instruction substantially increases reachability because ordinary user-controlled search text may be passed to this function. ### Attack Path 1. An attacker supplies a crafted tool query containing Python syntax that closes the triple-quoted literal. 2. The mandatory cache lookup invokes `cmd_get`. 3. During semantic matching, `cmd_get` calls `similarity "$query" "$cached_q"`. 4. The query is inserted directly into the source passed to `python3 -c`. 5. Python parses and executes the injected statements. 6. The attacker’s commands run with the same OS permissions, files, environment variables, and network access as the OpenClaw process. A malicious cached query can trigger the same path when it is later loaded as `cached_q`. ### Impact Assessment Successful exploitation provides arbitrary code execution under the account running the Skill. The attacker can read OpenClaw configuration and session files, access credentials avai ...[truncated 287 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
`. 3. `cmd_trim` reads the complete file and passes it to `count_tokens`. 4. `count_tokens` embeds the content into the `python3 -c` source string. 5. The crafted content terminates the intended literal and executes attacker-supplied Python. 6. Commands run with the privileges and environment of the OpenClaw process. ### Impact Assessment Exploitation grants arbitrary code execution as the current OS account. The attacker may read private prompts, session histories, model configuration, environment creden ...[truncated 377 chars]:35
Finding

Arbitrary Python code execution through prompt-file contents

Content
View full analysis
/dev/null || echo "0" } ``` The function is called with complete file contents: ```bash before_tokens=$(count_tokens "$(cat "$file")") ``` It is called again after the file is rewritten: ```bash after_tokens=$(count_tokens "$(cat "$file")") ``` ### Technical Analysis The complete contents of a user-selected file are interpolated directly into Python source between triple quotes. A file containing a closing triple-quote sequence can escape the intended string and add executable Python statements. The vulnerable token-counting operation occurs before the trimming transformation, so an attacker-controlled file can execute code as soon as `quantize trim` begins. Shell quoting around `"$(cat "$file")"` preserves the argument but does not escape it for the different Python-language context. ### Attack Path 1. An attacker creates or modifies a Markdown or prompt file with crafted Python-breaking content. 2. The attacker persuades a user or Agent to run `quantize trim `. 3. `cmd_trim` reads the complete file and passes it to `count_tokens`. 4. `count_tokens` embeds the content into the `python3 -c` source string. 5. The crafted content terminates the intended literal and executes attacker-supplied Python. 6. Commands run with the privileges and environment of the OpenClaw process. ### Impact Assessment Exploitation grants arbitrary code execution as the current OS account. The attacker may read private prompts, session histories, model configuration, environment credentials, and other user files; ...[truncated 225 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/clean-zombies.sh:7
Finding

Arbitrary Python code execution through the cleanup-days argument

Content
View full analysis
Remediation
View remediation
3650 )); then echo "DAYS must be an integer between 1 and 3650." >&2 exit 2 fi ``` Pass the validated value as data rather than source code: ```bash CUTOFF=$(python3 - "$DAYS" <<'PY' import sys import time days = int(sys.argv[1]) print(int((time.time() - days * 86400) * 1000)) PY ) ``` Also require dry-run review by default, validate all session identifiers before constructing paths, and retain explicit confirmation for filesystem changes. ]]>

T02 · Agent Memory Poisoning

Error
Location
scripts/quantize.sh:273
Finding

Conversation content is promoted into a persistent system-role message

Content
View full analysis
/dev/null | \ grep -iE "决定|选择|使用|创建|修改|完成|错误|TODO|NOTE" | \ head -20 } > "$summary_file" # 构建新的 session 文件:保留 metadata + 摘要 + 最近消息 local new_file="${jsonl_file}.new" # 保留第一行 (metadata) head -1 "$jsonl_file" > "$new_file" # 注入摘要作为 system 消息 local summary_text summary_text=$(cat "$summary_file") jq -n --arg t "$summary_text" \ '{"message":{"role":"system","content":[{"type":"text","text":"[之前对话摘要]\n" + $t}]}}' >> "$new_file" # 追加最近的消息 tail -n "$max_msgs" "$jsonl_file" >> "$new_file" # 替换原文件 mv "$new_file" "$jsonl_file" ``` ### Technical Analysis The script extracts text from historical messages without preserving whether each line came from a user, assistant, tool, or trusted instruction. Selection is based only on broad keywords such as `TODO` and `NOTE`. The extracted text is then inserted into a new message with the privileged `system` role and persisted in the rewritten session file. Consequently, attacker-controlled conversation content can be elevated from an untrusted role into system-level context. The original history is replaced, making the poisoned summary persist as part of the compressed session state. This is not a safe summarization boundary. Quoting untrusted text inside a system message does not reliably prevent models from treating embedded imperative language as instructions. ### Attack Path 1. An attacker contributes a message to a session containing an instruction with a selecte ...[truncated 1051 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/quantize.sh:315
Finding

Unrestricted destructive rewriting of arbitrary files during prompt trimming

Content
View full analysis
${NC}" >&2 return 1 fi echo -e "${YELLOW}✂️ 精简文件: $file${NC}" local before_tokens before_tokens=$(count_tokens "$(cat "$file")") # 精简规则 python3 - "$file" << 'PYEOF' import sys, re with open(sys.argv[1], 'r') as f: text = f.read() original_len = len(text) # 1. 删除空行超过 2 行的 text = re.sub(r'\n{3,}', '\n\n', text) # 2. 删除礼貌性用语 politeness = [ r'请.{0,5}(注意|确保|确认|记住)', r'(非常|十分|特别)?(感谢|谢谢).*?\n', r'如有.{0,3}(问题|疑问).{0,10}(请|欢迎).{0,10}\n', r'(希望|祝).{0,20}(顺利|愉快).*?\n', ] for p in politeness: text = re.sub(p, '', text) # 3. 压缩重复指令 text = re.sub(r'(请.{0,10})(\n\1)+', r'\1\n', text) # 4. 删除 markdown 注释 text = re.sub(r'', '', text, flags=re.DOTALL) # 5. 合并连续的 bullet point 描述行 text = re.sub(r'(- .+)\n (.+)', r'\1 \2', text) # 6. 清理尾部空白 text = text.strip() + '\n' saved = original_len - len(text) with open(sys.argv[1], 'w') as f: f.write(text) print(f" 原始: {original_len} 字符") print(f" 精简: {len(text)} 字符") print(f" 节省: {saved} 字符 ({saved*100//original_len}%)") PYEOF ``` ### Technical Analysis Although the command is presented as a prompt-file optimizer, it accepts any path that passes `-f`. It performs no canonical-path validation, workspace restriction, extension enforcement, symbolic-link protection, backup, preview, or confirmation before overwriting the file. The regular expressions are semantic and broad. In particular, they may remove language expressing requirements to pay attention, ensure, confirm, or remember something. Such language can be security-relevant rather than merely polite. The Markdown comment removal is ...[truncated 1085 chars]
Remediation
View remediation
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (26)

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

该代码块是 deploy.sh 安装脚本:创建目录、复制 SKILL.md/config.json/脚本文件、chmod、检查依赖并打印使用说明。其直接行为是部署名为 Agent Quantizer 的技能,而不是执行声明中的 API 调用优化、僵尸清理、heartbeat 检查、cron 审计等核心功能。虽然输出示例中提到“compress”和“cache stats”,可能与“上下文压缩/缓存”有部分相关,但这只是安装后可用命令的提示,不是当前代码块实际实现的能力。因此,代码实际行为与声明用途存在明显且实质性的偏差。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The supplied shell script is narrowly focused on cache management. It hashes queries, performs exact and Jaccard-based semantic cache lookups, stores responses with TTL/category metadata, cleans expired entries, reports stats, lists entries, and flushes the cache. This partially aligns with the declared '缓存去重' / API optimization aspect, but the description claims a much broader feature set—context compression, heartbeat checks, cron auditing, model grading, and skill management—which are absent from the code. No undeclared sensitive capabilities are present; the issue is that the description materially overstates the implemented behavior.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

代码行为只覆盖了声明中的“heartbeat 检查”这一小部分,而且是较具体的 HEARTBEAT.md 空转检查与配置读取。它并未实现描述中大部分核心能力,如 API 调用优化、上下文压缩、缓存去重、僵尸清理、cron 审计、模型分级或 skill 管理。因此,声明的主要用途明显比实际代码宽泛且不同,属于描述与行为不一致。未见额外危险或越权能力,但主功能严重不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

描述把该 skill 定义为一个多功能的“API 调用优化器”,包含多项能力;但提供的代码仅实现其中一个很窄的子功能:清理长期不活跃的 session。脚本通过 openclaw sessions --json 获取 session 列表,按 updatedAt 判断僵尸 session,展示统计信息,并在用户确认后把对应 .jsonl 文件移到 .zombie-backup 目录。虽然“僵尸清理”这一点与描述中的一项能力吻合,但整体声明的主要用途与实际代码的单一行为不相称,且多数宣称能力在该代码块中完全不存在,因此应判定为描述与行为不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
99% confidence
Finding

声明描述的核心是 API 调用优化与运行维护能力,例如上下文压缩、缓存去重、heartbeat/cron 审计、模型分级等;而实际代码并未实现这些功能。它的主要用途是本地 skill 目录整理与迁移,只涉及文件系统检查、输出建议、读取用户确认以及执行 mv 移动操作。虽然声明里提到“skill 管理”,但该表述过于宽泛,无法准确覆盖此脚本的实际主功能,更无法解释其与前半部分 API 优化/运维能力之间的明显偏差。因此属于实质性描述与行为不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding

描述与代码部分重合:代码确实涉及上下文压缩,也有缓存相关入口,并以 API/token 优化为主题。但当前代码块没有实现描述中的多项核心能力,如僵尸清理、heartbeat 检查、cron 审计、模型分级、skill 管理。相反,它实现了一个描述中未明确提到的重要功能:对任意 Markdown/prompt 文件进行内容精简,并且会直接修改本地会话存储文件,通过备份、删除和重建 JSONL 来压缩上下文。由于声明覆盖面明显大于实际代码,且代码包含未声明的重要文件修改行为,因此应判定为描述与实际行为存在不匹配。

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

声明描述的是一个多功能 API 优化/运维工具,覆盖上下文处理、缓存管理、进程清理、健康检查、定时任务审计、模型路由分级和 skill 管理等广泛能力。但提供的代码块只涉及“模型分级”中的很小一部分,而且还是只读检查与交互提示:它解析本地配置文件中的主模型和备用模型,输出推荐策略,并给出下一步操作建议。代码没有实现声明中的大多数核心能力,也没有进行实际配置写入或管理操作。因此描述明显宽于且不同于该代码的真实行为,属于实质性不匹配。

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

The compression flow deletes or replaces the session file with no confirmation prompt, dry-run, or rollback gate beyond a best-effort backup. In this skill context, destructive session mutation is a core feature, which makes the absence of safety controls particularly risky because a normal user action can irreversibly lose context or break agent state.

Content

No source excerpt is available for this finding.

Undeclared Tool Scope

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding

The skill advertises and instructs shell execution plus filesystem-affecting operations, but declares no explicit tool scope such as allowed-tools or permissions. That creates an authorization ambiguity where a host may grant broader capabilities than users expect, especially because the skill includes destructive and reorganization actions like cache flushing, session cleanup, and skill movement.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill exposes a destructive cache-clearing action via a natural-language shortcut without any warning, confirmation, scope limitation, or recovery guidance. In an agent setting, this increases the chance of accidental state loss or denial of service against cached data, especially because the skill is user-invocable and emphasizes direct command execution.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The comments and user-facing output indicate the skill is intended to operate in Chinese, and the script does not provide any option to select another language. This is a natural-language policy concern because it imposes a specific locale on users without opt-in or a stated region-specific justification.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

Comments and user-facing strings throughout the script are written in Chinese, including help and status output, without offering a language choice or documenting that the skill is intentionally limited to a Chinese-speaking context. This can violate language/locale policy when a skill imposes a specific language on users without opt-in.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

This shell script writes persistent cache and stats data to disk and later overwrites those files, but it provides no confirmation prompt and no user-facing warning at the points where data is created or modified. Because file writes and resets can affect user data, the script should explicitly disclose that it stores query/response content locally and that flush resets the cache.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
98% confidence
Finding

The flush command unconditionally overwrites the cache and stats files, deleting all cached entries and counters, yet there is no confirmation prompt or explicit warning in the command implementation or surrounding documentation. This is a destructive operation and should be clearly disclosed to the user before execution.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The script's title, usage text, status messages, and confirmation prompt are presented in Chinese, which imposes a specific language on users. There is no opt-in, fallback language, or documentation indicating that this skill is intentionally limited to a Chinese-speaking context.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The skill manifest advertises optimization and operational audit tasks such as context compression, deduplication, heartbeat checks, cron auditing, and model grading. In contrast, this file scans ~/.openclaw skill locations, suggests classification changes, and moves directories after confirmation, which is a different behavior domain from the primary manifest description.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The manifest describes an API-call optimizer covering context compression, cache deduplication, zombie cleanup, heartbeat checks, cron auditing, model tiering, and skill management. This script performs filesystem-level inventory and movement of skill directories across global and workspace locations, which is administrative reorganization behavior rather than optimization logic and is not clearly justified by the described purpose of this skill.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The script directly manipulates OpenClaw session state files under the user's state directory, including overwriting and replacing conversation history. In this skill context, the tool is explicitly designed to alter agent sessions, so the behavior is in-scope, but it is still dangerous because path-derived file operations can corrupt session state, destroy forensic/history data, or modify the wrong session if assumptions about IDs or layout are wrong.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The AI compression mode sends session content to another agent/model for summarization without an explicit disclosure or consent step warning that conversation contents may be transmitted for processing. In a context-compression skill, that makes the issue more serious because users may invoke it on sensitive sessions expecting a local maintenance action, not a secondary model exposure.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

Nearly all user-visible strings in the script are in Chinese, and there is no indication that the skill is region-specific or that users can opt into another language. This can violate language/locale policy when a skill imposes a specific language without user choice.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
91% confidence
Finding

The line states that users can invoke the skill directly in Chinese only ("中文即可"), which implies a language constraint without presenting an opt-in or alternative language option. This can violate language/locale policy expectations when a skill is otherwise general-purpose and not clearly limited to a Chinese-only context.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
96% confidence
Finding

The script's natural-language comments and user-facing messages are entirely in Chinese, including usage and status output. Under the policy, forcing a specific language without user opt-in or a documented locale-specific justification is a natural-language policy violation.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
98% confidence
Finding

The script's comments and all user-facing prompts are written in Chinese, including usage and confirmation text. This imposes a specific language on users without any visible option to select another locale, which matches the language/locale policy violation category.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Low
Category
Not specified by scanner
Confidence
98% confidence
Finding

Comments, prompts, status output, and help text are presented in Chinese throughout the script, including the injected compression summary prompt and all CLI usage messages. There is no mechanism for users to choose their preferred language or indication that the tool is intentionally region-specific, which creates a locale-policy issue.

Content

No source excerpt is available for this finding.

Description-Behavior Mismatch

Low
Category
Not specified by scanner
Confidence
84% confidence
Finding

The manifest description lists capabilities including zombie cleanup, heartbeat checks, cron auditing, model tiering, and skill management. In this script's exposed commands and implemented functions, the behavior is limited to session/token inspection, context compression, prompt-file trimming, and forwarding to cache management, with no implementation of the other claimed maintenance functions.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.