Back to skill

Security audit

Context Management

Security checks for vulnerabilities and agentic risk

Overview

This skill is mostly coherent context-management guidance, but users should be aware it can persist checkpoint text and, with approval, change OpenClaw gateway context settings.

Install only if you want an agent to manage context pressure and compaction recovery. Treat recovered checkpoint or daily-log text as notes rather than trusted commands, review any proposed gateway config changes carefully, and require the promised backup and rollback details before approving a restart.

Vulnerability Patterns
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • 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
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Findings (1)

T02 · Agent Memory Poisoning

Warning
Location
SKILL.md:91
Finding
Untrusted checkpoint content can poison persistent agent state<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:91-96`; supporting checkpoint writer at `scripts/context-checkpoint.sh:15-41` **Vulnerability Type**: Persistent agent-state poisoning **Risk Level**: Medium ### Vulnerable Code `SKILL.md:91-96`: ```markdown After compaction or `/new`: 1. Read `.context-checkpoint.md` if it exists 2. Read today's daily log if the workspace has one (e.g. `memory/{today}.md`) 3. Resume from the checkpoint's "Next Steps" 4. Delete the checkpoint file after restoring context ``` `scripts/context-checkpoint.sh:15-41`: ```bash write) TASK="${3:-No active task described}" STATE="${4:-No state captured}" DECISIONS="${5:-None recorded}" FILES="${6:-None recorded}" NEXT="${7:-No next steps defined}" DATE=$(date -u +"%Y-%m-%d %H:%M UTC") cat > "$CHECKPOINT" <<EOF # Context Checkpoint — $DATE ## Active Task $TASK ## Key State $STATE ## Decisions Made This Session $DECISIONS ## Files Changed $FILES ## Next Steps $NEXT EOF echo "Checkpoint written: $CHECKPOINT" ;; ``` ### Technical Analysis The checkpoint script persists caller-controlled text in `.context-checkpoint.md`, including the `Next Steps` field. The post-compaction recovery procedure subsequently instructs the agent to read this mutable workspace file and resume from its contents without validating provenance, integrity, or whether embedded directives should be treated only as untrusted data. A process or user with workspace write access could create or alter the checkpoint before recovery. Because the checkpoint survives compaction and new-session boundaries, malicious directives could continue influencing the agent after the original conversational context has been compressed or discarded. The issue does not involve shell command injection: the supplied values are written through a here-document rather than executed by the shell. The vulnerability instead exists at the agent instruction and persistent-state trust boundary. ### Att ...[truncated 1330 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Explicitly classify checkpoint files and daily logs as untrusted data. State that instructions embedded in them must never be executed automatically. 2. Require the agent to summarize recovered state and obtain user confirmation before acting on recovered `Next Steps`. 3. Validate checkpoints against a strict schema and reject unexpected sections, instruction-like content, or malformed fields. 4. Bind checkpoints to the originating workspace and session using metadata such as a session identifier, creation timestamp, and normalized workspace path. 5. Add integrity protection where feasible, such as a keyed message authentication code stored outside the writable workspace. 6. Refuse to read or overwrite a checkpoint if the path is a symbolic link or resolves outside the expected workspace. 7. Create checkpoint files atomically with restrictive permissions, for example by writing to a securely created temporary file, setting mode `0600`, and renaming it into place. 8. Record and display the checkpoint's origin, modification time, and integrity status during recovery. 9. Treat recovered actions as contextual notes rather than authoritative instructions; re-evaluate every action against the current user request and applicable safety policy. ]]>
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (7)

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding
The declared description presents a multi-purpose context management skill centered on analyzing context usage, informing spawn-policy decisions, and handling compaction/handoff workflows. The supplied code only implements checkpoint persistence: writing a markdown file, reading it back, and deleting it. While checkpoint handling aligns with the post-compaction restoration portion of the description, the major advertised capabilities—context consumption management, runway estimation, identifying context usage sources, and sub-agent spawn policy enforcement—are absent. This is a material description/behavior mismatch because the actual code covers only a narrow subset of the declared purpose.

Self-Modification

High
Category
Rogue Agent
Content
echo "Actions:"
    echo "  write  Write a checkpoint file before compaction or /new"
    echo "  read   Read existing checkpoint (for post-compaction recovery)"
    echo "  clear  Remove checkpoint after consuming it"
    echo ""
    echo "For complex content, write the checkpoint file directly instead of"
    echo "using this script — multiline content doesn't work well as arguments."
Confidence
70% confidence
Finding
Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Description-Behavior Mismatch

Medium
Confidence
92% confidence
Finding
The skill is presented as context-window management, but later expands into modifying gateway configuration and restarting the gateway. That scope expansion can mislead users or higher-level agents into granting operational authority they did not intend, increasing the chance of unauthorized or disruptive system changes.

Context-Inappropriate Capability

Medium
Confidence
94% confidence
Finding
This skill gives the agent procedures to alter gateway configuration, create rollback artifacts, and orchestrate restarts, which are privileged operational actions unrelated to basic context management. If followed by an autonomous or over-permissive agent, it could change runtime behavior, disrupt service, or weaken safety controls under the guise of routine context tuning.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
## How to Restart the Gateway
Depends on local setup — check which applies:
- CLI (most common): openclaw gateway restart
- systemd service: sudo systemctl restart <service-name>
- Manual process: kill the gateway process, then: openclaw gateway start

## How to Check Health
Confidence
78% confidence
Finding
The document includes a root-privileged restart path using sudo, which normalizes elevated execution in a general-purpose skill. While not itself executable code, embedding privileged operational commands in an agent skill increases the risk that an agent or user invokes unnecessary elevation, potentially affecting system integrity or availability.

Session Persistence

Medium
Category
Rogue Agent
Content
mode: "safeguard",           // Chunked summarisation — recommended
  reserveTokensFloor: 20000,   // Compact when this many tokens remain free
  memoryFlush: {
    enabled: true,              // Save state to disk before compaction
    softThresholdTokens: 10000  // Start flush this far from limit
  }
}
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.

Missing User Warnings

Low
Confidence
91% confidence
Finding
This is a markdown file, so SQP-2 applies to user-facing documentation. Lines L83-L87 direct the user to modify a configuration file and restart a service, which can affect system behavior or availability, but the section does not include a localized warning or caution about potential breakage if changes are incorrect.

Static analysis

No suspicious patterns detected.