However, when the link was used, canonical_username was once again applied
So after they sent the password reset link, they called "fetchUserIdByName" again, but they passed in a username that had already been canonicalized once. Because of this bug, I wonder if password resets worked at all for users with unicode characters in their names.Another possible solution would be to assume the username given to the password reset form is already canonicalized (which would be necessarily true, as far as I understand).
EDIT: However this wouldn't solve the other bug that's been discovered here, which is that "ᴮᴵᴳᴮᴵᴿᴰ" is canonicalized differently than "BIGBIRD", thus defeating the purpose of canonicalization (for that particular case) in the first place.
DRY tells us the code for looking up a user id by user name should be written in only one place, not that the code should be called from only one place.
The mistake was assuming the name->name function was idempotent, because it wasn't.
You are right to suggest using a name->id function instead. It would not suffer the same problem because the canonical name should not be stored... it's an implementation detail!
They having nothing to do with each other.
DRY tells us the code for looking up a user id by user
name should be written in only one place, not that the
code should be called from only one place.
If you write 'canonicalize(username)' in eight different places, you are not being DRY. If you need to write 'canonicalize(username)' in eight different places, your code probably doesn't separate responsibilities properly across separate modules.As such, they have a lot to do with each other. After all, if you call code from more than one place, you are writing the calling code in more than one place. Lack of DRYness is about the fact that you are doing so. Lack af modularity is about why you need to do so.
Could the method for computing canonical usernames based on nodeprep.prepare() be salvaged? If not we would be in trouble since we use canonical usernames in various databases so that changing how to derive them in a non-backwards compatible way would be quite costly.
How else do you map username to user id?
VirtualAlloc: http://msdn.microsoft.com/en-us/library/windows/desktop/aa36...
VirtualAllocEx: http://msdn.microsoft.com/en-us/library/windows/desktop/aa36...
VirtualAllocExNuma: http://msdn.microsoft.com/en-us/library/windows/desktop/aa36...
It all started out nice and clean I'm sure, but within a few years you start to see many more than one basic interface to some things.
When a new user is created, it then gets assigned a unique user ID. The email address is assigned to that user ID.
Then, if they do a password reset on user = "bigbird", it should do the exact same lookup to find the email address.
The security bug was not really about having an improper function to do unicode translation. It was more about having different functions for the same check, simply because they were in different parts of the code.
Modular code is just so much better on all fronts, including security.