3 ms·
Lua isn't really sandbox friendly, although that's a common misconception. Lua (by design) doesn't provide termination guarantees or a good way to force an unt
by miki123211 2y ago
Lua isn't really sandbox friendly, although that's a common misconception.
Lua (by design) doesn't provide termination guarantees or a good way to force an untrusted program to terminate. If you accept untrusted lua input, be prepared for your program to halt indefinitely.
Lua is great for semi-trusted input, AKA things you download from the internet, where you do a minimal amount of due diligence, but in case the code is actually malicious, you want to severely limit (but not completely eliminate) the harm it can do.
If you actually need Javascript-style completely untrusted input,, what you want is the Roblox fork called Luau[1].
[1] https://luau-lang.org/sandbox https://luau-lang.org/sandbox
- grashalm 2y agoAny language can be sandboxed on the VM level. It's a property of it's implementation. So you can say that Lua has no sandbox friendly implementation right now. For example, termination you can solve by unwinding the stack in efficiently polled safepoints. You need to take down the entire sandbox-capable Lua VM instance but you can.
- le-mark 2y agoLua has debug hooks that can be used for the purpose; for example an instruction counter coupled with a pool allocator should get one quite far. I would never trust third party bytecode, only source code. Is anyone familiar with Roblox luau security features?
- Ono-Sendai 2y agoLuau can be sandboxed, and scripts limited in cpu and memory usage.