T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:143
- Finding
- Overbroad Report Cleanup Deletes All Matching Reports<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:143` **Vulnerability Type**: Unsafe destructive file operation **Risk Level**: Medium ```bash rm memory/capital_market_report_*.md ``` ### Technical Analysis The Skill states that only reports older than 24 hours should be removed, but the prescribed command contains no age filter. Shell wildcard expansion causes every matching report in the relative `memory` directory to be deleted, including the report just generated and all reports required for the 24-hour Delta comparison. The relative path also makes the affected directory dependent on the Agent's current working directory. The command runs with the invoking user's privileges and does not require elevated access, but it exceeds the minimum file-deletion scope required by the declared retention policy. ### Attack Path 1. The Agent generates and saves a new capital-market report. 2. The Agent follows the mandatory cleanup instruction in `SKILL.md`. 3. The shell resolves `memory/capital_market_report_*.md` relative to the current working directory. 4. `rm` deletes every matching file without checking modification time. 5. The current report and historical Delta baseline may be irreversibly lost. No external attacker-controlled input is necessary; execution of the documented workflow is sufficient to trigger the issue. ### Impact Assessment The operation can delete all matching report files accessible to the current user in the resolved `memory` directory. It does not grant additional privileges or system-wide access, but it can cause data loss, invalidate report history, and prevent accurate 24-hour Delta analysis. ]]>
- Remediation
- <![CDATA[ ## Remediation Suggestions Use an absolute, explicitly scoped directory and apply an age condition: ```bash REPORT_DIR="$HOME/.openclaw/workspace-group/memory" find "$REPORT_DIR" -maxdepth 1 -type f \ -name 'capital_market_report_*.md' \ -mmin +1440 \ -delete ``` Additional hardening measures: 1. Verify that `REPORT_DIR` exists and resolves to the expected directory before deletion. 2. Preview the selected files with `-print` before enabling `-delete`. 3. Exclude the newly generated report explicitly if necessary. 4. Avoid making destructive cleanup a prerequisite for publishing the report. 5. Log every deleted path to support recovery and incident investigation. 6. Consider moving expired reports to a quarantine or archive directory instead of immediately deleting them. ]]>
