tomohulk / WinSCP

WinSCP PowerShell Wrapper Module
GNU General Public License v3.0
153 stars 30 forks source link

WinSCP.SessionOptions - password security #134

Closed TomaszBobrek closed 2 years ago

TomaszBobrek commented 3 years ago

Please fill in the following fields, replacing the values inside the brackets {{ }}.

Issue Description

{{ WinSCP.SessionOptions is decrypting SecureString to plain text

I'm setting credentials to WinSCP.SessionOptions, after that WinSCP.SessionOptions.Password field should be [System.Security.SecureString] but it has decrypted password (ihmo incorrect behavior).

When I'm setting Plain_Text password to WinSCP.SessionOptions.Password field, WinSCP.SessionOptions.SecurePassword field has encrypted data from WinSCP.SessionOptions.Password (ihmo proper behavior) }}

Example

{{

$credentials = get-credential $WINSCP_options = New-WinSCPSessionOption -Hostname "PlainText_Hostname" -Protocol Sftp -Credential $credentials $WINSCP_options | fl hostname,protocol,password }}

Expected Output

{{ HostName : PlainText_Hostname Protocol : Sftp Password : System.Security.SecureString SecurePassword : System.Security.SecureString NewPassword : SecureNewPassword : }}

Actual Output

{{ > HostName : PlainText_Hostname Protocol : Sftp Password : DECRYPTED_PASSWORD_FROM_CREDENTIALS SecurePassword : System.Security.SecureString NewPassword : SecureNewPassword : }}

WinSCP-PowerShell Version

{{ Script 5.17.10.0 WinSCP }}\

Environment

{{ Windows Server 2012r2, PowerShell Version: 5.1.14409.1018 }}

tomohulk commented 2 years ago

This is an Issue/Limitation in the underlying binary from WinSCP. I cannot do anything for this.