Security

Started by
28 comments, last by GameDev.net 19 years, 7 months ago
Quote:
Or maybe the bytecodes are too low level to easily know what's legal and not?


That's exactly it. The byte codes are too low level. The instructions that use indices can be checked, but other instructions like write, read, etc work with address pointers directly. A malicious code sequence can put an address on the stack with SET4 and at any time in the future call WRT4 on it.

If I can think of some way to make the bytecode secure (without loosing too much performance) I will do it.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement
how does Lua manage security?

[Edited by - EddHead on September 15, 2004 12:02:16 AM]
Jayanth.KRaptor Entertainment Pvt. Ltd.http://www.raptorentertainment.com---------------------------------------------------------Why Mr. Anderson? Why? ...Why keep fighting? Do you think you're fighting for something - for more than your survival? Can you tell me what it is? Do you even know? Is it freedom, or truth, perhaps peace, could it be for love? Illusions Mr. Anderson, vagaries of perception. Temporary constructs of a feeble human intellect trying desperately to justify an existence without meaning or purpose.
I read the reference manual for Lua, and from what I can see Lua doesn't allow saving/loading of compiled byte code, which effectively eliminates the security problem we are discussing here.

Note, the security risk is most notable when sending the compiled byte code between machines. If the compiled byte code is installed on the client machine together with the rest of the program then the bytecode poses no greater security risk than the application itself. A hacker with malicious intent could manipulate the application directly if he has access to it. So if you do not intend to pass byte code between machines I don't think you have to worry too much about the security.

If you do intend to pass compiled byte code between machines, you need to set up a protocol that protects hackers from tampering with the data stream. SSL has been proven to be a good way to do this.

In either case, if I can think of some way to make the bytecode safer I will implement it.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Security is really just narrowing down who can successfully circumvent any safety measures that are put in place.

* AngelScript as source - Anyone with notepad and some basic programming knowledge may be dangerous.

* AngelScript as byte code - Someone with a binary file editor and knowledgeable with AngelScript's byte code may be dangerous

* AngelScript as byte code in compressed and/or encrypted file - Someone with a memory debugger and knowledgeable with AngelScript's byte code may be dangerous.

The last should be handled by the application as the time for compression/encryption is a trade off with speed.

Mad
Well, my ideas would involve the serving sending bytecode to the client. What I'd want to avoid is someone setting up a server sending stuff that screws up the clients computer. (I guess a lockup or so would be okay, but if it can create code that destroys data on the client or something like that, it'd be a lot worse.)

I could send just source, but bytecode would be so much neater since it's more compact and at least a bit obfuscated.
If someone really wants to alter the "script" it'll happen anyhow so I think serving the source files is better. It would allow for conditional compilation, and problems (they are huge AFAIK) of invalid pointers would be avoided.

After the script/binary has been loaded it's in memory and can be read back and/or altered. No point in trying to prevent it.
I agree with Kurioes. You really ought to send the source files, not the bytecode. That way the compiler can do it's job and prevent access to memory the script shouldn't mess with.

You can use compression to decrease the size of the files. I suggest you take a look at zlib for this, as it is a free library (same license as AngelScript).

Never rely on obfuscation to hide code, use encryption instead. TEA is a really simple algorithm that can be implemented with only a few lines of code (I have an example on my site). The algorithm is very secure (at least as secure as private key encryption can be) and uses 128bit keys. The algorithm is also quite fast, and shouldn't slow down the download very much.




AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Quote:Original post by Mad Dugan
Security is really just narrowing down who can successfully circumvent any safety measures that are put in place.

* AngelScript as source - Anyone with notepad and some basic programming knowledge may be dangerous.

* AngelScript as byte code - Someone with a binary file editor and knowledgeable with AngelScript's byte code may be dangerous

* AngelScript as byte code in compressed and/or encrypted file - Someone with a memory debugger and knowledgeable with AngelScript's byte code may be dangerous.

The last should be handled by the application as the time for compression/encryption is a trade off with speed.

Mad


I only agree with the last two points.

The scripts can only do what the application allows them to do. If the application don't register any functions for accessing memory, then the script can't do that (of course that would make for a pretty useless script [wink]). If the script's interface to the application is secure then the script is also secure.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Quote:Original post by WitchLord
You can use compression to decrease the size of the files. I suggest you take a look at zlib for this, as it is a free library (same license as AngelScript).

Yeah, well it's not really a problem anyway. It's not like a script will be sent every frame or something. :)


Quote:
Never rely on obfuscation to hide code, use encryption instead. TEA is a really simple algorithm that can be implemented with only a few lines of code (I have an example on my site). The algorithm is very secure (at least as secure as private key encryption can be) and uses 128bit keys. The algorithm is also quite fast, and shouldn't slow down the download very much.


Well, in this case encryption is just another form of obfuscation. If the client can read it, no matter how tough the encryption is, so can the guy using the client one way or another. It wasn't thought as some bulletproof protection, just a way not to just swing the door wide open.

This isn't about cheating protection or anything like that. The idea was just a system somewhat like the mutators in Unreal Tournament. That the server can have modifications that are automatically downloaded and used. I've got no idea how extensive or secure the mutator-system is. I think they probably just send script code. (I haven't looked into it.)

Uhm. Okay. Now I actually have looked into it, and yes, it just sends script code as far as I can see.

Anyway, my point was that my ideas doesn't fall if bytecode can't be sent. I'm just exploring the possibilities. :)
You brought up an important issue with your question. I hadn't thought about this before.

I'll update the manual with a warning about the security risks of loading/saving bytecode.

As another solution to the problem you could digitally sign the compiled bytecode. That way the client can verify if anyone has altered the code and not run it. This would only be a viable solution if you can keep the private key secure. If you plan on having public servers then the private key isn't secure so the digital signature cannot be trusted.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement