In one of my code reviews I stumbled across an interesting implementation of SecureString
. Logically to hide the values in memory has merit, but my understanding of IConfiguration
is that when injected and built via the ConfigurationBuilder
a copy exists in memory already for usage. So the SecureString
though is hiding the clear text values, the configuration access automatically negates the cipher text.
Is my notion is correct, really the value is insecure and should not even use SecureString
because it is not secure to begin with-
public class Sample
{
private readonly SecureString secret;
public Sample(IConfiguration configuration) => secret = new NetworkCredentials(String.Empty,
configuration.GetSection("Api:Credentials")["secret"]).SecurePassword;
}