Back to skill

Security audit

token-optimizer-off

Security checks for vulnerabilities and agentic risk

Overview

The skill has a coherent token-saving purpose, but it needs review because it can silently persist AI-generated memory, send session or user-chosen file contents to configurable external API endpoints, and its cleanup/test paths can affect global OpenClaw memory.

Install only after you are comfortable with this skill sending session summaries or selected files to the configured AI endpoint and writing persistent global memory that future OpenClaw sessions may load. Avoid using the arbitrary file argument for sensitive files, verify the API URL and credentials, back up ~/.openclaw/memory before use, do not run the documented uninstall command that deletes the whole memory directory unless you intend to erase all OpenClaw memory, and isolate TOKEN_OPTIMIZER_MEMORY_DIR before running tests.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
Findings (4)

T02 · Agent Memory Poisoning

Error
Location
scripts/compress_session.py:181
Finding

Persistent Prompt Injection Through AI-Generated Session Summaries

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/compress_session.py:246
Finding

Arbitrary Local File Disclosure to an Unrestricted External API Endpoint

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
tests/test_session_guard.py:12
Finding

Test Suite Overwrites Live OpenClaw Session State

Content
View full analysis
Remediation
View remediation

T08 · Insecure Dependencies

Note
Location
requirements.txt:1
Finding

Unbounded and Unhashed Third-Party Dependency

Content
View full analysis
=1.0.0 ``` ### Technical Analysis The dependency declaration specifies only a minimum version. Any future release satisfying the constraint may be installed, including versions not reviewed or tested by the project. No lockfile or package hashes are supplied to verify the exact artifact. The package name is the expected official `openai` package, and the audited project contains no evidence of intentional dependency confusion or typosquatting. The issue is therefore an avoidable supply-chain and reproducibility weakness rather than evidence of a malicious dependency. ### Attack Path 1. A user runs `pip install -r requirements.txt`. 2. The package index resolves the newest available version satisfying `>=1.0.0`. 3. That version may contain an incompatible change, a newly introduced vulnerability, or a compromised release. 4. The dependency executes with the same user privileges as the Skill when imported and used. 5. Any malicious or vulnerable behavior in that installed release can affect files, environment data, network requests, and credentials accessible to the process. ### Impact Assessment A compromised dependency would execute with the privileges of the user running the Skill and could access the API credential passed to the OpenAI client, session contents, and other user-readable resources. The likelihood attributable to this project is limited because it references the expected package name from a normal package source. The primary confirmed impact is loss of build reproducibility and inability to guarantee that installations use an audited dependency version. ]]>
Remediation
View remediation
`. 2. Generate and commit a lockfile appropriate to the installation workflow. 3. Use hash checking, such as pip requirements with `--hash` entries and `--require-hashes`. 4. Update dependencies through a controlled review process with compatibility and security testing. 5. Use a trusted package index and prevent fallback to untrusted or user-controlled indexes in production installation instructions. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Taint TrackingDirect Taint Flow, Variable-Mediated Taint Flow, Credential Exfiltration Chain
Findings (35)

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · INSTALL.md (reported line 129)May include surrounding context.

bash
# 删除技能目录
rm -rf ~/.openclaw/workspace/skills/token-optimizer

# 可选:删除记忆文件
rm -rf ~/.openclaw/memory

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
90% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · INSTALL.md (reported line 129)May include surrounding context.

bash
# 删除技能目录
rm -rf ~/.openclaw/workspace/skills/token-optimizer

# 可选:删除记忆文件
rm -rf ~/.openclaw/memory

Missing User Warnings

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The uninstall instructions include deletion of ~/.openclaw/memory, which the document earlier states is a global memory directory shared by OpenClaw rather than being scoped to this skill. Removing that path can destroy unrelated user data and session history, and the warning is only marked as optional rather than clearly describing the data-loss consequences.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
99% confidence
Finding

This duplicate finding correctly identifies a high-risk deletion command aimed at a global application directory rather than the skill itself. Because the documentation notes that memory is stored globally under ~/.openclaw/memory/, the uninstall step can cause substantial unintended data loss beyond this skill's footprint.

Content

Scanner excerpt · INSTALL.md (reported line 132)May include surrounding context.

rm -rf ~/.openclaw/workspace/skills/token-optimizer

可选:删除记忆文件

rm -rf ~/.openclaw/memory

text

## 获取帮助

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
99% confidence
Finding

This duplicate finding correctly identifies a high-risk deletion command aimed at a global application directory rather than the skill itself. Because the documentation notes that memory is stored globally under ~/.openclaw/memory/, the uninstall step can cause substantial unintended data loss beyond this skill's footprint.

Content

Scanner excerpt · INSTALL.md (reported line 132)May include surrounding context.

rm -rf ~/.openclaw/workspace/skills/token-optimizer

可选:删除记忆文件

rm -rf ~/.openclaw/memory

text

## 获取帮助

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
86% confidence
Finding

All user-facing instructions in the file are presented in Chinese, and there is no indication that the skill is region-specific or that alternative language documentation is available. This can violate language or locale policy when users are not given an explicit language choice.

Content

No source excerpt is available for this finding.

File System Enumeration

Medium
Category
Data Exfiltration
Confidence
60% confidence
Finding

Code scans file system directories looking for sensitive files. This could be reconnaissance for credential theft.

Content

Scanner excerpt · INSTALL.md (reported line 45)May include surrounding context.

python3 scripts/status.py

查看记忆目录

ls -la ~/.openclaw/memory/

text

## 使用示例

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · INSTALL.md (reported line 97)May include surrounding context.

如果看到权限警告:

bash
chmod 600 ~/.openclaw/config.json

问题4:测试失败

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The README promotes automatic compression and persistent memory storage as core features without warning that user conversation history may be modified, reduced, and stored outside the skill directory. In a tool that operates on session context, failing to disclose persistence and mutation of user data can lead to unintended data loss, privacy issues, and user surprise during normal use.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The usage section includes a dry-run and then an actual compression command that saves changes, but it does not clearly warn that compression may irreversibly reduce session context fidelity or overwrite the latest summary state. Users may execute the command expecting a safe optimization step, when it actually alters persisted memory and future agent behavior.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The skill explicitly states that session compression will run automatically and silently, while also describing writes to global memory files under ~/.openclaw/memory/. Silent modification of persistent conversation summaries can change what future sessions load without the user noticing, creating risks of unintended data retention, context tampering, or leakage of sensitive information into long-lived memory.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The natural-language description forces a specific language presentation in the manifest metadata. Under the policy, locale or language restrictions should either offer user opt-in or be clearly justified as region-specific, neither of which is present here.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
94% confidence
Finding

The script loads API credentials from local configuration/environment and uses them to send session summary content to a remote LLM service. Even if this is the intended feature, it creates a real data-exposure boundary because potentially sensitive local session data is transmitted off-host without strong scoping, redaction, or explicit consent at the point of use.

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

md
# 提取 AI 配置
                if 'ai' in openclaw_config:
                    ai_config = openclaw_config['ai']
                    config['api_url'] = ai_config.get('baseURL', 'https://api.openai.com/v1')
                    config['api_key'] = ai_config.get('apiKey', '')
                    config['model'] = ai_config.get('model', 'gpt-4')
                elif 'llm' in openclaw_config:

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

md
# 提取 AI 配置
                if 'ai' in openclaw_config:
                    ai_config = openclaw_config['ai']
                    config['api_url'] = ai_config.get('baseURL', 'https://api.openai.com/v1')
                    config['api_key'] = ai_config.get('apiKey', '')
                    config['model'] = ai_config.get('model', 'gpt-4')
                elif 'llm' in openclaw_config:

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 · scripts/compress_session.py (reported line 58)May include surrounding context.

python
# 提取 AI 配置
                if 'ai' in openclaw_config:
                    ai_config = openclaw_config['ai']
                    config['api_url'] = ai_config.get('baseURL', 'https://api.openai.com/v1')
                    config['api_key'] = ai_config.get('apiKey', '')
                    config['model'] = ai_config.get('model', 'gpt-4')
                elif 'llm' in openclaw_config:

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 · scripts/compress_session.py (reported line 63)May include surrounding context.

python
# 提取 AI 配置
                if 'ai' in openclaw_config:
                    ai_config = openclaw_config['ai']
                    config['api_url'] = ai_config.get('baseURL', 'https://api.openai.com/v1')
                    config['api_key'] = ai_config.get('apiKey', '')
                    config['model'] = ai_config.get('model', 'gpt-4')
                elif 'llm' in openclaw_config:

Sudo/Root Execution

Medium
Category
Privilege Escalation
Confidence
80% confidence
Finding

Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Content

Scanner excerpt · scripts/compress_session.py (reported line 97)May include surrounding context.

python
# 检查是否其他用户可读(权限过于宽松)
        if file_mode & stat.S_IROTH:
            print(f'[警告] 配置文件 {filepath} 权限过于宽松(其他用户可读)')
            print(f'       建议执行: chmod 600 {filepath}')
    except Exception:
        pass  # 权限检查失败不影响主流程

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The code removes backup files in cleanup_old_backups and later writes a new latest-summary.md, changing persistent local state. While there are status prints for backup and completion, there is no clear up-front disclosure in the tool description/help that running the command will overwrite the latest summary and automatically delete backups older than 7 days.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The code sends full session content to an external AI API but does not present a clear runtime warning that local data will leave the machine. Users may reasonably assume a summarization utility operates locally, so the absence of explicit disclosure increases the risk of unintentional leakage of secrets, personal data, or internal project details.

Content

No source excerpt is available for this finding.

Ssd 3

Medium
Category
Not specified by scanner
Confidence
85% confidence
Finding

The compression prompt explicitly tells the model to retain key configuration, paths, validated solutions, lessons learned, and important decisions in a persistent summary. That increases the chance that sensitive operational details, environment structure, or security-relevant context are preserved long-term and possibly transmitted to a third party during compression.

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 instructions, docstrings, and command usage text exclusively in Chinese, which can force a specific language experience on users. The policy allows locale constraints only when they are documented and justified or when users are given a choice, neither of which is present here.

Content

No source excerpt is available for this finding.

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

This Python file's docstring, CLI descriptions, and printed guidance are entirely in Chinese, and the header states the agent should call this script before every reply. That creates a natural-language locale constraint without any opt-in, fallback, or justification that the skill is intended only for a Chinese-speaking environment.

Content

No source excerpt is available for this finding.

Tainted flow: 'STATE_FILE' from os.getenv (line 22, credential/environment) → open (file write)

Medium
Category
Data Flow
Confidence
90% confidence
Finding

The script builds MEMORY_DIR from the TOKEN_OPTIMIZER_MEMORY_DIR environment variable and then writes state to STATE_FILE under that path without validation. If an attacker can influence the environment in which the agent runs, they can redirect writes to an arbitrary filesystem location the process can access, causing unintended file creation or overwrite and potentially corrupting other application state.

Content

Scanner excerpt · scripts/session_guard.py (reported line 74)May include surrounding context.

python
def save_state(state: dict):
    """保存会话状态"""
    os.makedirs(SESSIONS_DIR, exist_ok=True)
    with open(STATE_FILE, 'w', encoding='utf-8') as f:
        json.dump(state, f, ensure_ascii=False, indent=2)

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
96% confidence
Finding

The module docstring and user-facing descriptions are entirely in Chinese, including the usage/help text shown to users. This imposes a specific language/locale without opt-in or justification, which matches the policy category for language or locale violations.

Content

No source excerpt is available for this finding.