Comment On Uniquely Secure

If you haven't had the opportunity to work on a behemoth application that requires more full-time production support developers than most companies employ, then you've missed out on a lot of fun. In these systems, trying to find quality code is like trying to find a needle in a stack of hay other needles ... while blindfolded ... with your feet. Now as much as I'd like to feature such an application, I suspect that most readers would stop reading after the eightieth page or so. Instead, I'll present a single line of code representative of the entire system Kico Zaninetti came to maintain ... [expand full text]
« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Re: Uniquely Secure

2006-05-10 14:18 • by adasd
fist!

Re: Uniquely Secure

2006-05-10 14:21 • by Joe
Why doesnt anyone scream Second!!

Re: Uniquely Secure

2006-05-10 14:22 • by Albatross
72118 in reply to 72113
secondist!

Re: Uniquely Secure

2006-05-10 14:23 • by Enric Naval

They probably thought that it was more efficient than actually doing a select to check for existing passwords, adn then doing an update



Oh, wait a minute, this means that you can't have the same password for two different users? I was expecting a message like "User XXXX is already using this password" :)



Oh, and I was the one doing the "fist!" first reply today. I just saw "0 replies" and I had to do it.... I had no time to login. I just typed something on the name field so it wouldn't complain


Re: Uniquely Secure

2006-05-10 14:24 • by Bus Raker
Sweet , I know the password.  What's the username?

Re: Uniquely Secure

2006-05-10 14:24 • by ammoQ
The real WTF is that the error message does not include the account name with the already existing password, so the user has no easy possibilty to verify the correctnes of the error message.


;-)

Re: Uniquely Secure

2006-05-10 14:25 • by ammoQ
72122 in reply to 72121
ammoQ:
The real WTF is that the error message does not include the account name with the already existing password, so the user has no easy possibilty to verify the correctnes of the error message.


;-)


Ooops, I'm obviously too slow

Re: Uniquely Secure

2006-05-10 14:25 • by only lamers claim first
72123 in reply to 72119
doing the whole fist thing is stupid.

Re: Uniquely Secure

2006-05-10 14:25 • by JR
Alex Papadimoulis:
if (errMsg.indexOf("Violation of UNIQUE KEY constraint 'UQ__mbrs_pwd'") != -1)

return "The password entered is already in use. Please enter another.";


He should have said:


if (errMsg.Contains("Violation of UNIQUE KEY constraint 'UQ__mbrs_pwd'"))


  return "The password entered is already in use by " + username + ". Please enter another, or have them change their password now.";


Some people...


 

Re: Uniquely Secure

2006-05-10 14:25 • by HatTrick
Hmmmm boy doesn't that make a hackers life easier.

Re: Uniquely Secure

2006-05-10 14:30 • by Brendan Kidwell
if (errMsg.indexOf("Violation of UNIQUE KEY constraint 'UQ__mbrs_pwd'") != -1)

return "The password entered is already in use. Please enter another.";
debug.writeLn("User " + user +
" successfully set password to '" + password + "'.");

Re: Uniquely Secure

2006-05-10 14:32 • by Jojosh_the_Pi
72129 in reply to 72125
HatTrick:
Hmmmm boy doesn't that make a hackers life easier.


It's not really an issue, because the hacker still doesn't know which user name goes with the password!


Re: Uniquely Secure

2006-05-10 14:35 • by headhigh
72130 in reply to 72125
Yeah, I mean obfuscation, DUH!

"We won't tell you why we don't like that password, but we strongly suggest you choose another one."

Re: Uniquely Secure

2006-05-10 14:35 • by R.Flowers
Also, what about depending on the comparison of the error message to a hard-coded stirng? Of course, if the error message changed, thus breaking the function, everyone would be better off...

Re: Uniquely Secure

2006-05-10 14:37 • by Paul
72132 in reply to 72129
But now you have the private half of the puzzle, finding the more public half (the username) will be easier. In addition, the password may be a clue as to what the username is. This is a good WTF.

Re: Uniquely Secure

2006-05-10 14:38 • by apathes
Alex Papadimoulis:

 ... while blindfolded with your feet



WTF? ;-)

Re: Uniquely Secure

2006-05-10 14:39 • by marvin_rabbit
72134 in reply to 72119
Enric Naval:

Oh, and I was the one doing the "fist!" first reply today. I just saw "0 replies" and I had to do it.... I had no time to login. I just typed something on the name field so it wouldn't complain


The real WTF here is that some ass-hat would actually fess up to that.  (And not just admit it, but want to claim it as an honor!)

Re: Uniquely Secure

