Back to skill

Security audit

context-clean-up

Security checks for vulnerabilities and agentic risk

Overview

The skill is mostly an audit tool, but it can expose private OpenClaw session content in reports and recommends quiet out-of-band delivery patterns that deserve review before installation.

Install only if you are comfortable with the skill inspecting OpenClaw session history. Treat generated JSON reports as sensitive because they may include private conversation or reasoning snippets, inspect/redact them before sharing, and avoid using the out-of-band notification guidance unless you explicitly approve the destination and understand what data will leave the main transcript.

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

Warning
Location
scripts/context_cleanup_audit.py:109
Finding

Unredacted Session and Reasoning Content Persisted in Audit Reports

Content
View full analysis

Vulnerability Details

File Location: scripts/context_cleanup_audit.py, lines 109–149 and 202–215
Vulnerability Type: Sensitive information exposure through unredacted report generation
Risk Level: Medium

Vulnerable Code

python
with session_path.open("r", encoding="utf-8") as f:
    for line in f:
        total_lines += 1
        line = line.strip("\n")
        if not line:
            continue
        try:
            obj = json.loads(line)
        except Exception:
            continue

        if obj.get("type") != "message":
            continue
        msg = obj.get("message") or {}
        role = str(msg.get("role") or "")
        roles[role] += 1

        tool_name = str(msg.get("toolName") or "")
        if tool_name:
            tool_names[tool_name] += 1

        content = msg.get("content") or []
        if not isinstance(content, list):
            continue

        for ci in content:
            if not isinstance(ci, dict):
                continue
            ctype = ci.get("type")
            if ctype == "text":
                text = ci.get("text") or ""
                if not isinstance(text, str) or not text:
                    continue
                if "System:" in text:
                    system_like += 1
                if "Cron:" in text:
                    cron_like += 1
                consider(len(text), "text", str(obj.get("id") or ""), role, tool_name, _preview(text))
            elif ctype == "thinking":
                think = ci.get("thinking") or ""
                if not isinstance(think, str) or not think:
                    continue
                consider(len(think), "thinking", str(obj.get("id") or ""), role, tool_name, _preview(think))
python
if args.out:
    out_path = Path(args.out).expanduser().resolve()
    out_path.parent.mkdir(parents=True, exist_ok=True)
    out_path.write_text(json.dumps(report, indent=2, ensure_ascii=False), encoding="utf-8")

Technical Analysis

The ...[truncated 2561 chars]

Remediation
View remediation

Remediation Suggestions

  1. Remove content previews from default reports. Record only metadata such as character count, role, message identifier, tool name, and content type.
  2. Place preview generation behind an explicit opt-in option such as --include-previews, accompanied by a clear warning that reports may contain private data.
  3. Apply robust redaction before serialization, covering API keys, bearer tokens, passwords, private keys, session cookies, authorization headers, personal data, and other configurable patterns.
  4. Exclude thinking content by default and require separate, explicit authorization before processing or exporting it.
  5. Require explicit session selection instead of silently choosing the latest transcript, or display the selected path and request confirmation before reading it.
  6. Create output files with owner-only permissions, such as mode 0600, and verify permissions after creation.
  7. Warn users to inspect and sanitize reports before sharing, uploading, or committing them.
  8. Add automated tests confirming that representative secrets never appear in default report output.
  9. Consider replacing previews with irreversible hashes or stable identifiers when correlation between repeated entries is required.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Rogue AgentSelf-Modification, Session Persistence
Findings (12)

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding

The code substantially aligns with the stated high-level purpose of auditing prompt/context bloat and not making automatic changes. It is read-only and reports likely bloat sources such as large transcript items and bootstrap files. However, the declared output promises more than the code actually delivers: there is no logic to recommend 3-8 fixes, no rollback notes, and no concrete reversible plan generation. The script outputs metrics, counts, and top largest items, but not the full audit report described. So this is a description-to-behavior mismatch caused mainly by underdelivery on the declared output and deliverables, not by dangerous hidden behavior.

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 82)May include surrounding context.

md
- long runbooks embedded directly in `SKILL.md`

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · references/cron-noise-checklist.md (reported line 30)May include surrounding context.

md
Always preserve behavior:
- create backups before editing files
- for cron jobs, modify only the final output instructions first
- verify the next run before making deeper changes

Exfiltration Commands

High
Category
Prompt Injection
Confidence
95% confidence
Finding

The instruction to 'Send the message to the user using the platform tool' describes an exfiltration-capable action, and pairing it with NO_REPLY intentionally reduces visibility in the main transcript. Even if framed as user notification, this pattern can be abused to move data out-of-band without normal conversational auditability, making it especially risky in a skill that claims to be audit-only.

Content

Scanner excerpt · references/out-of-band-delivery.md (reported line 10)May include surrounding context.

md
## Pattern

Inside the isolated cron worker:
1) Send the message to the user using the platform tool (Telegram/Discord/Slack/etc.)
2) Output exactly `NO_REPLY`

This makes the cron run "silent" from the perspective of the main session transcript, while still delivering the content to the user.

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
94% confidence
Finding

The documentation instructs an isolated cron worker to send messages via external platforms and to suppress transcript visibility by returning NO_REPLY, which goes beyond an audit-only cleanup skill and creates a covert side channel. In this skill context, hiding operational output from the main session while still delivering content externally increases the risk of unauthorized data disclosure and bypasses user oversight.

Content

No source excerpt is available for this finding.

Lp1

High
Category
MCP Least Privilege
Confidence
75% confidence
Finding

The skill uses 'env' capability that is not listed in its permissions. This may indicate deceptive intent or missing permission declarations.

Content

No source excerpt is available for this finding.

Lp1

High
Category
MCP Least Privilege
Confidence
75% confidence
Finding

The skill uses 'file_read' capability that is not listed in its permissions. This may indicate deceptive intent or missing permission declarations.

Content

No source excerpt is available for this finding.

Lp1

High
Category
MCP Least Privilege
Confidence
75% confidence
Finding

The skill uses 'file_write' capability that is not listed in its permissions. This may indicate deceptive intent or missing permission declarations.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

Recommending Telegram/Discord/Slack delivery is not justified by the stated purpose of ranking context offenders and proposing reversible fixes. Because the guidance is framed as a recommended pattern, it normalizes sending potentially sensitive content through third-party channels without necessity for the skill's declared function.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
92% confidence
Finding

The markdown recommends sending messages to external platforms but does not warn that transcript content or summaries may contain sensitive data and will leave the primary system boundary. In a cleanup/audit skill, the absence of disclosure language makes accidental data leakage more likely because users would not expect external transmission from this capability.

Content

No source excerpt is available for this finding.

Context-Inappropriate Capability

Medium
Category
Not specified by scanner
Confidence
88% confidence
Finding

The recommendation to write details into memory files introduces data persistence and possible secondary exposure that an audit-only reporting skill does not need. In context, storing details to memory/...json can retain sensitive information outside the visible report path and broaden the attack surface for later retrieval or misuse.

Content

No source excerpt is available for this finding.

Session Persistence

Medium
Category
Rogue Agent
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.

Content

Scanner excerpt · scripts/context_cleanup_audit.py (reported line 11)May include surrounding context.

python
Design goals:
- dependency-free (stdlib only)
- short stdout; optionally write detailed JSON to a file

Usage:
  python3 scripts/context_cleanup_audit.py --out memory/context-cleanup-audit.json

Static analysis

No suspicious patterns detected.