Page 1 of 3

Server and security

Posted: Sat May 09, 2015 10:14 am
by SuperZazu
Hello all :)

For my next game, I plan on storing high-scores online, on my webserver. It works like this: when I want to add a score to the online database, I just have to make an HTTP request with some parameters ("score", "username"...).
Everything works. However, anyone could just look at the source and send custom HTTP requests to the server; that means everyone could cheat and send fake scores... How could I avoid that ?

Have a good day,
-- superzazu

Re: Server and security

Posted: Sat May 09, 2015 10:25 am
by cohadar
You can't, and it has nothing to do with open-source.
Basically you have untrusted clients and encryption does not provide trust, just communication safety.

Even Blizzard cannot do this, and they have waaay more resources than you.
Unless of course you want to force your users to install "monitoring/protection" software alongside your game.

May I suggest alternative idea:
Instead of high scores, make an achievements API.
That way people have no incentive to cheat, and even if they do, they just lie to themselves.

Re: Server and security

Posted: Sat May 09, 2015 11:57 am
by ivan
As cohadar said, it's not a question of making it 'impossible' to cheat - just make it not worth it.
For anonymous hiscores, you can store the IP for each entry and ignore repeated request from that IP for 4-5 minutes.

Re: Server and security

Posted: Sat May 09, 2015 5:47 pm
by I~=Spam
If it still matters to you one thing you could try is moving some of that code to c/c++ and only distribute the binary form that way it is harder to discover how the scores are sent. But even still you cannot absolutely guarantee that the high scores sent are real.

Re: Server and security

Posted: Sun May 10, 2015 9:13 pm
by SuperZazu
Thank you for your answers ! :-)

Re: Server and security

Posted: Fri May 22, 2015 4:20 pm
by T-Bone
For some games, I guess instead of sending the scores you could just send all user input, and then the server simulates the game and calculates the score. That way, a cheater must still "play" (although they may do so by scripting). May not be feasible for complex games, and is almost certainly not worth it, but it could be fun to implement.

Re: Server and security

Posted: Fri May 22, 2015 5:12 pm
by kikito
The simplest way I know for ensuring that highscores are real is that the server knows some game logic.

For example, if you know that level 1's max theoretical score is 1000, then if anyone sends you 10000, that's a fake and you can discard it.

If it takes at least 30 seconds to complete a level and you get two request with the same user id and ip address in less than 30 seconds, you can discard both requests.

You can make the game send you one score per level instead of just one score at the end. If someone sends you a score for level 9 but not for level 8, 7, 6 ... etc, with appropriate rules for each one, you can discard that request too.

You can also put ip addresses into "ice boxes". The first time you detect they sent you bad stuff, you ignore all their request for 1 minute. If they send you bad stuff during that minute, you ignore them for the next 10 minutes. Then 1 hour. Then 2 hours. Then 10 hours. Etc. Until they stop. Some people will play from subnetworks so their public addresses might collide, so you might want to combine the ip address with something else, like the user id or a random id that you create in the game.

All this is not bullet-proof, but it should deter the "obvious" attempts. And it's more straightforward than encryption, which is very tricky. Still, it will take a non-trivial amount of time to implement all of this in the server. I would wait until I had at least a nice beta version of the game working, before starting any of this.

Re: Server and security

Posted: Sat May 23, 2015 5:54 pm
by Inny
In my experience, releasing the game on the love2d.org forums and simply stating what a regular score at the end should be, gets you pretty legit scores posted by everyone who played it. Sometimes with screenshots.

Re: Server and security

Posted: Sat May 23, 2015 7:12 pm
by T-Bone
Inny, your note about screenshots gave me an idea: The client could take a screenshot and send it to the server, which could then use image analysis tools to determine if it seems legit or not. While this can obviously be fooled as well, it could make some things very difficult to do. It could be pretty hard to know what the latter levels are going to look like without playing your way there.

Re: Server and security

Posted: Sat May 23, 2015 7:31 pm
by Robin
T-Bone wrote:Inny, your note about screenshots gave me an idea: The client could take a screenshot and send it to the server, which could then use image analysis tools to determine if it seems legit or not.
The image analysis tool would likely be harder to write than something breaking that same tool.