2006-05-10 14:41 • by shaggz
A database vendor adds whitespace/colon/period to the format of an error message and the entire application goes down the toilet.  Brillant!


Re: Uniquely Secure

2006-05-10 14:43 • by BtM

Why is there a unique constraint on passwords?  Surely they're not being used as keys anywhere, are they?  If so, doesn't that cause problems when the user changes their password?  Never mind the security implications...


I sense layers of WTFery beneath this snippet.

Re: Uniquely Secure

2006-05-10 14:45 • by agent86
72138 in reply to 72132
Anonymous:
But now you have the private half of the puzzle, finding the more public half (the username) will be easier. In addition, the password may be a clue as to what the username is. This is a good WTF.


It seems to me that if the user is permitted to choose both the username AND the password, there is no guaranteed way to ensure uniqueness, without tipping the hand.

I guess that's why Banks use account numbers, and my Hotmail account was something like JoeBlow753

Captcha = image, random

Re: Uniquely Secure

2006-05-10 14:46 • by kipthegreat
Alex Papadimoulis:
if (errMsg.indexOf("Violation of UNIQUE KEY constraint 'UQ__mbrs_pwd'") != -1)

return "The password entered is already in use. Please enter another.";



It's funny.. when I read this, I thought the wtf was the first line, determining what kind of error you have based on an error message rather than some kind of error code (what happens when they sell a customer running their database in German?).  I totally didn't catch the much bigger WTF of what the error message was saying.

Aside from that, there's also the wtf that the password is stored in the database in plain-text, rather than using an md5 hash of the password or something like that at the least, and adding some salt characters would be even better.

Three wtfs from two lines of code.  Not exactly a record here. :)

Re: Uniquely Secure

2006-05-10 14:47 • by kipthegreat
72141 in reply to 72139
kipthegreat:
Alex Papadimoulis:
if (errMsg.indexOf("Violation of UNIQUE KEY constraint 'UQ__mbrs_pwd'") != -1)

return "The password entered is already in use. Please enter another.";



It's funny.. when I read this, I thought the wtf was the first line, determining what kind of error you have based on an error message rather than some kind of error code (what happens when they sell a customer running their database in German?).  I totally didn't catch the much bigger WTF of what the error message was saying.

Aside from that, there's also the wtf that the password is stored in the database in plain-text, rather than using an md5 hash of the password or something like that at the least, and adding some salt characters would be even better.

Three wtfs from two lines of code.  Not exactly a record here. :)


Meant to say-   what happens when they sell to a customer running their database in German?

Re: Uniquely Secure

2006-05-10 14:50 • by xrT

checking for specific error messages are not good practice...
they're easily misspelled...[:P]

Re: Uniquely Secure

2006-05-10 14:51 • by codeman
72143 in reply to 72137
Anonymous:

Why is there a unique constraint on passwords?  Surely they're not being used as keys anywhere, are they?  If so, doesn't that cause problems when the user changes their password?  Never mind the security implications...


I sense layers of WTFery beneath this snippet.



As someone who has worked on (read: inherited) monstrously sized applications, I have, sadly, frequently seen this sort of thing. Apparently, the less experienced developers had no time to develop a comprehensive error handling paradigm (eg: exceptions), so everything just returns a String, and then its contents are strcmp'd to see if it contains some magic words, thus indicating an error. You fix stuff like this as you encounter it, but it's like trying to sweep the tide back out to sea. <cries>

Re: Uniquely Secure

2006-05-10 14:53 • by marvin_rabbit
I'm just trying to imagine the GMail (or other such service) sign-up process if THAT required a unique password:
<sound of typing:>
"secret", no.
"password", no.
"07-04-1776", no.
"asdfasdfasdf", no.

"wtf?", no.

"Reginauld G. Cooper was here", no.
"Reginauld G. Cooper was THERE", no.
"are there any f---ing paswords left?", no.
"spacemonkey", no.
"deadbabyducks", no.
"painfullrectalitch", no.
"superbassamatic76", no.

Re: Uniquely Secure

2006-05-10 14:55 • by jspenguin
72145 in reply to 72139
Not to mention the fact that they are RETURNING the error message instead of throwing it.

Re: Uniquely Secure

2006-05-10 14:56 • by jspenguin
72146 in reply to 72144
marvin_rabbit:
I'm just trying to imagine the GMail (or other such service) sign-up process if THAT required a unique password:

"secret", no.
"password", no.
"07-04-1776", no.
"asdfasdfasdf", no.

"wtf?", no.

"Reginauld G. Cooper was here", no.
"Reginauld G. Cooper was THERE", no.
"are there any f---ing paswords left?", no.
"spacemonkey", no.
"deadbabyducks", no.
"painfullrectalitch", no.
"superbassamatic76", no.


