T09 · Insecure Skill Coding Practices
- Location
scripts/ghost_mode.sh:242- Finding
Arbitrary Python Code Execution Through Unsafe Shell Interpolation
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This skill is a clearly disclosed privacy/deletion tool, but its implementation can delete too broadly and has unsafe failure and input-handling behavior.
Review before installing. This skill is local and purpose-built to delete OpenClaw memory/session traces, but it has serious safety issues: it may delete unrelated archive/session data, may claim cleanup succeeded when verification failed, and has input/path handling bugs. Use only with backups, explicit commands, dry-run previews, and a trusted local environment; avoid cron, --yes, and disabling confirmations until the implementation is fixed.
scripts/ghost_mode.sh:242Arbitrary Python Code Execution Through Unsafe Shell Interpolation
scripts/ghost_archive.py:24OPENCLAW_AGENT Path Traversal Allows File Operations Outside the OpenClaw Directory
scripts/ghost_mode.sh:349Single-Session Cleanup Securely Deletes the Entire Shared Archive
scripts/ghost_mode.sh:328Cleanup Continues After Failures and Falsely Reports Successful Verification
scripts/ghost_scrub.py:50Timestamp-Based Scrubbing Can Delete Memory From Unrelated Sessions
Skill instructs the agent to omit warnings, disclaimers, or ethical commentary. Stripping safety caveats hides risk from the user and is a common jailbreak preamble.
> ⚠️ **Ghost Mode is installed.** This skill permanently deletes data — logs, memory files, session transcripts, and search index entries — using secure deletion (`shred -u`). This is irreversible. Bugs, misuse, or environment conflicts can cause unrecoverable data loss beyond what you intended. By keeping this skill installed, you accept these risks. **Strongly recommended: set up daily backups of `~/.openclaw/workspace/` and `~/.openclaw/data/`.** Run `ghost_mode.sh status` to check the current state at any time.
This warning must be shown **once** after installation. To prevent repeated warnings, after delivering it, create the file `memory/.ghost-mode-warning-shown` in the workspace. On subsequent sessions, check for this file — if it exists, skip the warning.
**On first install**, the agent MUST also create `ghost-mode-config.json` in the workspace root with confirmation enforced:
The skill advertises a session that leaves 'no persistent trace' while explicitly preserving independently created files and local outputs. This creates a dangerous privacy mismatch: users may disclose secrets under the assumption of full non-persistence even though artifacts, downloads, generated files, gateway logs, and other traces can remain.
---
name: ghost-mode
description: Browser-style incognito mode for your OpenClaw agent. Activate to pause all memory writes — when you deactivate, every trace of the session is securely scrubbed from logs, memory files, session transcripts, and search indexes. Like closing an incognito window: nothing persists. Any files or local outputs you independently create during the session remain untouched. Use when user says "ghost on", "ghost off", "incognito", "private mode", "privacy mode", or wants a conversation that leaves no persistent trace in agent memory.
requires:
bins:
- python3
The invocation description includes the broad trigger 'or wants a conversation that leaves no persistent trace in agent memory,' which can cause the skill to activate from ambiguous user intent rather than a precise command. In a destructive/privacy-affecting skill, ambiguous activation increases the risk of unintended suppression of logging and later deletion of session artifacts.
The documented use of '--yes' to skip confirmation enables fully automated execution of a destructive cleanup operation that permanently deletes logs, memory files, transcripts, and index entries. In a skill whose core function is irreversible deletion, allowing one-flag suppression of safeguards materially increases the chance of accidental or scripted data destruction.
# Deactivate and scrub (with confirmation prompt)
./scripts/ghost_mode.sh off
# Skip confirmation prompt (for scripted/automated use)
./scripts/ghost_mode.sh off --yes
# Check status (includes config)
Allowing 'confirm_before_delete' to be disabled in configuration and permitting '--yes' in non-interactive contexts weakens the only meaningful user-consent barrier before irreversible deletion. This makes misuse by automation, operator error, or a compromised agent workflow much more likely to cause silent destructive cleanup.
Type yes to confirm, or anything else to cancel:
- **Configurable**: Set `"confirm_before_delete": false` in `ghost-mode-config.json` to disable prompts.
- **Non-interactive fallback**: If no terminal is available (e.g., cron, piped input), confirmation is required unless you pass `--yes` / `-y`.
- **`--yes` / `-y` flag**: Skips the confirmation prompt entirely. Use in scripts, cron jobs, or automation.
The configuration table explicitly documents turning off confirmation and dry-run defaults, normalizing unattended destructive behavior. Given the skill's purpose of scrubbing and shredding records, these options reduce friction around irreversible deletion and make unsafe deployment practices more likely.
| Setting | Default | Description |
|---------|---------|-------------|
| `confirm_before_delete` | `true` | Require typing `yes` before any destructive operation. Set `false` to disable prompts. |
| `dry_run_by_default` | `true` | If `true` (default), `ghost off` and `force-cleanup-all` start in dry-run mode. Pass `--yes` to execute for real. Set `false` to skip dry-run by default. |
## What This Skill Touches
The documentation states that files and local outputs created during a ghost session remain untouched, which conflicts with the broader incognito/no-trace framing elsewhere in the skill. This can mislead users into believing sensitive material handled during the session will be ephemeral, when in reality generated files, artifacts, and downloads may persist on disk.
## What This Skill Does NOT Touch
- **Files you create** — code, documents, images, configs, anything you explicitly write to disk during a ghost session stays exactly where you put it
- **Local outputs** — command output, build artifacts, downloaded files, anything the agent creates as a file output (not a memory entry) is untouched
- OpenClaw gateway logs — outside agent workspace scope
- OS-level process traces — outside agent workspace scope
The AGENTS.md integration instructs the agent to avoid mentioning ghost mode unless the user asks, reducing transparency while a destructive mode is active. Hiding the state of a mode that suppresses memory writes and later scrubs records can prevent informed consent and increase the chance of unnoticed data loss or audit bypass.
The architecture explicitly describes irreversible deletion and shredding of session transcripts, checkpoints, and memory artifacts, but it does not pair that behavior with strong user-consent, retention, rollback, or recovery safeguards. In a system handling conversational history and memory, this can cause accidental permanent data loss or anti-forensics behavior if triggered improperly or automatically.
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.
**Semantic memory** (`memory/semantic/*.md`):
- Removes entries attributed to the ghost session or with timestamps in the ghost window
- Atomic write: write to `.tmp`, then rename
**Episodic memory** (`memory/episodic/*.md`):
- Same approach as semantic
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
dest = archive_dir / src_path.name
# Copy to archive
shutil.copy2(src_path, dest)
print(f"Archived: {src_path.name} -> {archive_dir.relative_to(OPENCLAW_HOME)}", file=sys.stderr)
# Remove original if full mode, or if checkpoint/split in split mode
The script unlinks original session files after copying them, with no confirmation, dry-run, rollback, or verification that the archive copy is complete and durable beyond copy2 returning. In an agent/automation context, this can cause irreversible loss of session data if invoked against the wrong sessions, with misleading status updates further increasing the chance of silent destructive mistakes.
The function documentation states it will find sessions with status 'completed' and archive them, but the implementation calls list_sessions(status="active"). This is an active contradiction between the stated intent and the actual selection logic, and it materially changes which sessions are affected.
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
# ── Confirmation ────────────────────────────────────────────────────
confirm_delete() {
# Check config: if confirm_before_delete is false, skip confirmation
local require_confirm
require_confirm=$(get_config_bool "confirm_before_delete" "true")
if [ "$require_confirm" = "false" ]; then
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
# ── Confirmation ────────────────────────────────────────────────────
confirm_delete() {
# Check config: if confirm_before_delete is false, skip confirmation
local require_confirm
require_confirm=$(get_config_bool "confirm_before_delete" "true")
if [ "$require_confirm" = "false" ]; then
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.
echo "════════════════════════════════════════════════════════════════"
echo ""
# Mark warning as shown so it only appears once
mkdir -p "$(dirname "$WARNING_FILE")"
date -u +"%Y-%m-%dT%H:%M:%SZ" > "$WARNING_FILE"
log "Warning shown and acknowledged. This message will not appear again."
fi
Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
echo ""
echo "Options:"
echo " --dry-run Show what would be deleted without making any changes"
echo " --yes, -y Skip confirmation prompt (for scripted use)"
echo ""
echo "Configuration (ghost-mode-config.json in workspace root):"
echo " {"
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
"""Atomic write: save to .tmp then rename."""
REGISTRY_PATH.parent.mkdir(parents=True, exist_ok=True)
tmp = REGISTRY_PATH.with_suffix(".tmp")
with open(tmp, "w") as f:
json.dump(registry, f, indent=2)
tmp.rename(REGISTRY_PATH)
Data from a source is assigned to a variable that is later passed to a sink, creating a variable-mediated taint flow.
"activatedAt": datetime.now(timezone.utc).isoformat(),
}
FLAG_PATH.parent.mkdir(parents=True, exist_ok=True)
with open(FLAG_PATH, "w") as f:
json.dump(flag_data, f, indent=2)
print(f"Ghost mode flag written: {FLAG_PATH}", file=sys.stderr)
Skill's behavior or capabilities extend beyond its stated purpose. Scope creep allows an agent to perform actions unrelated to its documented functionality, increasing the attack surface.
This skill is provided **as-is, with no warranties, express or implied.** There is no assurance of fitness for any particular purpose, no guarantee of data safety, and no support commitment.
By installing or using this skill, you accept full responsibility for any outcomes. You use this skill entirely at your own risk. The Author is not liable in any way for any losses, damages, or consequences — direct, indirect, incidental, or otherwise — that result from using this skill. This includes, but is not limited to, data loss, corrupted files, lost sessions, or any other damage arising from the use or inability to use this skill.
You are running a tool whose stated purpose is to permanently delete data. Use it carefully. Back up your workspace.
The subcommand is named 'completed', which implies acting on completed sessions, but its help text says 'Archive all active sessions' and the implementation also targets active sessions. This creates contradictory operator-facing intent signals about what the command is supposed to do.