-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Why is Get-AzAccessToken going to start returning a SecureString? #26847
Comments
Hi @jackmtpt thanks for reaching out. Long story short, we promote secure string to prevent the risk of unintentional exposure of plain text string, not for cryptographic reasons. PowerShell scripts are often executed in automation systems. Some of them lack comprehensive access control over logs, which when combined with unsafe programming practices, leads to the exposure of secrets. That's the problem we want to address with SecureString. Even if a SecureString is logged, it's never in plain text, hence free of risk. The reason why SecureString is unrecommended in .NET is that it's not safe cryptographically. Since Azure PowerShell is not relying on it to encrypt those data, it is unnecessary to move away from SecureString as well. |
There's better ways to do that though aren't there? e.g. via the Format.ps1xml files that specify which fields are shown by default when an object is written to the pipeline. That would prevent the token getting printed to the terminal/logs accidentally unless someone explicitly accesses |
Yes that's one option. But there are limitations that (a) as you said if someone explicitly |
For A I'd say that's up to the user - if they send For context my reason for not wanting to deal with SecureStrings here is that for some API calls you need to include the Entra ID refresh token in the body of a POST request, such as when getting an ACR refresh token via the If you still want to change the default to SecureString, would you be open to having a |
Description
Other Microsoft code is actively migrating away from
SecureString
, e.g. AzureAD/microsoft-authentication-library-for-dotnet#2437.Microsoft's own documentation about SecureString recommends that it is not used: https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-security-securestring
Apparently
Az
version 14 is going to ignore this guidance and make a breaking change to use SecureString anyway:Why?
Script or Debug output
Environment data
Module versions
Error output
The text was updated successfully, but these errors were encountered: