aspnet / Identity

[Archived] ASP.NET Core Identity is the membership system for building ASP.NET Core web applications, including membership, login, and user data. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
1.97k stars 871 forks source link

[Question] Passwords should not be of type String ? #2051

Closed ycrumeyrolle closed 5 years ago

ycrumeyrolle commented 5 years ago

My security team escalated to me that the PasswordHasher is vulnerable to heap inspection, as the password is of type String. It should be instead a byte array / span of bytes cleared at the end of the process, as it is done by any cryptographic operation in corefx. CC @bartonjs. Same problem with any password related types (IPasswordValidator, and maybe also the IUserPasswordStore)

blowdart commented 5 years ago

So .. yes but ...

When the passwords are delivered over an HTTP request they're strings. You can pretend to add safety by turning them into a byte array, but it doesn't add anything, they've been strings already, now you have them represented in two places. It's the same problem SecureString has, byte arrays are only useful if you control the input mechanism.

So sure, in theory yes, in practice it adds nothing.

ycrumeyrolle commented 5 years ago

But what if I am controlling the input mechanism? In my case, password is a PIN typed on a randomized virtual keyboard. The http request just has the position on the keyboard, not the value. After decoding the position, I am able to provide a byte array without passing by a string.

blowdart commented 5 years ago

Then you're way outside what we expect identity to be used for.

Also, if an attacker is at the point where they can execute code to start dumping memory they're at the point where they can run anything on your server, so they can intercept requests, change responses, connect to your database and so on. This is solved by hardening your infrastructure, not by changing strings to byte arrays.