T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:55
- Finding
- Destructive Removal of the Complete Agent Model Configuration<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 55–58 **Vulnerability Type**: Destructive configuration handling without backup, confirmation, or scoped modification **Risk Level**: Medium ### Vulnerable Code ```powershell # Remove conflicting agent override if (Test-Path $agentCfgPath) { Remove-Item $agentCfgPath -Force } ``` ### Technical Analysis The conflict-remediation workflow forcefully deletes the complete agent-level `models.json` file to remove a single potentially conflicting Bailian provider override. The file may contain unrelated provider definitions, model selections, or other agent-specific settings. The operation is not limited to `providers.bailian.baseUrl` and is performed without: - Creating a backup - Confirming the deletion with the user - Validating the file's contents or schema - Preserving unrelated configuration properties - Providing an automatic rollback mechanism This violates safe configuration-management principles. Although the path is fixed under the user's OpenClaw directory rather than being directly attacker-controlled, invoking the documented repair can cause broader configuration loss than necessary. ### Attack Path 1. An agent has a `~/.openclaw/agents/main/agent/models.json` file containing a conflicting Bailian endpoint and unrelated valid model or provider settings. 2. The user follows the skill's conflict-remediation workflow. 3. `Test-Path` confirms that the agent configuration exists. 4. `Remove-Item -Force` deletes the entire file without confirmation or backup. 5. The workflow restarts the OpenClaw gateway. 6. The agent loses all configuration stored exclusively in that file, not merely the conflicting endpoint override. ### Impact Assessment The command executes with the current user's filesystem privileges and can delete that user's complete main-agent model configuration. It does not demonstrate privilege escalation or access beyond the current account. Potential effects ...[truncated 389 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Create a timestamped backup before making any change: ```powershell $backupPath = "$agentCfgPath.$(Get-Date -Format 'yyyyMMddHHmmss').bak" Copy-Item $agentCfgPath $backupPath ``` 2. Parse the JSON and update or remove only the conflicting `providers.bailian.baseUrl` property. Preserve all unrelated providers, models, and agent settings. 3. If deletion of the complete file is genuinely required, display the affected path and request explicit user confirmation. 4. Serialize the modified configuration to a temporary file, parse it again to verify valid JSON, and then atomically replace the original file. 5. Validate routing before restarting the gateway. 6. If post-change verification fails, restore the backup automatically and report the rollback. ]]>
