Repository navigation
ConvertFrom-SecureString is broken on Linux #1654
Copy link
Copy link
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productOS-LinuxOS-macOSResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Milestone
Description
Steps to reproduce
- Install PowerShell on Ubuntu 14.04
- Launch PowerShell
- Run the following:
$password = Convertto-Securestring -String "PowerShellRocks!" -AsPlainText -Force
ConvertFrom-SecureString $password Expected behavior
No error
Actual behavior
The following error is thrown
PS /home/chythu/temp> ConvertFrom-SecureString $password ConvertFrom-SecureString : Unable to load DLL 'CRYPT32.dll': The specified
module could not be found.
(Exception from HRESULT: 0x8007007E)
At line:1 char:1
- ConvertFrom-SecureString $password
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (:) [ConvertFrom-SecureString], Dl
lNotFoundException
- FullyQualifiedErrorId : System.DllNotFoundException,Microsoft.PowerShell
.Commands.ConvertFromSecureStringCommand
Environment data
Name Value
---
PSVersion 5.1.10032.0
PSEdition PowerShellCore
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 3.0.0.0
GitCommitId v6.0.0-alpha.7
CLRVersion
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Updates by Travis Plunk (@TravisEz13) on 2016-04-10
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.2
PSEdition Core
GitCommitId v6.0.2
OS Darwin 17.5.0 Darwin Kernel Version 17.5.0: M...
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Workaround
The following works
# you should generate your own key
$Key = (3,4,2,3,56,34,254,222,1,1,2,23,42,54,33,233,1,34,2,7,6,5,35,43)
$s | ConvertFrom-SecureString -Key $Key Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productOS-LinuxOS-macOSResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Activity
oising commentedon Aug 5, 2016
https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/security/SecureStringHelper.cs#L449
Seems to be CoreCLR that is lacking.
hiteshraigandhi commentedon Aug 10, 2016
Talked @KrishnaV-MSFT This is not needed for Azure demo. Moving it out of Alpha.10
jaredmichaelwilliams commentedon Aug 18, 2016
Came across the same error on MacOS 10.12 Beta (16A270f)
Was just messing around got this:
Result:
35359595 commentedon Oct 2, 2016
Hi,
same library error when trying to use mapped cert: psdrive:
Get-ChildItem Cert:/LocalMachine/Error:
vors commentedon Oct 2, 2016
Ivan Temchenko (@35359595) good finding! The error definitely should be friendlier. On Linux and macOS
Cert:/provider needs some re-thinking. The way these two systems approach storing certificates are completely different from each other and windows.ChrisMagnuson commentedon Jan 4, 2017
Fyi, 16.04.1 with PowerShell v6 alpha 14 still has this same issue
ngetchell commentedon Feb 12, 2017
This is holding me back from bringing my modules over to Linux. I'd like to be able to store Web API keys securely on all OSes, not just Windows.
76 remaining items
iSazonov commentedon Mar 20, 2019
I added the link for information only.
Essentially:
SteveL-MSFT commentedon Mar 20, 2019
Early on, the @PowerShell/powershell-committee discussed introducing a
SensitiveStringto replace the functional need ofSecureStringeven though both are not secure (theSecureStringtype would still be needed for backwards compat). A type (whether "Sensitive" or "Secure" is needed to indicate to PowerShell to prompt without echoing the input so it's used more than just for remoting. As for the original issue of this bug, this has been fixed (you don't get an error anymore), just keep in mind the SecureString is internally in plain text.vchrizz commentedon Mar 21, 2019
thanks for the update, looks promising!
may we ask for an approximately timeframe when to expect to be able to utilize this (e.g. in microsoft-debian-stretch-prod debian repository)?
rmbolger commentedon Mar 21, 2019
Does anyone have a link to the fix or know what release version it will be available in? I'm still getting crypt32.dll errors in powershell_6.1.3-1.ubuntu.16.04_amd64.deb (same deal with the 6.2.0-rc.1 preview package).
I'm also curious how this fix affects Import/Export-CliXml when the data to be serialized contains SecureString or PSCredential objects.
iSazonov commentedon Mar 21, 2019
Ryan Bolger (@rmbolger) Could you please check with latest build (6.2.0-RC)?
rkeithhill commentedon Mar 21, 2019
I'm seeing the same as Ryan Bolger (@rmbolger)
iSazonov commentedon Mar 21, 2019
The cmdlets load directly the CRYPT32.dll
PowerShell/src/Microsoft.PowerShell.Security/security/SecureStringCommands.cs
Line 169 in 8763c0b
PowerShell/src/System.Management.Automation/security/SecureStringHelper.cs
Line 158 in 8763c0b
PowerShell/src/System.Management.Automation/security/SecureStringHelper.cs
Line 449 in 8763c0b
PowerShell/src/System.Management.Automation/security/SecureStringHelper.cs
Line 590 in 8763c0b
Enable `SecureString` cmdlets for non-Windows (#9199)
Enable `SecureString` cmdlets for non-Windows (#9199)
Enable `SecureString` cmdlets for non-Windows (PowerShell#9199)