Skip to content

Fix the TPA in a more reliable way - #115

Merged
Aditya Patwardhan (adityapatwardhan) merged 2 commits into
PowerShell:masterfrom
daxian-dbw:tpa
Sep 17, 2026
Merged

Aditya Patwardhan (adityapatwardhan) merged 2 commits into
PowerShell:masterfrom
daxian-dbw:tpa

Conversation

@daxian-dbw

@daxian-dbw Dongbo Wang (daxian-dbw) commented Sep 14, 2026

Copy link
Copy Markdown
Member

PR Summary

Fix #114
Also fix the following PowerShell issues:

Replace the hard-coded Trusted Platform Assemblies (TPA) allow-list used by pwrshplugin.dll with a deny-list constructed from the DLLs installed alongside .NET runtime.

Motivation

The set of trusted platform assemblies differs across supported PowerShell versions, including 7.4, 7.5, and 7.6. Maintaining an explicit allow-list causes the WinRM hosting code to fall out of sync as assemblies are added, removed, or renamed.

Comparing TRUSTED_PLATFORM_ASSEMBLIES from pwsh.exe with the DLLs under $PSHOME showed that the TPA list is consistently the set of installed DLLs minus a relatively stable group of native and host binaries.

Changes

  • Enumerate *.dll files immediately under coreCLRDirectoryPath.
  • Include each discovered DLL in the TPA list unless it is a known native or host binary.
  • Match deny-list entries case-insensitively.
  • Exclude files beginning with mscordaccore_ to account for architecture- and version-specific filenames.
  • Exclude Microsoft.PowerShell.GraphicalHost.dll, which is not usable in a remoting session.
  • Include other PowerShell managed assemblies in the TPA list.
  • Remove the obsolete .ni.dll probing logic because modern PowerShell distributions no longer include native-image assemblies.
  • Remove outdated comments.
  • Add FindFirstFileA, FindNextFileA, and FindClose to the existing system-call facade so directory enumeration follows the current dependency-injection design.

This makes TPA construction resilient to assembly changes across PowerShell and .NET servicing releases while retaining a small, stable deny-list.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@daxian-dbw

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 115 in repo PowerShell/PowerShell-Native

@adityapatwardhan

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@daxian-dbw

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Comment thread src/powershell-native/nativemsh/pwrshcommon/pwrshcommon.cpp
"clrjit.dll",
"coreclr.dll",
"D3DCompiler_47_cor3.dll",
"getfilesiginforedist.dll",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also this "getfilesiginforedistwrapper.dll" ?

@daxian-dbw Dongbo Wang (daxian-dbw) Sep 17, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

getfilesiginforedistwrapper.dll is included in the TPA list of pwsh.exe, so it's not excluded here. You can find it by running [AppContext]::GetData('TRUSTED_PLATFORM_ASSEMBLIES') from pwsh.

I compared the new TPAs in the plugin and those in pwsh.exe (7.4.20, 7.5.11, and 7.6.6), only 2 are intentionally excluded from the plugin:

  • Microsoft.PowerShell.GraphicalHost.dll
  • pwsh.dll

@adityapatwardhan

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@adityapatwardhan

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

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.

System.IO.Pipelines missing from the TRUSTED_PLATFORM_ASSEMBLIES array

2 participants