Hi all,
My game requires users to log in via Facebook in order to get past the start screen because this free-to-play game has real prizes to be won, and having their Facebook details provides a means of contacting them if they win.
I’ve been pondering security and how I might prevent a hacked version of the game from submitting guesses that could allow them to win. A user submits a guess via my web API using the WWW class, and my code returns a simple yes or no bool value, as to whether or not they guessed correct (and won a prize).
When submitting a guess, my API currently requires the user’s Facebook ID that is returned by the Facebook API, along with their guess. I have server-side checks to ensure a single user (Facebook ID) can only submit 1 guess every 5 seconds, but what is to stop a hacker from sending a bogus Facebook ID that they randomly generate?
My initial thoughts are that on logging in to the app via Facebook, I should server-side query Facebook for that user’s first name, last name, friend count etc, and generate a hash on the server, storing it in the database. Any API requests within the game should then send along those same details, which i’ll hash on the server and compare against the stored hash in my database. If the hashes match then I can assume the account is at least a genuine one.
But, what stops a serious hacker from implementing a Facebook user lookup function into their own hacked version of the game, and sending legit details along that will pass my server side checks?
One has to ask themselves, why would a hacker submit guesses from someone else’s Facebook ID, and potentially winning a prize for that person? Perhaps someone with thousands of Facebook accounts? I don’t suppose there is a way to protect against people who submit attempts from thousands of seemingly legit Facebook accounts, other than applying some limitations on the number of requests coming from the same IP - but with proxies even that’s not foolproof.
I’ll conclude by suggesting that in the event a successful guess is submitted, a “claim code” is generated and given back to the user, and stored in the database. In order to claim the prize, the user would need to quote the claim code they were shown in the app. This means that if a hacker won the prize on someone else’s behalf, the unsuspecting winner would not be able to claim the prize.
It makes my head spin, but if you’ve made it this far through my post, thanks! If you have any feedback on my thoughts, or a suggestion as to how I can guarantee legit usage of my game i’d love to hear it.
[ UPDATE ]
I just found that the Unity Facebook SDK returns an access token when the user successfully logs in (FB.AccessToken). On the server I can query the Facebook Graph API for a user by passing a valid access token, so this is how I will authenticate each request. As for dealing with spammers with multiple accounts, i’m still not sure on a best approach.
Thanks
Mat