Skip to content

Controller-side extension pipes (TRX, HangDump, Retry) don't authorize the AppContainer/sandboxed package SID #10819

Closed

Description

Summary

Extensions that create their own named pipe from the TestHostControllers-side process-lifetime handler (running in the controller process) currently all construct their NamedPipeServer with the overload that has no authorizedSecurityIdentities parameter, which defaults to PipeOptions.CurrentUserOnly on .NET. This means only a child process running under the exact same user token can connect.

The platform's own controller-to-test-host connection pipe (TestHostControllersTestHost.Ipc.cs) does not have this problem: it asks the registered ITestHostLauncher, when it implements ITestHostControllerConnectionAuthorizer, for the security identities that must additionally be authorized (typically an AppContainer package SID for a packaged/sandboxed test host), and passes those into its own pipe.

Extension-owned pipes never do this, so a packaged/AppContainer test host cannot connect back to them. Concretely:

  • src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxProcessLifetimeHandler.cs (BeforeTestHostProcessStartCore)
  • src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpProcessLifetimeHandler.cs
  • src/Platform/Microsoft.Testing.Extensions.Retry/RetryFailedTestsPipeServer.cs

all call the NamedPipeServer(PipeNameDescription, callback, environment, logger, task, cancellationToken) overload (no identity list), instead of the overload that accepts IReadOnlyList<string>? authorizedSecurityIdentities.

Impact

When a packaged/AppContainer test host is combined with any of these extensions in a mode that requires process isolation (e.g. --crashdump --report-trx, --hangdump, or retry with process isolation today; plain --report-trx after #10792/#10808 makes TRX controller-backed by default on all supported platforms), the extension's own named-pipe handshake from the sandboxed child can fail to connect, and the run can hang until the handshake timeout elapses or fail outright — even though the platform's own controller pipe connects fine.

Proposed fix

Give extensions a way to reuse the same authorization the platform's controller pipe already computes (via ITestHostControllerConnectionAuthorizer.GetAuthorizedSecurityIdentitiesAsync) — e.g. expose the resolved identities through the service provider, or provide a small platform-level helper extensions can call — and update TrxProcessLifetimeHandler, HangDumpProcessLifetimeHandler, and RetryFailedTestsPipeServer to pass them into their own NamedPipeServer construction. This should include acceptance coverage for a packaged/AppContainer test host combined with at least one of these extensions.

Context

Found while reviewing #10808 (making --report-trx controller-backed by default). This is a pre-existing, cross-extension platform gap — not introduced by that PR, and not specific to TRX — so it is being tracked here as a separate follow-up rather than folded into that PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/dumpCrashDump / HangDump extensions.area/server-mode-pipeMTP server mode - named pipe transport.area/trxTRX report extension.

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions