This repository has been archived by the owner. It is now read-only.

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

Closed
ycrumeyrolle opened this Issue Nov 1, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@ycrumeyrolle
Copy link

ycrumeyrolle commented Nov 1, 2018

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)

@ycrumeyrolle ycrumeyrolle changed the title Passwords should not be of type String [Question] Passwords should not be of type String ? Nov 1, 2018

@blowdart

This comment has been minimized.

Copy link
Member

blowdart commented Nov 1, 2018

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.

@blowdart blowdart closed this Nov 1, 2018

@ycrumeyrolle

This comment has been minimized.

Copy link

ycrumeyrolle commented Nov 2, 2018

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

This comment has been minimized.

Copy link
Member

blowdart commented Nov 2, 2018

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.