T09 · Insecure Skill Coding Practices
- Location
scripts/generate_report.py:150- Finding
Unsafe privileged report-file overwrite through a fixed output path
- Content
View full analysis
None: """Write report to OUTPUT_FILE.""" with open(OUTPUT_FILE, "w", encoding="utf-8") as f: f.write(content) ``` ### Technical Analysis The report destination is hard-coded inside `/root/.openclaw/workspace`, implying that the script may be executed with elevated filesystem privileges. The destination is opened in write mode without first verifying that it is a regular file owned by the expected user. Python's standard `open()` follows symbolic links. It also truncates an existing destination immediately when opened with mode `"w"`. If another user or compromised process can modify the workspace, it can replace `stock_morning_report.md` with a symbolic link to a different file. The script would then follow that link and overwrite the linked target using the permissions of the process running the report generator. There is also a time-of-check/time-of-use risk if validation is added separately without using safe file-descriptor operations. The implementation does not use exclusive creation, `O_NOFOLLOW`, restrictive permissions, or an atomic temporary-file replacement strategy. ### Attack Path 1. The report generator is configured to run with sufficient privileges to write under `/root/.openclaw/workspace`. 2. An attacker obtains write access to that workspace through another user, process, container mount, or compromised component. 3. The attacker removes or renames `stock_morning_report.md`. 4. The attacker creates a symbolic link named `stock_morning_report.md` pointing to a file writable by the report generator. 5. The Skill invokes `save_report()`. 6. `open(... ...[truncated 1037 chars]- Remediation
View remediation
