Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(safety): block PowerShell's Format-Volume and Clear-Disk -RemoveData like format C:
Dheeraj Piduru667b1d82f106
diff --git a/server/safety-floor.test.ts b/server/safety-floor.test.tsindex 50f04efd5e..d5975ec613 100644--- a/server/safety-floor.test.ts+++ b/server/safety-floor.test.ts@@ -193,6 +193,12 @@ const BLOCKED: Case[] = [['cmd.exe /c "rd /s /q C:\\Users"', "delete-system-directory", "win32"],["format C:", "format-disk", "win32"],["format D: /FS:NTFS /Q", "format-disk", "win32"],+ ["Format-Volume -DriveLetter D -FileSystem NTFS", "format-disk", "win32"],+ ["Format-Volume C", "format-disk", "win32"],+ ["Get-Partition -DiskNumber 1 | Format-Volume -FileSystem NTFS -Confirm:$false", "format-disk", "win32"],+ ['powershell -Command "Format-Volume -DriveLetter D -Force"', "format-disk", "win32"],+ ["Clear-Disk -Number 1 -RemoveData -Confirm:$false", "format-disk", "win32"],+ ["Get-Disk 2 | Clear-Disk -RemoveD", "format-disk", "win32"],// Windows: PowerShell["Remove-Item -Recurse -Force C:\\", "delete-root", "win32"],["Remove-Item C:\\Users -Recurse", "delete-system-directory", "win32"],@@ -366,6 +372,9 @@ const ALLOWED: Array<[command: string, on?: Platform | "posix"]> = [['git log --grep="rm -rf /"'],["echo ':(){ :|:& };:'"],['echo "format C:"'],+ ["Get-Volume -DriveLetter C", "win32"],+ ["Clear-Disk -Number 1", "win32"],+ ['echo "Format-Volume C"', "win32"],["# rm -rf /"],["ls -la # then rm -rf /"],["cat <<'EOF' > cleanup-notes.md\nNever run:\nrm -rf /\nEOF"],diff --git a/server/safety-floor.ts b/server/safety-floor.tsindex 493fc49692..d763af4cce 100644--- a/server/safety-floor.ts+++ b/server/safety-floor.ts@@ -660,6 +660,15 @@ function judge(command: Command, source: string, pass: Pass, mode: Mode, depth:return null;}if (program === "format") return args.some((arg) => /^[A-Za-z]:\\?$/.test(arg)) ? FORMAT_DISK : null;+ // Windows Storage module: Format-Volume formats whatever volume it is given, also one piped in; Clear-Disk erases+ // a disk's data only with -RemoveData, and refuses a disk holding data partitions without it.+ if (program === "format-volume") return FORMAT_DISK;+ if (program === "clear-disk") {+ return args.some((arg) => {+ const name = arg.split(":")[0].toLowerCase();+ return name.length >= "-removed".length && "-removedata".startsWith(name);+ }) ? FORMAT_DISK : null;+ }return null;}