Back to skill

Security audit

OpenClaw Session Guard

Security checks for vulnerabilities and agentic risk

Overview

The skill is broadly aligned with automatic OpenClaw session rotation, but it persistently scans sessions, archives recent conversation text in plaintext, and rewrites session state automatically.

Install only if you deliberately want a persistent local job to monitor OpenClaw sessions and rotate them automatically. Review or modify it first to restrict which agents are processed, protect archive permissions, redact secrets, add retention cleanup, and back up session metadata before automatic rewrites. The package also appears to be missing its LaunchAgent plist template, so installation may fail as shipped.

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/openclaw-session-rotator.sh:17
Finding
Cross-Agent Conversation Content Is Duplicated into Plaintext Archives Without Restrictive Permissions## Vulnerability Details **File Location**: `scripts/openclaw-session-rotator.sh:17, 44, 101-111, 126-160, 173-198` **Vulnerability Type**: Plaintext storage of potentially sensitive conversation data **Risk Level**: Medium ### Vulnerable Code ```bash mkdir -p "$STATE_ROOT" "$COOLDOWN_DIR" "$ARCHIVE_ROOT" "$ARCHIVE_ROOT/latest" if ! "$OPENCLAW_BIN" sessions --all-agents --json > "$TMP_SESSIONS_JSON" 2>/dev/null; then log "sessions list unavailable, skip" exit 0 fi ``` ```bash session_file="$HOME/.openclaw/agents/$agent_id/sessions/${session_id}.jsonl" [[ -f "$session_file" ]] || continue agent_archive_dir="$ARCHIVE_ROOT/$agent_id" mkdir -p "$agent_archive_dir" stamp="$(date +%Y%m%d-%H%M%S)" archive_file="$agent_archive_dir/${stamp}-${safe_key:0:10}.md" handoff_file="$agent_archive_dir/${stamp}-${safe_key:0:10}.handoff.txt" latest_file="$ARCHIVE_ROOT/latest/${agent_id}.md" python3 - "$session_file" "$archive_file" "$handoff_file" "$session_key" "$agent_id" "$pct" "$total" "$context" "$MAX_ITEMS_PER_ROLE" <<'PY' ``` ```python for raw in session_file.read_text(encoding="utf-8").splitlines(): if not raw.strip(): continue try: row = json.loads(raw) except json.JSONDecodeError: continue if row.get("type") != "message": continue ts = row.get("timestamp") if isinstance(ts, str): if first_ts is None: first_ts = ts last_ts = ts msg = row.get("message") or {} role = msg.get("role") if role not in ("user", "assistant"): continue parts = msg.get("content") or [] texts = [] for part in parts: if isinstance(part, dict) and part.get("type") == "text": t = (part.get("text") or "").strip() if t: texts.append(t) if not texts: continue merged = norm(" ".join(texts)) if role == "user ...[truncated 3897 chars]
Remediation
## Remediation Suggestions 1. Set restrictive defaults before creating any state or archive files: ```bash umask 077 ``` 2. Explicitly secure all relevant directories: ```bash install -d -m 700 "$STATE_ROOT" "$COOLDOWN_DIR" "$ARCHIVE_ROOT" "$ARCHIVE_ROOT/latest" install -d -m 700 "$agent_archive_dir" ``` 3. Create archive, handoff, map, cooldown, and temporary files with mode `0600`. After writing or copying files, enforce permissions with `chmod 600`. 4. Replace unrestricted `--all-agents` processing with an explicit, user-configured agent allowlist. Require affirmative opt-in before reading or archiving each agent's sessions. 5. Add secret redaction before archival. At minimum, detect common API-key, bearer-token, private-key, password, and credential patterns. Prefer omitting sensitive messages entirely rather than relying only on pattern matching. 6. Avoid retaining verbatim conversation content where possible. Generate a minimal structured summary that excludes credentials, personal information, and full message text. 7. Establish configurable retention limits and securely remove expired archives, handoff files, temporary session data, and stale `latest` copies. 8. Write files atomically using securely created temporary files in a private directory, apply mode `0600`, and then rename them into place. 9. Document the cross-agent collection behavior and archive locations clearly so users can make an informed decision before enabling the scheduled task.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (21)

Tool Parameter Abuse

High
Category
Tool Misuse
Content
launchctl bootout "gui/$(id -u)" "$PLIST" >/dev/null 2>&1 || true
rm -f "$PLIST"
rm -f "$HOME/bin/openclaw-session-rotator.sh"

echo "[uninstall] removed launch agent and script"
Confidence
95% 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).

Lp3

Medium
Category
MCP Least Privilege
Confidence
83% confidence
Finding
The skill exposes operational commands that invoke local shell scripts capable of reading and writing files, but it does not declare any tool scope such as permissions or allowed-tools. That creates an authorization gap: an agent or reviewer cannot easily determine the intended filesystem capabilities up front, increasing the chance of over-broad execution or unsafe invocation in a sensitive local environment.

Natural-Language Policy Violations

Medium
Confidence
87% confidence
Finding
The manifest description and operational instructions are written entirely in Chinese, including a requirement to report status to the user, but there is no indication that language is optional or based on user preference. This can violate language/locale policy when a skill effectively constrains interaction language without explicit opt-in or documented justification.

Ssd 3

