Is there a hardening guide for Luau? #1311
Replies: 2 comments
-
Freezing metatables is sensible. You might prefer using a lightweight timer (something like I don't recall the specifics, but I believe there's also a way to throw a lua memory error on alloc failures so that it can be caught in a Do you have a |
Beta Was this translation helpful? Give feedback.
-
Hi Harold, I'm not currently worried about user Lua code being able to handle out of memory errors. Yes I do call luaL_sandboxthread. Can you explain why freezing metatables is a good idea? |
Beta Was this translation helpful? Give feedback.
-
Hi all,
Soon I will be deploying some code to execute Luau scripts on my metaverse server. Since the scripts will be user-created (e.g. untrusted), I would like the sandboxing to be as effective as possible.
Is there a guide for this somewhere?
So far I have done:
calling lua_newstate and luaL_sandbox on scripts. (https://github.com/glaretechnologies/glare-core/blob/533531267d2b3bfac955993964355d3e4eef41a9/lua/LuaVM.cpp#L147)
Limited memory use by supplying a custom memory allocator (https://github.com/glaretechnologies/glare-core/blob/533531267d2b3bfac955993964355d3e4eef41a9/lua/LuaVM.cpp#L19)
Limiting script execution CPU time by counting interrupts and throwing an exception if some threshold is exceeded. (https://github.com/glaretechnologies/glare-core/blob/533531267d2b3bfac955993964355d3e4eef41a9/lua/LuaVM.cpp#L62)
Is there anything else I need to do?
What about freezing or protecting metatables?
Beta Was this translation helpful? Give feedback.
All reactions