table.pack and LOVE

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: table.pack and LOVE

Post by bartbes »

Be warned that TSerial allows for arbitrary code execution, so it might not be the best idea for networking.
User avatar
Sheepolution
Party member
Posts: 264
Joined: Mon Mar 04, 2013 9:31 am
Location: The Netherlands
Contact:

Re: table.pack and LOVE

Post by Sheepolution »

At what point can it be dangerous though?

As soon as I do Tserial.unpack(table)?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: table.pack and LOVE

Post by Robin »

Yeah.
Help us help you: attach a .love.
User avatar
Sheepolution
Party member
Posts: 264
Joined: Mon Mar 04, 2013 9:31 am
Location: The Netherlands
Contact:

Re: table.pack and LOVE

Post by Sheepolution »

But how? Variables älone can't do much right?
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: table.pack and LOVE

Post by Jasoco »

In Lua, everything is a variable. Including functions and tables and all can be inside each other.
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: table.pack and LOVE

Post 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.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: table.pack and LOVE

Post 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".
User avatar
ArchAngel075
Party member
Posts: 319
Joined: Mon Jun 24, 2013 5:16 am

Re: table.pack and LOVE

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: table.pack and LOVE

Post 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.
Help us help you: attach a .love.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: table.pack and LOVE

Post 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.
When I write def I mean function.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests