Re: My login security design
It sounds ok.
Two comments/questions though:
Does the session in the database ever expire if the player logs in but then doesn't connect to the game for any reason?
It's vulnerable to replay attacks, if the communication from client to the login server is / is allowed to be identical every time. i.e. someone could record and replay a successful login, without ever actually knowing the password.
Re: My login security design
Good point, thank you!
I'm gonna make the sessions expire after some given time, if they're not being used :)
Re: My login security design
You send the password as plaintext, and the PHP server is responsible for MD5ing it (and scramble it a bit following a rule), and check that against your database. You don't store passwords in plaintext, but you can pass them as plaintext.
If the client sends an MD5 to the host, that MD5 effectively becomes the password, and any protection you might have is void.
Also, on replay attacks: don't bother avoiding them - too much trouble and minimal gain (unless you're a bank or something).
Re: My login security design
It is true that if your client sends an md5 to the server then the md5 is effectively the password, but it's still slightly more secure than transmitting the password in cleartext because if someone snoops it they can't just type what they see into the real client.
Avoiding replay attacks is a simple as asking the server for a login token (which is generated randomly), and then making an md5 of that plus some secret salt (you should be using a salt anyway) plus the password (or the md5 of the password), and sending that back to the server. The server then does the same thing to validate the password, using the token it generated for you earlier.
i.e.
User signs up with "username" and "password"
Server stores md5(salt+password) into the database
User logs in by typing password into client
Client sends username to server, asking for login token
Server sends back token and stores token with username
Client computes md5(token+salt2+md5(salt+password)) and sends it to the server
Server computes md5(token+salt2+storedpasswordmd5) and checks if it matches
Server sends back login succeed/fail, and stores session if login success
EDIT: You don't need to avoid replay attacks, if you're willing to be slightly less secure. At least use a salt to prevent md5 reversing though.
Re: My login security design
I've changed it a bit, adding some encryptions and expiration of the sessions, you can see it in the first post.
Re: My login security design
Why do you now seem to be checking the user's password twice?
Re: My login security design
I think I've got confused with my own ideas, let me think it over again... XD
EDIT:
I've changed it again, but it seems that it's still not good... If somebody logs in, there's gonna be a record with his username created in the "sessions" table, so he will be able to run any other application and make it connect with my server... :/
Re: My login security design
Quote:
Originally Posted by Pasiunia
If somebody logs in, there's gonna be a record with his username created in the "sessions" table, so he will be able to run any other application and make it connect with my server... :/
If you mean "he will be able to multiclient" then no, because the other client will have to login. If he tries to login and his username is already stored in "sessions", either the old instance gets booted or the new instance gets an access denied (your choice, really).
If you mean "he will be able to plug third party applications in", then yes. But then again, he can plug anything anyways, unless you encrypt every outgoing packet, which you won't because no one has that kind of processing power (unless you're a bank).
Quote:
Originally Posted by Dynasoft
but it's still slightly more secure than transmitting the password in cleartext because if someone snoops it they can't just type what they see into the real client.
If he knows how to snoop, then he knows how to replay. Little program called "WPE PRO" should do the trick.
Also, I see a problem with the salt: the client can never know it. It's too easy for a malicious attacker to disassemble your client and discover the salt.
You could use an asymmetric key, where the decryption key is known only by the server while the encryption key is public - but in my opinion, it's not worth the effort. That's why most [game] clients don't bother with login encryption
Re: My login security design
I start getting to the conclusion that making any securities is not worth of my effort, cause there's always some way to break it... xD