Page 2 of 4
Re: table.pack and LOVE
Posted: Wed Oct 09, 2013 3:08 pm
by bartbes
Be warned that TSerial allows for arbitrary code execution, so it might not be the best idea for networking.
Re: table.pack and LOVE
Posted: Wed Oct 09, 2013 3:36 pm
by Sheepolution
At what point can it be dangerous though?
As soon as I do Tserial.unpack(table)?
Re: table.pack and LOVE
Posted: Wed Oct 09, 2013 3:45 pm
by Robin
Yeah.
Re: table.pack and LOVE
Posted: Wed Oct 09, 2013 5:14 pm
by Sheepolution
But how? Variables älone can't do much right?
Re: table.pack and LOVE
Posted: Wed Oct 09, 2013 6:14 pm
by Jasoco
In Lua, everything is a variable. Including functions and tables and all can be inside each other.
Re: table.pack and LOVE
Posted: Wed Oct 09, 2013 6:25 pm
by Lafolie
It is possible to sandbox to an extent, you can create a safe environment using do-end blocks or using a
set of rules defined by a function.
Re: table.pack and LOVE
Posted: Wed Oct 09, 2013 7:52 pm
by bartbes
Well, it uses [manual]loadstring[/manual] to unpack, which executes a string as code, so there you go.
Just to be clear, I'm not bashing TSerial, it's just that it's not meant for (safely) receiving things from outside of your "trusted zone".
Re: table.pack and LOVE
Posted: Thu Oct 10, 2013 4:42 am
by ArchAngel075
My workaround will be to scan all incoming messages server side, and if the string contains "function" then it will error the game, i dont plan on trying to send functions of my own and so this will eliminate the security risk almost completely.
Im sure there might be a different way to protect from malicious code.
Re: table.pack and LOVE
Posted: Thu Oct 10, 2013 6:16 am
by Robin
ArchAngel075 wrote:My workaround will be to scan all incoming messages server side, and if the string contains "function" then it will error the game, i dont plan on trying to send functions of my own and so this will eliminate the security risk almost completely.
Spoiler alert: you will get hacked. Blacklisting is not something you can prevent code injection with. Either use sandboxing or send JSON instead of Lua. I recommend the latter.
Re: table.pack and LOVE
Posted: Thu Oct 10, 2013 9:50 am
by kikito
Which reminds me:
https://github.com/kikito/sandbox.lua
I have not announced it here because it's not yet 1.0, but it works quite nicely.