Skip to content

feat: add Windows 11 support via built-in sudo#7

Open
hughesjs wants to merge 2 commits intomasterfrom
feat/windows-support
Open

feat: add Windows 11 support via built-in sudo#7
hughesjs wants to merge 2 commits intomasterfrom
feat/windows-support

Conversation

@hughesjs
Copy link
Copy Markdown
Owner

Summary

  • Adds Windows as a third supported platform using the Windows 11 24H2+ built-in sudo command with UAC elevation
  • New WindowsSudoExecutor implements IPrivilegedExecutor, executing commands via sudo cmd /c <command>
  • Windows-specific blocklist patterns: format, diskpart, bcdedit, registry system hive edits (reg add/delete HKLM\SYSTEM|SOFTWARE|SAM|SECURITY), PowerShell Remove-Item -Recurse -Force, and cipher
  • PowerShell install/uninstall scripts (scripts/install.ps1, scripts/uninstall.ps1)
  • CI pipeline: Windows added to unit test matrix + dedicated Windows build job
  • CD pipeline: Separate build-windows-binary job + zip release artifact (sudo-mcp-win-x64-vVERSION.zip)
  • Documentation updated throughout (README, SECURITY.md, CLAUDE.md)

Details

Executor

WindowsSudoExecutor follows the same pattern as PkexecExecutor (Linux) and SudoExecutor (macOS). It spawns sudo cmd /c <command> and handles Windows-specific error messages (sudo not found, access denied, UAC cancelled). Requires Windows 11 24H2+ with sudo enabled in Developer Settings.

Blocklist

Four new [GeneratedRegex] patterns with 1-second ReDoS timeout:

  • FormatDriveformat C: and variants
  • BcdeditAny — any bcdedit subcommand
  • RegSystemHivereg add/delete/import targeting HKLM\SYSTEM|SOFTWARE|SAM|SECURITY
  • PowerShellRecursiveDeletepowershell/pwsh Remove-Item -Recurse -Force (flags in any order via lookaheads)

Six new blocked binaries: diskpart(.exe), bcdedit(.exe), cipher(.exe)

CI/CD

  • Windows build is a separate job from the existing Linux/macOS matrix because the artifact path differs (SudoMcp.exe vs SudoMcp)
  • Release artifact is a .zip (not .tar.gz) since that's standard on Windows

Test plan

  • 51 unit tests pass locally (22 new Windows blocklist + 2 executor + 27 existing)
  • CI passes on all three platforms (Linux, macOS, Windows)
  • Verify Windows build job produces valid binary on windows-latest
  • Manual test on Windows 11 24H2+ with sudo enabled (if available)

🤖 Generated with Claude Code

Add Windows as a third supported platform alongside Linux and macOS.
Uses the Windows 11 24H2+ built-in sudo command with UAC elevation
for privilege escalation.

- WindowsSudoExecutor: executes commands via sudo cmd /c
- Windows blocklist patterns: format, diskpart, bcdedit, registry
  system hive edits, PowerShell Remove-Item -Recurse -Force, cipher
- DI registration with OperatingSystem.IsWindows() branch
- PowerShell install/uninstall scripts
- CI: Windows added to unit test matrix + build job
- CD: Windows x64 build + zip release artifact
- Documentation updated throughout
@hughesjs
Copy link
Copy Markdown
Owner Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Reviewed: WindowsSudoExecutor implementation, Windows blocklist patterns (format, diskpart, bcdedit, registry, PowerShell, cipher), DI registration, CI/CD pipeline changes, install/uninstall scripts, and documentation updates. Audited against CLAUDE.md rules (British spellings, XML comments, security considerations, code style), git history for regressions, prior PR feedback, and code comment compliance.

Notable observations that fell below the reporting threshold:

  • RegSystemHive regex only matches the short form HKLM\ -- the long form HKEY_LOCAL_MACHINE\ is a known bypass, consistent with the project's documented position that regex blocklists will be bypassed (SECURITY.md)
  • cmd /c quoting via ArgumentList may misbehave with commands containing double quotes (cmd.exe uses "" escaping, not \"), but this edge case needs real Windows testing to confirm

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

Extends the build-windows job to create a zip artifact, then adds a
test-install-windows job that extracts the zip, runs install.ps1, and
verifies the installed binary is on PATH and responds to --help.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant