T05 · Unauthorized Access and Privilege Escalation
- Location
REFERENCES.md:467- Finding
Destructive System-Wide Temporary Directory Cleanup
- Content
View full analysis
Vulnerability Details
File Location:
REFERENCES.md, line 467
Vulnerability Type: Destructive cleanup command affecting a shared system directory
Risk Level: HighVulnerable Code:
bash # Clean temporary files rm -rf /tmp/*Technical Analysis
The troubleshooting instructions recommend recursively deleting every visible entry under the shared
/tmpdirectory. This operation is not restricted to files created by OpenCode and does not verify ownership, age, file type, or whether an entry is currently in use./tmpcommonly contains files, directories, sockets, locks, and intermediate data belonging to unrelated applications and users. When the command is run by an account with sufficient permissions, it crosses the legitimate cleanup boundary of this skill and may remove resources belonging to other processes. The use of recursive forced deletion suppresses confirmation and attempts to continue without interactive safeguards.Attack Path
- A user follows the documented disk-space troubleshooting procedure.
- The user executes
rm -rf /tmp/*, potentially from a privileged shell or an account with access to other temporary resources. - The command recursively removes accessible entries regardless of which application or user created them.
- Applications relying on deleted temporary files, sockets, or state may fail, lose data, or behave unpredictably.
No privilege is acquired by the command itself. The damage is limited by the permissions of the invoking account, but execution with elevated privileges substantially increases the affected scope.
Impact Assessment
Potential consequences include:
- Deletion of temporary data belonging to unrelated applications or users.
- Interruption of active services and local processes.
- Loss of unsaved or in-progress application data.
- Removal of sockets, lock files, and temporary state.
- Local denial of service.
- System-wi ...[truncated 53 chars]
- Remediation
View remediation
Remediation Suggestions
Remove the system-wide deletion instruction and replace it with narrowly scoped cleanup logic:
- Restrict deletion to a dedicated OpenCode cache or temporary directory.
- Resolve and validate the target path before deletion.
- Verify that the directory is owned by the current user.
- Refuse empty paths,
/,/tmp, home directories, and other shared locations. - Display the files selected for deletion before modifying them.
- Require explicit confirmation for recursive deletion.
- Prefer age-based deletion of known OpenCode artifacts.
A safer example is:
bash CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/opencode" if [ -d "$CACHE_DIR" ] && [ -O "$CACHE_DIR" ]; then find "$CACHE_DIR" -mindepth 1 -maxdepth 1 -print find "$CACHE_DIR" -mindepth 1 -maxdepth 1 -mtime +7 -delete fiThe implementation should still confirm that the resolved path is the expected application-specific directory before deletion.
