Parts of the Lua 5.x standard library are unsafe. Some of the functions provide access to the host operating system, including process execution and file reads. Some functions lack sufficient memory safety checks. Some functions are safe if all code is untrusted, but can break the isolation barrier between trusted and untrusted code.
The following libraries and global functions have been removed as a result:
-
io.
library has been removed entirely, as it gives access to files and allows running processes
-
package.
library has been removed entirely, as it gives access to files and allows loading native modules
-
os.
library has been cleaned up from file and environment access functions (execute
, exit
, etc.). The only supported functions in the library are clock
, date
, difftime
and time
.
-
debug.
library has been removed to a large extent, as it has functions that aren’t memory safe and other functions break isolation; the only supported functions are traceback
.
-
dofile
and loadfile
allowed access to file system and have been removed.
These features are cool to have deleted if you want to make a game like Roblox, but not when making games where you trust your code and want access to these functions.
When initializing the default globals table, the tables are protected from modification:
- All libraries (
string
, math
, etc.) are marked as readonly
- The string metatable is marked as readonly
- The global table itself is marked as readonly
In other word, no monkey patching of builtin functions.
Seems like Luau would be a great fit if you want to make a game like Roblox which is itself a game development / publishing platform, or you want to make a game which is very mod friendly but also has security better built in.