Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Question about validating player score/leaderboard.

Discussion in 'General Discussion' started by slayeruk, May 1, 2014.

  1. slayeruk

    slayeruk

    Joined:
    Mar 10, 2014
    Posts:
    33
    I have asked this question in the Networking section but I thought I might get more input here, so sorry in advance, also for wall of text.

    The game is a simple puzzle matching game.

    Basically, my game is not multi-player at all but:

    1) I need to verify player score on-line leader board - Must be secure
    2) I need to verify time limit.
    3) I need to verify number of remaining moves.

    The game will be mobile only.
    If I use simple http/https - anyone can decompile the game and view encryption key and modify source.
    If I make the game an authoritative server, (a lot of work), the lag will be a problem and I will need hundreds of simultaneous games running. As the game is single player with on-line leader boards and score verification.

    Without giving away to much info. it is very important that the ON-LINE Score Board/ leader board is Secure above all else, that the scores being submitted are legitimate.

    How to achieve such a thing in a reasonable amount of time?

    I have researched every option.

    HTTP HTTPS is insecure when used in .net application because of reflection.
    A Non-authoritative server can be cheated ( Never trust client).
    An authoritative server will introduce long development times/latency/and other complications, along with high server cost and maintenance.

    What other options are there? and/or which is the most feasible.
     
  2. Graham-Dunnett

    Graham-Dunnett

    Unity Technologies

    Joined:
    Jun 2, 2009
    Posts:
    4,287
  3. slayeruk

    slayeruk

    Joined:
    Mar 10, 2014
    Posts:
    33
    Really? Apple game centre is secure? What about android?

    What is stopping someone from modifying the game and submitting a high score? Never trust the Client.
     
  4. S3dition

    S3dition

    Joined:
    Jan 6, 2013
    Posts:
    252
    You already don't like the only answer. You can't trust the client. Ever. Server authoritative is the only way to ensure data integrity.
     
  5. slayeruk

    slayeruk

    Joined:
    Mar 10, 2014
    Posts:
    33
    Yes, so I am to create an elaborate server architecture, for a simple puzzle game just to have a secure leader board? Seems a little OTT. Not to mention the cost of hosting such a system. There will not be one world, each client would require a separate server instance.

    There has to be another solution.
     
  6. S3dition

    S3dition

    Joined:
    Jan 6, 2013
    Posts:
    252
    Cloud hosting is pretty cheap. You'd have to write a basic backend for it, but you need a database to retain the high scores anyway don't you? Why exactly would they need a full server instance per client? Don't you mean socket?

    And, there really isn't, which is why all games that have any kind of persistence have some level of server authoritative code. At the very least things like score, credits, premium currency, and unlocks are only stored serverside and never touched by the client.

    I'm not aware of a single game (or any software) where the client is trusted enough to handle data integrity.
     
  7. slayeruk

    slayeruk

    Joined:
    Mar 10, 2014
    Posts:
    33
    Not sure of the price of cloud hosting I assumed it would get expensive.

    A database of high scores is extremely simplistic compared to a fully authoritative server, at least in my understanding.
    I assumed I would need an instance per client as the game is single player, I suppose it would be possible to connect everyone to the same server instance but since they don't share data between clients, it's kind of pointless and it makes the coding complexity higher.

    I understand that storing the score, credits, premium currency, and unlocks are only stored server side is absolutely necessary that is not my issue.

    My issue is that having access to the full source means that the client can send any data to the server fake or not. Unless the game is fully authoritative which is OTT for a simple single player puzzle game.

    So that is the dilemma, one that I don't see being solved easily. Normally you would not care if a client manipulated the leader boards, but in this instance it breaks the whole idea for the game, hence the need.
     
    Last edited: May 1, 2014
  8. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    511
    One other option could be to use Kii.com for that. I use it as well and works very nice so far. Free until 1mio API calls per month. Access control on object level is in place. It might give you an easy alternative compared to firing up your own server.
     
  9. S3dition

    S3dition

    Joined:
    Jan 6, 2013
    Posts:
    252
    Well, if you know php it tends to be cheaper than if you're using asp.net or some other server side language. Azure offers a free trial and is relatively cheap at ~$15/mo. Rackspace starts at $30/mo for a faster linux vm. You can sign up for Heroku for free and try them out too.

    There are a lot of options for less than $50/mo that should work fine. If you're using more computing power than you're being paid for, then there is probably a monetization problem with your app.

    As far as how you expect your backend to function, that's really up to you. All you need to do is manage the data per user connection and make certain each player gets the proper information. You could set up a system that sends whatever the puzzle pieces are to each device on request. I don't know your game or how it works, but you would need to figure out what exactly you don't want to be altered and do it on the server.

    It's possible to set up an instance of Unity as a server that everyone connects to and have it manage each player as if they are connected to a multiplayer game.

    But anyone with your game client can decompile it and send whatever information they want. The only way to prevent it is to do all the important stuff on the server.
     
  10. DallonF

    DallonF

    Joined:
    Nov 12, 2009
    Posts:
    620
    Here's an interesting idea that just came to mind...

    Make sure the game is 100% deterministic. The same inputs at the same times will ALWAYS result in the same score. You'll probably have to use some random seeding for level generation (I'm assuming this is something similar to a Match-3 game?) Then, instead of a score, send up a list of the player's moves to the server. The server then simulates their game, doing a couple of sanity checks (can an actual human REALLY swipe that fast?) and posts the resulting score to the leaderboard.

    This solves the problem of players submitting ridiculously high scores. The only way to exploit this is to reverse engineer the game (and the random seed for that level instance), determine the optimum set of moves, then send a carefully crafted play record to the server for the maximum possible score on that level. Honestly, I don't see anybody going through the trouble of doing that, and if they do... well, maybe they deserve a spot on the high scores? In any case, if it becomes a serious problem after the game is released, you can add more sanity checks to the server.

    But you're seriously overengineering this. You shouldn't be worrying this much about cheaters until you actually have, you know, legitimate players.
     
    Last edited: May 1, 2014
  11. slayeruk

    slayeruk

    Joined:
    Mar 10, 2014
    Posts:
    33
    DallonF, that was one of the ways I envisioned the server operating, record the moves and send the data along with random seed to the server and simulate the result, to legitimize the score. Its still a lot of work but seems the best option, of course if someone reverses this then they deserve the score.

    Yes, I know it is pointless to worry about it until I have players but the way I am making the game I am expecting their to be a lot, and there will be incentive to cheat.

    I didn't want to create the game then run into the cheating problem I would rather have the architecture in place to deal with cheaters from the get go, I also wanted to make sure I was thinking about the problem in the correct way.

    Thanks for the reply.

    S3dition, Thanks for the pricing info.