Skip to content

Fix key exchange hang for outofproc transports - #11380

Merged
Andrew (anmenaga) merged 6 commits into
PowerShell:masterfrom
PaulHigin:fix-outofproc-transport-key-hang
Dec 18, 2019
Merged

Andrew (anmenaga) merged 6 commits into
PowerShell:masterfrom
PaulHigin:fix-outofproc-transport-key-hang

Conversation

@PaulHigin

@PaulHigin Paul Higinbotham (PaulHigin) commented Dec 17, 2019 •

Copy link
Copy Markdown
Contributor

PR Summary

This PR fixes the remoting key exchange hang in OutOfProc transport connections, when transferring SecureString objects.
Fixes issue: #259

PR Context

When a SecureString object is transferred over the remoting layer, a key exchange algorithm is lazily run so that the contents of the SecureString can be encrypted. This is not strictly necessary since both WinRM and SSH remoting channels already encrypt data on the wire by default. But the key exchange must remain for compatibility reasons.

The hang occurs when the target sends an encrypted SecureString object to the client for the first time. The client begins a key exchange handshake with the target so that it can handle the object. This works fine for WinRM based remote connections because the client processes session and command protocol messages on different threads. But the OutOfProc based transport implementations process client protocol messages on a single thread, and the lazily initiated key exchange results in a deadlock.

The fix is to update the OutOfProc transport manager base class to detect and process command and session client protocol messages on separate threads.

This is not a low risk change since it affects four remote implementations that are based on the OutOfProc transport: background jobs, PowerShellDirect, named pipes, SSH.

Repro Steps:

$session = New-PSSession -Host localhost
Invoke-Command $session { $ss = ConvertTo-SecureString "Hello" -AsPlainText -Force }
Invoke-Command $session { $ss }

#Result
Hang

#Expected
SecureString object to be returned.

PR Checklist

…essing threads for session and command protocol messages.

@SteveL-MSFT Steve Lee (SteveL-MSFT) left a comment

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.

One NIT

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Dec 17, 2019 •

Copy link
Copy Markdown
Member

Paul Higinbotham (@PaulHigin) merge upstream/master tp pick up fix for the nulconditional tests

@TylerLeonhardt

Copy link
Copy Markdown
Member

This will probably fix Azure/azure-functions-powershell-worker#259

@daxian-dbw

Copy link
Copy Markdown
Member

Will this issue be considered for GA? Otherwise, the Azure Function issue won't really be resolved until 7.1, which maybe a year later.

@SteveL-MSFT Steve Lee (SteveL-MSFT) added this to the GA-consider milestone Dec 18, 2019
@anmenaga
Andrew (anmenaga) merged commit 76a009e into PowerShell:master Dec 18, 2019
@anmenaga Andrew (anmenaga) added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Dec 18, 2019
@PaulHigin
Paul Higinbotham (PaulHigin) deleted the fix-outofproc-transport-key-hang branch December 18, 2019 22:11
@TylerLeonhardt

TylerLeonhardt commented Dec 20, 2019 •

Copy link
Copy Markdown
Member

I would love for it to make it into GA.

@daxian-dbw Dongbo Wang (daxian-dbw) added this to the 7.0.0-rc.2 milestone Jan 11, 2020
@invisibleaxm

Copy link
Copy Markdown

Hello, just trying to understand, i see GA-approved for this PR, does it mean it will also solve for the Azure Functions issue ? (Azure/azure-functions-powershell-worker#259)

@daxian-dbw

Copy link
Copy Markdown
Member

Yes, this will address that issue, as soon as the Azure Functions team adopts PowerShell 7 in their runtime.

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

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants