Jump to content
The Dark Mod Forums

Security Of Computer Game Code


thestemmer

Recommended Posts

Just a random question for all you coders out there. I'm an undergraduate student taking a course in computer programming for the first time, and after having studied Java for a semester I'm now being introduced to C for the first time. Recently I was struck by one of the professor's demonstrations, in which he showed how a poorly written C program could be easily used to access parts of the hard drive that should be beyond its security privileges. Naturally, I understood almost none of what he was doing, but I got the basic idea of what he was trying to prove.

 

It made me start thinking, though, are modern computer games secure enough to protect against malicious use of their code? With the huge influx of very complex but shoddily programmed games into the market (games like this one come to mind), are we taking a risk installing games onto our systems? I don't know the first thing about how computer game code works, but is it possible that somebody could create a virus that takes advantage of the coding vulnerabilities of specific games? Big things like the Windows OS get updated for security vulnerabilities all the time, but I've never heard of a security update for a specific computer game. Should I be worried?

Edited by thestemmer
Link to comment
Share on other sites

The poorly written code that you saw deomonstrated is the exact thing that hackers look for to write viruses that will exploit those faults.

 

However, games don't really do anything useful enough for a hacker - access textures, load maps... so hackers can't fool the game into doing anything nasty to your system because its not doing anything that interesting in the first place.

 

Now your OS on the other hand does a lot more interesting things - write directly to RAM, directly to HDD...

 

 

 

I dont' specifically know about the HDD access, but as for accessing memory it shouldn't - a poorly written app won't be allowed to mess up your RAM directly and cause a crash that way - each program is allocated one or more pages, and they can be as badly written as they want and mess up those pages all they want - as soon as they attempt to write outside their allocated pages, windows says "This program has performed an illegal operation and will be shut down", and it terminates the program and blanks the pages. Now you know what that error generally means.

Link to comment
Share on other sites

It made me start thinking, though, are modern computer games secure enough to protect against malicious use of their code?

 

No. That's why there are constant security updates and exploits. But this has nothing to do with modern games or not, because you always have that risk.

 

With the huge influx of very complex but shoddily programmed games into the market (games like this one come to mind), are we taking a risk installing games onto our systems?

 

You always run that risk. Not only with games, but anytime you run some code. Installing the operating system already introduces that risk, even if you wrote it yourself.

 

I don't know the first thing about how computer game code works, but is it possible that somebody could create a virus that takes advatantage of the coding vulnerabilities of specific games?

 

That happens all the time.

 

Big things like the Windows OS get updated for security vulnerabilities all the time, but I've never heard of a security update for a specific computer game. Should I be worried?

 

Games are security updated the same as OSes.

Gerhard

Link to comment
Share on other sites

However, games don't really do anything useful enough for a hacker - access textures, load maps... so hackers can't fool the game into doing anything nasty to your system because its not doing anything that interesting in the first place.

 

Which is of course WRONG! As soon as a hacker can introduce his own code it doesn't matter what the original code did.

 

I dont' specifically know about the HDD access, but as for accessing memory it shouldn't - a poorly written app won't be allowed to mess up your RAM directly and cause a crash that way - each program is allocated one or more pages, and they can be as badly written as they want and mess up those pages all they want - as soon as they attempt to write outside their allocated pages, windows says "This program has performed an illegal operation and will be shut down", and it terminates the program and blanks the pages. Now you know what that error generally means.

 

Which is also wrong. If a virus will perform such an action it is poorly written. A properly written exploit wouldn't even be noticed. That's the whole point of it. In fact, one of the bigger viriis these days (don't remember which one it was) was caught red-handed because of this. The author forgot a condition on some systems which caused them to crash. And Windows allows you all kind of manipulations of memory, so you don't really need to crash the system.

Gerhard

Link to comment
Share on other sites

Okay I mis understood. Well the real security is that games are a poor target for a hacker, operating systems are more widespread.

 

Yes I was wrong I just remembered the real reason virus code can run - you cause the program to overflow into ram its not supposed to, put your code there, so that it will run your code. That's what I remember from my programming lecturer saying.

Link to comment
Share on other sites

Actually it works like this.

 

You try to cause a stack overflow. The overflow must be done in such a way that enough data is on the stack to match what was before there. The original function proceeds like normal. When it returns it will clear up the stack and discards all the data that you put there. The last value on the stack, before the function actually returns, is the address where it is originaly called from. Since you put enough data on the stack, of course the address doesn't point to the original caller, but to the new code that should be executed. So when the original function tries to return, it will not return to the original caller, but to the address that it is now pointing to. This code typically is rather small and will download additional stuff and run it. Any assembly programmer should be able to do this, and must know this, because knowledge of how the stack works should be naturally to them.

In fact I used such a technique on the Commodore 64 because the CPU didn't have big jumptables. It was limited to 256 btyes, but with this technique you could create jumptables that were as big as you needed them. The technique itself is not anything new or sophisticated, it is simply applying assembly language programming knowledge.

Gerhard

Link to comment
Share on other sites

There is also the far less refined technique where you overwrite as much memory as possible with a chain of NOPs followed by your code, with the hope that at some point in the future, one of the NOPs will be the jump target of a function call which will lead to your code being run.

Link to comment
Share on other sites

Games are security updated the same as OSes.

That's very interesting. I don't remember ever seeing information about a security update in the readme file for any patch I downloaded, though. Are they just not normally listed? Perhaps to prevent potential hackers from exploiting code vulnerabilities?

 

Also, you said that there are viruses out there that target specific games. That surprised me, I've never heard of such a thing. Could you give an example? The thought of somebody using my downloaded version of Pacman to gain backdoor entry into my system is frightening. I'd imagine that this could be particularly problematic for things like business network systems, where people would have reason to want access to restricted files and incentive to custom-tailor a program to do so.

Link to comment
Share on other sites

I don't know about the policy of how games companies handle this, but I know that one of the bigger games had a big problem. I think it was battlefield or unreal tournament. I haven't followed this though because I was not interested in this game. I don't really know if viriis use games as a target, but then again I would be very surprised if hackers would ignore games. Sure it's a much smaller user base then targeting an OS, but then if you can hack 50.000 machines, it still pays off and for the bigger games, I think it could easily reach much higher numbers. Don't know though how the rates are, so maybe 50.000 machines is not much worth. :)

Gerhard

Link to comment
Share on other sites

I can see massively popular games like World of Warcraft becoming attack vectors for malware, but smaller games aren't going to be of much interest when stuff like IE still exists with its multitude of vulnerabilities. There is no point in writing a Doom 3 worm when you can write an IE or email version which will infect many more computers.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 2 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
    • The Black Arrow

      I wanna play Doom 3, but fhDoom has much better features than dhewm3, yet fhDoom is old, outdated and probably not supported. Damn!
      Makes me think that TDM engine for Doom 3 itself would actually be perfect.
      · 6 replies
    • Petike the Taffer

      Maybe a bit of advice ? In the FM series I'm preparing, the two main characters have the given names Toby and Agnes (it's the protagonist and deuteragonist, respectively), I've been toying with the idea of giving them family names as well, since many of the FM series have named protagonists who have surnames. Toby's from a family who were usually farriers, though he eventually wound up working as a cobbler (this serves as a daylight "front" for his night time thieving). Would it make sense if the man's popularly accepted family name was Farrier ? It's an existing, though less common English surname, and it directly refers to the profession practiced by his relatives. Your suggestions ?
      · 9 replies
×
×
  • Create New...