T09 · Insecure Skill Coding Practices
- Location
scripts/gc_and_checkpoint.sh:5- Finding
Hard-Coded Workspace and Misleading Checkpoint Automation
- Content
View full analysis
Vulnerability Details
File Location:
scripts/gc_and_checkpoint.sh:5-6, 14-17; related instructions inSKILL.md:19-27
Vulnerability Type: Hard-coded environment path and incomplete security-sensitive automation
Risk Level: MediumVulnerable Code
scripts/gc_and_checkpoint.sh:5-6, 14-17:bash WORKSPACE="/Users/yang/clawd" HOT_MEMORY="$WORKSPACE/memory/hot/HOT_MEMORY.md" TIMESTAMP=$(date "+%Y-%m-%d %H:%M") echo "🚀 Starting Context Budgeting Service..." # 1. Update Decision Log in HOT_MEMORY.md # Note: This is a placeholder for the agent to fill with actual session context. # When run by the agent, the agent should have already updated the file. # 2. Trigger Physical Compaction via OpenClaw CLI echo "🧹 Triggering session compaction..." # Note: Using the validated 'openclaw' command structure openclaw sessions --active 1 > /dev/nullRelated mandatory instructions in
SKILL.md:19-27:markdown ### 2. Pre-compression Checkpointing (Mandatory) Before any compaction (manual or automatic), the agent MUST: 1. **Generate Checkpoint**: Update `memory/hot/HOT_MEMORY.md` with: - **Status**: Current task progress. - **Key Decision**: Significant choices made. - **Next Step**: Immediate action required. 2. **Run Automation**: Execute `scripts/gc_and_checkpoint.sh` to trigger the physical cleanup. ## Automation Tool: `gc_and_checkpoint.sh` Located at: `skills/context-budgeting/scripts/gc_and_checkpoint.sh`Technical Analysis
The skill mandates persistence of session-derived status, decisions, and next steps in a memory file before running the supplied script. However, the script defines an absolute, user-specific workspace path (
/Users/yang/clawd) rather than deriving the active workspace from validated configuration. This creates an unsafe and non-portable configuration that could refer to another profile or an unintended location if subsequently ...[truncated 2595 chars]- Remediation
View remediation
Remediation Suggestions
- Remove the user-specific absolute path. Obtain the workspace from an explicit command-line argument or a trusted OpenClaw configuration API.
- Canonicalize the selected path and verify that it is contained within the active workspace before reading or writing memory files.
- Implement the documented checkpoint and compaction behavior with the correct OpenClaw command rather than using a session-listing command.
- Check all command exit statuses and terminate with a nonzero status when checkpointing or compaction fails.
- Print a success message only after verifying that the requested operation completed.
- Restrict checkpoint contents to the minimum information required. Avoid persisting credentials, tokens, raw tool output, personal information, or other sensitive session data.
- Create checkpoint files with restrictive permissions, such as mode
0600, and use atomic writes to prevent partial or corrupted state. - Document the retention and deletion policy for checkpoint data, including which operation actually removes or compacts it.
- Add automated tests confirming that the script uses the active workspace, rejects out-of-scope paths, handles command failures, and performs the advertised lifecycle operation.
