Skip to content

Conversation

@YuliiaKovalova
Copy link
Member

@YuliiaKovalova YuliiaKovalova commented Aug 21, 2025

Fixes #12385

Context

MSBuild handshake failures occur when an elevated MSBuild.exe process (running on .NET Framework) attempts to communicate with dotnet.exe child processes (running on .NET). The issue stems from a platform compatibility problem where:

  • MSBuild.exe includes HandshakeOptions.Administrator flag when running elevated (due to FEATURE_SECURITY_PRINCIPAL_WINDOWS being available)
  • dotnet.exe child processes cannot include this flag because WindowsPrincipal/WindowsIdentity APIs are not available in modern .NET runtimes
  • This creates a handshake mismatch even when both processes have identical elevation levels (High Integrity)

Changes Made

  • Updated the elevation check in GetHandshakeOptions() to make elevation validation avaialble for .NET task host scenarios

Testing

  • Tested handshake completion without elevation flag mismatches

Copilot AI review requested due to automatic review settings August 21, 2025 13:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a handshake failure between elevated MSBuild.exe processes (running on .NET Framework) and dotnet.exe child processes (running on .NET). The issue occurs because MSBuild.exe can check for administrator privileges using Windows APIs that are unavailable in modern .NET runtimes, causing handshake mismatches.

  • Modified elevation check logic to skip administrator privilege validation for .NET task host scenarios
  • Added conditional guard to prevent HandshakeOptions.Administrator flag when communicating with .NET endpoints
  • Maintains security intent while resolving cross-platform compatibility issues

@YuliiaKovalova YuliiaKovalova changed the title Remove elevation check for net host Adjust elevation check for net host Aug 21, 2025
@YuliiaKovalova YuliiaKovalova force-pushed the dev/ykovalova/fix_handshake_for_admin branch from 56e3ed3 to 67176ee Compare August 21, 2025 14:40
@YuliiaKovalova YuliiaKovalova self-assigned this Aug 21, 2025
@YuliiaKovalova YuliiaKovalova merged commit 768d9e1 into main Aug 22, 2025
9 checks passed
@YuliiaKovalova YuliiaKovalova deleted the dev/ykovalova/fix_handshake_for_admin branch August 22, 2025 13:56
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.

Task Host - fix the spawned project privileges

4 participants