Note to self: change GMail password

Re: Uniquely Secure

2006-05-10 14:56 • by shaggz
72147 in reply to 72137
Anonymous:

Why is there a unique constraint on passwords?  Surely they're not being used as keys anywhere, are they?  If so, doesn't that cause problems when the user changes their password?  Never mind the security implications...


I sense layers of WTFery beneath this snippet.



They can have a cool 'forgot username?' feature.  You enter your password and it tells you your username.

This WTF is truly an onion........

1) questionable primary keys
2) security issues
3) error handling based on database vendor magic strings, as well as database key/index names


Re: Uniquely Secure

2006-05-10 14:59 • by notEnoughInfo
72148 in reply to 72139
kipthegreat:
Alex Papadimoulis:
if (errMsg.indexOf("Violation of UNIQUE KEY constraint 'UQ__mbrs_pwd'") != -1)

return "The password entered is already in use. Please enter another.";



Aside from that, there's also the wtf that the password is stored in the database in plain-text, rather than using an md5 hash of the password or something like that at the least, and adding some salt characters would be even better.


I don't know how you can infer anything about how the password is stored from that snippet of code.  It's just searching the text of an error message; the preceding lines could have included a check of a hashed or encrypted value against the one in the DB.

Re: Uniquely Secure

2006-05-10 15:02 • by Matt
72150 in reply to 72147

I can see the query now:


 


select * from users where username = @username or password = @password


 


Thats why they can't allow duplicate usernames...

Re: Uniquely Secure

2006-05-10 15:02 • by ammoQ
72151 in reply to 72141
kipthegreat:

Meant to say-   what happens when they sell to a customer running their database in German?

If that was the only problem, I would say: so what, tell the customer to run their database in English. Who cares.
I would rather worry that the error message ("The password entered...") is hardcoded in English.

Re: Uniquely Secure

2006-05-10 15:04 • by kipthegreat
72152 in reply to 72146
jspenguin:
marvin_rabbit:
I'm just trying to imagine the GMail (or other such service) sign-up process if THAT required a unique password:

"secret", no.
"password", no.
"07-04-1776", no.
"asdfasdfasdf", no.

"wtf?", no.

"Reginauld G. Cooper was here", no.
"Reginauld G. Cooper was THERE", no.
"are there any f---ing paswords left?", no.
"spacemonkey", no.
"deadbabyducks", no.
"painfullrectalitch", no.
"superbassamatic76", no.


Note to self: change GMail password


My GMail password is 12345.  I'm very proud of it.  No one would ever guess it.

Re: Uniquely Secure

2006-05-10 15:05 • by squirrel
Please tell me that once you've logged in with a "proper" password, you can browse the list of users?

Re: Uniquely Secure

2006-05-10 15:09 • by rbriem
72154 in reply to 72137
Anonymous:

Why is there a unique constraint on passwords?  Surely they're not being used as keys anywhere, are they?  If so, doesn't that cause problems when the user changes their password?  Never mind the security implications...


I sense layers of WTFery beneath this snippet.



Layers and layers of WTFery ... entire underground civilizations of WTFery ... The Land of WTFery That Time Forgot ...

Re: Uniquely Secure

2006-05-10 15:11 • by tster
72155 in reply to 72145
jspenguin:
Not to mention the fact that they are RETURNING the error message instead of throwing it.


if the function is called returnErrorMessage() or something then why would they want to throw it?  throwing errors is just 1 of 2 (actually 3 if you count setting globals) ways to handle errors.

Re: Uniquely Secure

2006-05-10 15:13 • by What about?
What if they had separate tables for passwords and usernames with no way to link one to the other! (It's only natural to have similar constraints in them, no?)

Re: Uniquely Secure

2006-05-10 15:14 • by kipthegreat
72157 in reply to 72148
Anonymous:
kipthegreat:
Alex Papadimoulis:
if (errMsg.indexOf("Violation of UNIQUE KEY constraint 'UQ__mbrs_pwd'") != -1)

return "The password entered is already in use. Please enter another.";



Aside from that, there's also the wtf that the password is stored in the database in plain-text, rather than using an md5 hash of the password or something like that at the least, and adding some salt characters would be even better.


I don't know how you can infer anything about how the password is stored from that snippet of code.  It's just searching the text of an error message; the preceding lines could have included a check of a hashed or encrypted value against the one in the DB.


That's true.  Giving them the benefit of the doubt, they could be storing something like an md5 hash with several randomly-generated salt characters.  In which case, there would need to be somewhere on the order of 1.774 * 2^64 users before the probability of a collision is greater than 50%.  If this were the case, then it is unlikely that this error message was ever seen, which would explain why it was still in the system.  Using an even better hash like SHA-1 would further decrease the probability of a clash.

Of course, Alex said "this is as bad as it seems" so I doubt it.

Re: Uniquely Secure

2006-05-10 15:15 • by TankerJoe
72158 in reply to 72152
kipthegreat:
jspenguin:
marvin_rabbit:
I'm just trying to imagine the GMail (or other such service) sign-up process if THAT required a unique password:

"secret", no.
"password", no.
"07-04-1776", no.
"asdfasdfasdf", no.

"wtf?", no.

"Reginauld G. Cooper was here", no.
"Reginauld G. Cooper was THERE", no.
"are there any f---ing paswords left?", no.
"spacemonkey", no.
"deadbabyducks", no.
"painfullrectalitch", no.
"superbassamatic76", no.


Note to self: change GMail password


My GMail password is 12345.  I'm very proud of it.  No one would ever guess it.


12345? That is the kind of password that only an idiot would have on his luggage...

Re: Uniquely Secure

2006-05-10 15:18 • by Strydyr

A few years back, I worked for someone who wanted a unique constraint on the username/password combination.


In other words, everyone could register with the same username, as long as their password was new.


After an intense discussion with this "English-challenged" individual, I went ahead and coded it as requested.  (If the user picked a previously used combination on the registration form, it just goes ahead and logs them into the existing account.)


As far as I know, this e-Commerce application is still using the code, and I suppose history has demonstrated my foolishness... he's now the VP of Development, and I was laid off, partly owing to my "negativity".

Re: Uniquely Secure

2006-05-10 15:19 • by GalacticCowboy
72161 in reply to 72123

Anonymous:
doing the whole fist thing is stupid.


Yep, one finger is sufficient.

Re: Uniquely Secure

2006-05-10 15:20 • by Kevin
72162 in reply to 72148
I will take a guess that the user table is as expected: id, username, password. (Well, almost as expected.) I don't think passwords are being used as primary keys.

Some bonehead probably just thought that having two passwords be the same is a security risk, then went ahead and added the unique constraint that made today's WTF possible.

Re: Uniquely Secure

2006-05-10 15:24 • by ptomblin
Maybe it's not as bad as you think.  Sure, using the text of a error message as  a key is a WTF.  But maybe it's not such a big WTF to check that the password is unique.  I've seen an application where you needed different passwords for different access levels, and you couldn't use the same password in the different places.  In that application, a constraint on userid,password would make sense.

Re: Uniquely Secure

2006-05-10 15:28 • by Baloon Knot
Alex Papadimoulis:

...I'll present a single line of code...

if (errMsg.indexOf("Violation of UNIQUE KEY constraint 'UQ__mbrs_pwd'") != -1)

return "The password entered is already in use. Please enter another.";


I get it, the WTF is that Alex said he'd present a single line of code, but he really showed two.

Re: Uniquely Secure

2006-05-10 15:32 • by Baloon Knot
72166 in reply to 72161
GalacticCowboy:

Anonymous:
doing the whole fist thing is stupid.


Yep, one finger is sufficient.



I prefer the shocker myself (giving, not receiving).

Re: Uniquely Secure

2006-05-10 15:32 • by Lindows Network Administrator
Lindows will rule the day!

Re: Uniquely Secure

2006-05-10 15:33 • by stannius
72168 in reply to 72147

shaggz:
They can have a cool 'forgot username?' feature.  You enter your password and it tells you your username.


Why bother with a complicated "forgot username" feature. It would be simpler to just add a "loggedin=true" query string parameter and you could skip that whole logging in thing altogether.

Re: Uniquely Secure

2006-05-10 15:33 • by Pablo Marambio
72169 in reply to 72165
Not to mention the passwords could be stored in plain text...

Re: Uniquely Secure

2006-05-10 15:35 • by Troll
First Post!

Re: Uniquely Secure

2006-05-10 15:36 • by strickdd
first? 

Re: Uniquely Secure

2006-05-10 15:42 • by Jenny Simonds

Geez, I noticed that they were checking the text of an error message, which is silly but only slightly dangerous. But the fact that they were trying to keep all the passwords unique? And that the user was notified of that fact, thus giving them some information about what passwords are on the system? Nope. Totally missed it.


This is like reading Marilyn Vos Savant's column, where she gives you a list of words and asks what they have in common. I never figure those out, 'cuz the relationships are always totally out of left field. And I hate myself for ALWAYS stopping to read that darn column anyway!

« PrevPage 1 | Page 2 | Page 3 | Page 4Next »

Add Comment