-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Update PSRP protocol to deprecate session key exchange between newer client and server #25774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4724ed3
Update PSRP protocol to deprecate session key exchange between newer …
daxian-dbw 704578a
Update the comment for remote protocol v2.4
daxian-dbw ae17b62
Use existing utility methods to convert 'SecureString' to 'byte[]' an…
daxian-dbw 9d7838c
Add CodeQL suppressions
daxian-dbw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,18 +76,27 @@ internal static class RemotingConstants | |
| { | ||
| internal static readonly Version HostVersion = PSVersionInfo.PSVersion; | ||
|
|
||
| internal static readonly Version ProtocolVersionWin7RC = new Version(2, 0); | ||
| internal static readonly Version ProtocolVersionWin7RTM = new Version(2, 1); | ||
| internal static readonly Version ProtocolVersionWin8RTM = new Version(2, 2); | ||
| internal static readonly Version ProtocolVersionWin10RTM = new Version(2, 3); | ||
| internal static readonly Version ProtocolVersion_2_0 = new(2, 0); // Window 7 RC | ||
| internal static readonly Version ProtocolVersion_2_1 = new(2, 1); // Window 7 RTM | ||
| internal static readonly Version ProtocolVersion_2_2 = new(2, 2); // Window 8 RTM | ||
| internal static readonly Version ProtocolVersion_2_3 = new(2, 3); // Window 10 RTM | ||
| internal static readonly Version ProtocolVersion_2_4 = new(2, 4); // PowerShell 7.6 | ||
|
Comment on lines
-79
to
+83
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renamed the variable names because:
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes perfect sense |
||
|
|
||
| // Minor will be incremented for each change in PSRP client/server stack and new versions will be | ||
| // forked on early major release/drop changes history. | ||
| // 2.101 to 2.102 - Disconnect support as of M2 | ||
| // 2.102 to 2.103 - Key exchange protocol changes in M3 | ||
| // 2.103 to 2.2 - Final ship protocol version value, no change to protocol | ||
| // 2.2 to 2.3 - Enabling informational stream | ||
| internal static readonly Version ProtocolVersionCurrent = new Version(2, 3); | ||
| // 2.3 to 2.4 - Deprecate the 'Session_Key' exchange. The following messages are obsolete when both server and client are v2.4+: | ||
| // - PUBLIC_KEY | ||
| // - PUBLIC_KEY_REQUEST | ||
| // - ENCRYPTED_SESSION_KEY | ||
| // The padding algorithm 'RSAEncryptionPadding.Pkcs1' used in the 'Session_Key' exchange is NOT secure, and therefore, | ||
| // PSRP needs to be used on top of a secure transport and the 'Session_Key' doesn't add any extra security. | ||
| // So, we decided to deprecate the 'Session_Key' exchange in PSRP and skip encryption and decryption for 'SecureString' | ||
| // objects. Instead, we require the transport to be secure for secure data transfer between PSRP clients and servers. | ||
| internal static readonly Version ProtocolVersionCurrent = new(2, 4); | ||
| internal static readonly Version ProtocolVersion = ProtocolVersionCurrent; | ||
| // Used by remoting commands to add remoting specific note properties. | ||
| internal static readonly string ComputerNameNoteProperty = "PSComputerName"; | ||
|
|
@@ -2158,7 +2167,7 @@ internal static bool ServerSupportsBatchInvocation(Runspace runspace) | |
| return false; | ||
| } | ||
|
|
||
| return (runspace.GetRemoteProtocolVersion() >= RemotingConstants.ProtocolVersionWin8RTM); | ||
| return (runspace.GetRemoteProtocolVersion() >= RemotingConstants.ProtocolVersion_2_2); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it would be better off as a separate commit or at a minimum pointed out that this has changed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually related to this protocol change. PowerShell has built-in support for 3 non-network transports:
For HyperV direct, we've confirmed with the HyperV team that the man-in-the-middle attacks are not possible with HyperV sockets.
For standard I/O, both client and server are local, so we should be good.
For named pipe, it's possible for a remote client to connect to named pipe, which 1) may not be intended from the beginning of this feature 2) could be problematic after
SecureStringis no longer encrypted with a session key. So, it's better off to disable remote client for it.I called it out in the PR description above. I will add more about it in the description.