You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CRITICAL BUG: Unset $env:*/* may silently expand to drive root and BYPASS external_directory permission, causing entire windows drive got destroyed #24468
When using $env:WorkDir in PowerShell commands (e.g. Remove-Item -Recurse -Force $env:WorkDir\*), if the environment variable is not set, it resolves to an empty string. This causes the path to become \* which targets the root of the current drive, potentially wiping all user files on that drive.
opencode's external_directory protection is designed to confine file operations to a designated workspace directory. However, this safeguard is completely bypassed if using $env:WorkDir\*.
In the incident, my D: drive was completely wiped because the command operated at D:\* instead of the intended subdirectory, with zero interference from the external_directory guard.
Plugins
None
OpenCode version
1.14.25
Steps to reproduce
Ensure $env:WorkDir is not set in the PowerShell session.
Ask your model run the command: Remove-Item -Recurse -Force $env:WorkDir\*. (Direct requests may be rejected, requiring adjustments to prompt words or more attempts.)
Observe that the command runs without interception.
Your report describes a distinct vector (unset PowerShell environment variable expanding to drive root), so this may warrant its own fix, but the above issues share context and may be worth referencing.
Activity
github-actions commentedon Apr 26, 2026
This issue might be related to existing issues about
external_directorypermission bypasses. Please check:external_directorypermission bypassed by bash wildcard rules (different bypass mechanism, same guard)external_directory: "deny"not enforced when running OpenCode from Git Bash on Windows (Windows-specific bypass)Your report describes a distinct vector (unset PowerShell environment variable expanding to drive root), so this may warrant its own fix, but the above issues share context and may be worth referencing.
github-actions commentedon Jul 4, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.