Medium
Confidence
95% confidence
Finding
The rotator extracts recent user and assistant messages from the old session, writes them into archive files, and then instructs the new session to continue from that archive. This creates a deliberate natural-language data transfer channel that can propagate sensitive content into additional storage locations and future model inputs, increasing exposure and the chance of secret retention or leakage across session boundaries.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The script automatically archives recent session content into markdown and handoff files under persistent storage without any user notice, consent, retention control, or data minimization beyond truncation. Because session messages can contain secrets, personal data, or sensitive business context, this creates a privacy and confidentiality risk if local files are later accessed by other users, backup systems, sync tools, or unrelated processes.

Natural-Language Policy Violations

Medium
Confidence
98% confidence
Finding
The natural-language strings used for the handoff are entirely in Chinese, which imposes a specific language on downstream behavior. There is no opt-in, language selection, or documentation indicating that this skill is intentionally limited to Chinese-speaking users or a China-specific environment.

Missing User Warnings

Medium
Confidence
88% confidence
Finding
The script rewrites the active session mapping to point to a new session ID and resets token/accounting fields without any confirmation, transactional safety, or rollback path. This can silently alter user state and continuity, and if the operation is interrupted or races with another process, it may cause session confusion, loss of auditability, or corrupted session metadata.

Session Persistence

Medium
Category
Rogue Agent
Content
set -euo pipefail

LABEL="ai.openclaw.session.rotator"
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"

launchctl bootout "gui/$(id -u)" "$PLIST" >/dev/null 2>&1 || true
rm -f "$PLIST"
Confidence
75% 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.

Session Persistence

Medium
Category
Rogue Agent
Content
set -euo pipefail

LABEL="ai.openclaw.session.rotator"
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"

launchctl bootout "gui/$(id -u)" "$PLIST" >/dev/null 2>&1 || true
rm -f "$PLIST"
Confidence
75% 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.

Session Persistence

Medium
Category
Rogue Agent
Content
set -euo pipefail

LABEL="ai.openclaw.session.rotator"
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"

launchctl bootout "gui/$(id -u)" "$PLIST" >/dev/null 2>&1 || true
rm -f "$PLIST"
Confidence
75% 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.

Session Persistence

Medium
Category
Rogue Agent
Content
set -euo pipefail

LABEL="ai.openclaw.session.rotator"
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"

launchctl bootout "gui/$(id -u)" "$PLIST" >/dev/null 2>&1 || true
rm -f "$PLIST"
Confidence
75% 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.

Session Persistence

Medium
Category
Rogue Agent
Content
set -euo pipefail

LABEL="ai.openclaw.session.rotator"
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"

launchctl bootout "gui/$(id -u)" "$PLIST" >/dev/null 2>&1 || true
rm -f "$PLIST"
Confidence
75% 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.

Session Persistence

Medium
Category
Rogue Agent
Content
set -euo pipefail

LABEL="ai.openclaw.session.rotator"
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"

launchctl bootout "gui/$(id -u)" "$PLIST" >/dev/null 2>&1 || true
rm -f "$PLIST"
Confidence
75% 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.

Session Persistence

Medium
Category
Rogue Agent
Content
set -euo pipefail

LABEL="ai.openclaw.session.rotator"
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"

launchctl bootout "gui/$(id -u)" "$PLIST" >/dev/null 2>&1 || true
rm -f "$PLIST"
Confidence
75% 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.

Session Persistence

Medium
Category
Rogue Agent
Content
set -euo pipefail

LABEL="ai.openclaw.session.rotator"
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"

launchctl bootout "gui/$(id -u)" "$PLIST" >/dev/null 2>&1 || true
rm -f "$PLIST"
Confidence
75% 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.

Session Persistence

Medium
Category
Rogue Agent
Content
set -euo pipefail

LABEL="ai.openclaw.session.rotator"
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"

launchctl bootout "gui/$(id -u)" "$PLIST" >/dev/null 2>&1 || true
rm -f "$PLIST"
Confidence
75% 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.

Session Persistence

Medium
Category
Rogue Agent
Content
set -euo pipefail

LABEL="ai.openclaw.session.rotator"
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"

launchctl bootout "gui/$(id -u)" "$PLIST" >/dev/null 2>&1 || true
rm -f "$PLIST"
Confidence
75% 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.

Session Persistence

Medium
Category
Rogue Agent
Content
set -euo pipefail

LABEL="ai.openclaw.session.rotator"
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"

launchctl bootout "gui/$(id -u)" "$PLIST" >/dev/null 2>&1 || true
rm -f "$PLIST"
Confidence
75% 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.

Session Persistence

Medium
Category
Rogue Agent
Content
set -euo pipefail

LABEL="ai.openclaw.session.rotator"
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"

launchctl bootout "gui/$(id -u)" "$PLIST" >/dev/null 2>&1 || true
rm -f "$PLIST"
Confidence
75% 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.

Session Persistence

Medium
Category
Rogue Agent
Content
set -euo pipefail

LABEL="ai.openclaw.session.rotator"
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"

launchctl bootout "gui/$(id -u)" "$PLIST" >/dev/null 2>&1 || true
rm -f "$PLIST"
Confidence
75% 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.

Session Persistence

Medium
Category
Rogue Agent
Content
set -euo pipefail

LABEL="ai.openclaw.session.rotator"
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"

launchctl bootout "gui/$(id -u)" "$PLIST" >/dev/null 2>&1 || true
rm -f "$PLIST"
Confidence
75% 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.

Static analysis

No suspicious patterns detected.