T09 · Insecure Skill Coding Practices
- Location
scripts/delete_agent.py:128- Finding
Untrusted workspace configuration can cause recursive deletion of unrelated user data
- Content
View full analysis
Vulnerability Details
File Location:
scripts/delete_agent.py, lines 70-74 and 128-136
Vulnerability Type: Insufficient validation of a destructive filesystem target
Risk Level: HighVulnerable Code
python if target: removed["agent"] = True cfg["agents"]["list"] = new_agents removed["workspace"] = target.get("workspace")python if args.delete_workspace and removed["workspace"]: wp = Path(removed["workspace"]).expanduser() # guardrail: only allow deleting workspaces under user's home and matching claw-* naming validate_within(Path.home(), wp, "workspace") if not wp.name.startswith("claw-"): raise SystemExit(f"Error: refusing unsafe workspace delete (expected claw-*): {wp}") if wp.exists(): shutil.rmtree(wp)Technical Analysis
The recursive deletion target is taken directly from the mutable
workspacefield in~/.openclaw/openclaw.json. The implemented checks only establish that the resolved path is beneath the current user's home directory and that its final component starts withclaw-.These conditions do not prove that the directory belongs to the selected agent. Consequently, any unrelated directory beneath the user's home whose basename begins with
claw-can satisfy the guardrails. If configuration integrity has been compromised or the workspace value was incorrectly assigned,shutil.rmtreerecursively removes that unrelated directory.The path-resolution check does protect against straightforward traversal outside the home directory and against symlink targets resolving outside it. However, it does not provide ownership or agent-to-workspace binding validation.
Attack Path
- An attacker or another process with permission to modify
~/.openclaw/openclaw.jsonchanges the selected agent'sworkspacevalue to an unrelated directory such as/home/user/projects/claw-important. - The user follows the ...[truncated 826 chars]
- An attacker or another process with permission to modify
- Remediation
View remediation
Remediation Suggestions
- Do not authorize deletion based only on a name prefix.
- Define a dedicated canonical workspace root and require all removable workspaces to be direct children of that root.
- Derive the expected workspace path from the validated agent identifier where possible instead of trusting a mutable configuration path.
- Store and verify an ownership marker inside the workspace, containing the corresponding agent ID.
- Resolve the path before any destructive operation and reject symlinks, the home directory itself, filesystem roots, and paths that do not match the authoritative agent-to-workspace mapping.
- Include the canonical target path in dry-run output and require path-specific confirmation for workspace deletion.
- Consider moving the workspace into a recoverable quarantine or trash location before permanent removal.
Example hardening logic should require all of the following: the canonical path is beneath the dedicated workspace root, its expected name exactly matches the selected agent, its ownership marker matches
agent_id, and it is not a symbolic link.
