Security, Lua, and You

Security, Lua, and You

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Security, Lua, and You

Post by lurker »

Did you know that lua can write a dll and then immediately load it, executing anything inside? We could use some kind of blocking for writing out executable files. Windows demo attached.
Attachments
sayhi.lua
(5.29 KiB) Downloaded 118 times
User avatar
Neddie
Community Lead
Posts: 9406
Joined: 10 Apr 2006, 05:05

Re: Security, Lua, and You

Post by Neddie »

Uh. Yeeeah.
User avatar
danuker
Posts: 53
Joined: 04 Feb 2008, 22:37

Re: Security, Lua, and You

Post by danuker »

I'm on Linux. Linux rules.
[Though it might also be vulnerable.]
Last edited by danuker on 20 Feb 2009, 22:39, edited 3 times in total.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Security, Lua, and You

Post by lurker »

Will spring refuse to load a .so without the executable bit?
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: Security, Lua, and You

Post by aegis »

it'll refuse to load a .so not compiled right :P
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Security, Lua, and You

Post by Argh »

Oh, so you can do it for Ubuntu users, but maybe not another kernel?

Still... yuck, lol. I figured that was possible, and I'm glad somebody's tested it before it became an issue, since Widgets could be very easily built to... eh... deliver stuff.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: Security, Lua, and You

Post by aegis »

applications aren't run as administrator by default on linux, and memory is protected better
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Security, Lua, and You

Post by lurker »

What do memory protections have to do with it? This call is doing what it's designed to do, loading a library and running a function in it. And who cares if it's not admin when it can still delete all your files. I don't run spring as admin here either.
el_matarife
Posts: 933
Joined: 27 Feb 2006, 02:04

Re: Security, Lua, and You

Post by el_matarife »

Oh great considering Spring practically requires administrator level privileges on Windows. Is this the incentive we need to move all the Spring mods and maps to All Users and the configuration settings to the current user's application data?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Security, Lua, and You

Post by AF »

If spring downloader didn't ask for admin rights it didn't need then tasclient wouldn't run as an admin and spring wouldn't inherit its privilledges as a result. Spring itself doesn't need admin privilledges to run.
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Security, Lua, and You

Post by yuritch »

Now that tasclient is (seemingly) abandoned, admin rights on Windows should no longer be a problem.
==Troy==
Posts: 376
Joined: 29 Oct 2008, 15:55

Re: Security, Lua, and You

Post by ==Troy== »

*Cut*
Last edited by ==Troy== on 04 Nov 2009, 10:36, edited 1 time in total.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Security, Lua, and You

Post by lurker »

==Troy== wrote:Edit 2 : Actually, the stealthiest way to use this exploit is to put the hex representation of the dll into the LUA code, and then tell LUA to create such file once it is loaded, in the spring folder, with further execution of it.
Way to not look at the demo.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: Security, Lua, and You

Post by zwzsg »

Shouldn't that have been posted and discussed in a more private area, until fix is made and released? Because now that everybody knows, I'll be afraid to use any new map or mod, as I know that the Spring community has enough fucktard that sooner or later one will release a map that format my hard drive "just for lulz" (and the worst thing is that then, dev will blame myself for not being careful).
danuker wrote:I'm on Linux. Linux rules.
Irrelevant, since a sizeable part of Spring user base use windows, often with admin right.

I'd say that lua should only be able to read inside Spring folders (the main spring folder, and also those other folders where setting and such are stored). Reading anything else is dangerous, as I don't want any Spring map to suck up my passwords and game keys then upload them for instance.

As for writing, ideally it should only be able to write new files, with a system to keep track of which lua / which mod wrote which file, so that they can rewrite their own files. If that can't be done, I guess either a black list of dangerous file extension (exe,dll) or a white list of safer file extension (.txt, .ini, .png) would be better than nothing, but not a perfect solution : the whitelist will always lack some useful extension only one lua widget writer found the need of (like that .ppm for height map exporter), and safe files can be unsafe (like buffer overflow in windows's thumbnail exploitable by a mere image or sound file).
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Security, Lua, and You

Post by lurker »

I really wouldn't worry about exploiting normal files.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Security, Lua, and You

Post by Argh »

1. Please, don't entirely curtail IO, it'd make World Builder moot, which would be a major bummer.

2. If you're going to make changes to IO, please enable it for Gadgets. It's pretty silly that we cannot read or write files with Gadgets at all.
User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

Re: Security, Lua, and You

Post by Pxtl »

It sounds like each little widget, mod-package, or map needs a little seperate sandbox where it can write files, and that's the only place it can write. It can read any file within the Spring file tree, but it's stuck to writing in that little sandbox.

And a separate folder is needed for "this folder is the one place you can store DLLs/EXEs that Lua script can execute". Obviously, Lua cannot write to that folder. That way an intrepid modder can create dll/exe-extended mods, but those mods will require the dll/exe to be deployed separately from the mod package, thus requiring active user involvement in the process of deploying such potentially unsafe content.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Security, Lua, and You

Post by lurker »

Okay, because windows likes to run all kinds of things when you click on them, let's make a list of executable / system-changing file extensions. Speak up if you have anything not on the list that would run on a standard windows install.
Binary: exe, com, scr, pif, bat (you can rename to spring.bat and it works!?)
Script: cmd, jar, jnlp, js, jse, reg, rgs, sct, vbe, vbs, wsf
Unknown: msc? cpl?

Even a whitelist might work better than that mess.

There is the option is to block only binary-executable files and trust people to not click the BIG RED BUTTON of other files.

And tobi had the idea to mark the files as unsafe / from an untrusted zone so you get a warning before doing something like executing.
==Troy==
Posts: 376
Joined: 29 Oct 2008, 15:55

Re: Security, Lua, and You

Post by ==Troy== »

WinVista has an annoying feature of detection bat/exe files if needed. Not sure what are the exact criteria for it to find them.
ZellSF
Posts: 1187
Joined: 08 Jul 2006, 19:07

Re: Security, Lua, and You

Post by ZellSF »

lurker wrote:Okay, because windows likes to run all kinds of things when you click on them, let's make a list of executable / system-changing file extensions. Speak up if you have anything not on the list that would run on a standard windows install.
Binary: exe, com, scr, pif, bat (you can rename to spring.bat and it works!?)
Script: cmd, jar, jnlp, js, jse, reg, rgs, sct, vbe, vbs, wsf
Unknown: msc? cpl?
Don't think jar would run on a standard Windows install.
Post Reply

Return to “Engine”