Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm working on a flash game that saves your progress locally. These saves can easily be hacked. My solution is to add an md5 hash of all the variables saved into the save file itself. When loading the save, the game would check if the hash is valid.

Is this a good soultion? Are there better solutions?

share|improve this question
    
This might be a stupid question, but when you say they can easily be hacked, are you simply saving as a readable text file? Or as a proper binary file? –  Ray Dey Feb 8 '11 at 23:02
1  
Using Flash's standard local shared objects –  Abdulla Feb 9 '11 at 2:35
    
I would suggest asking on security.stackexchange.com. Though it's not a typical IT type question, development security is squarely within scope. I'm sure you'll get some good answers, though you may need to phrase the question a bit differently. –  AviD Feb 9 '11 at 8:41
    
@AviD: this is very game related, actually –  Lohoris Feb 15 '12 at 8:48
    
@Lohoris of course its game-related, but my point was this is looking for security expertise - though its related to gamedev, its not a gamedev-expertise question. –  AviD Feb 15 '12 at 10:11

3 Answers 3

up vote 24 down vote accepted

The way you have it described, somebody hacking a save file would just need to construct an MD5 hash of the save file values in order to bypass this measure. You need to add one thing in order for this to even really be worthwhile: a secret block of arbitrary data that's added to what you're hashing (both when creating the save and when validating it on restore). The mechanism won't be uncrackable or anything at that point, but it'll be resistant to medium-casual tampering. If you can avoid having the data block be easily extractable from your runtime files using a hex editor, that'll add another notch.

If you want people to actually not be able to hack your saves, you cannot perform local saves at all. You cannot trust the client because the client is in the hands of the enemy.

share|improve this answer
17  
+1 for "the client is in the hands of the enemy" –  Constantin Feb 9 '11 at 0:22
    
Something I'd like to add, you should try to incorporate something about the user's computer as part of the protection. That way users can't trade save files so easily. (perhaps incorporate the computer's name into the salt or something of this sort) –  Michael Coleman Feb 9 '11 at 3:52
3  
@Omnion: The risk of associating with the computer is that the user may lose all their save files when they get a new machine. Migrating data to a new computer is painful enough without that. Probably the ideal thing, if possible, is associating the save file with a server account. –  chaos Feb 9 '11 at 6:58
2  
Salt is not a secret chunk of data, while it is random it does not add authenticity, nor does it prevent tampering. Salt is only intended to "randomize" the hash output, such as to prevent e.g. Rainbow Table attacks. –  AviD Feb 9 '11 at 8:43
2  
"You cannot trust the client..." this part is very true. –  AviD Feb 9 '11 at 8:44

If this is not an online tracked competitive type game:

Let em hack away man. You can spend way too much energy on things like this when people who will play the game, will just play the game. Those who want to hack it will never really want to play it, they just want to hack it.

If it is an online competitive type game:

All you have to do is store the hashes on a server some where with their login information. If the hash from their save file is not valid, then their game is not valid.. Start over, or revert, or whatever :)

This is fairly basic but there again, we are talking about games, not bank accounts and such.. And always remember.. hobbyist or professional gamer developer, there are Hundreds of people out there who are going to try and hack your games. Put in enough effort to try and preserve the enjoyment of the game for those who are going to play by the game's rules, and thats about it.

share|improve this answer
1  
+1 for putting the security effort into context of benefit. –  AviD Feb 9 '11 at 8:45
    
@AviD Thanks :) –  James Feb 9 '11 at 18:38
    
-1 for dismissing games so easily (why?!). Though the first part of the post is very true. –  Lohoris Feb 15 '12 at 12:53
    
@Lohoris I do not dismiss video games. I just think people should evaluate what they get out of spending time on security vs game development. –  James Feb 15 '12 at 17:08

This is not a good solution, since all the values hashed are in the save file.

If the attacker twiddles something, they just have to recompute the hash and store that in the save file too...

Saving things locally without any online state tracking is fundamentally non-securable.

You need an element that is on the server such as HMACing with a key that only the server stores.

This will not guard against an active attack where the attacker impersonates or otherwise piggybacks a live session however.

I know people who delight in hacking Flash games btw.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.