wateret / mengde

A turn-based RPG game engine inspired by 三國志曹操傳.
MIT License
27 stars 10 forks source link

Sandboxing Lua scripts #138

Closed wateret closed 4 years ago

wateret commented 5 years ago

Lua scripts can do almost everything to our running environment. But this could be vulnerable so we need to limit if some features are not necessary for scenario scripts and may be harmful. E.g. access to file system

Currently I am not 100% sure on this concept and what features to prohibit.

References for studying "Sandboxes"

http://lua-users.org/wiki/LuaSecurity http://lua-users.org/wiki/SandBoxes https://en.wikipedia.org/wiki/Sandbox_(computer_security) https://stackoverflow.com/questions/1224708/how-can-i-create-a-secure-lua-sandbox

Features to prohibit

...

wateret commented 5 years ago

https://sol2.readthedocs.io/en/latest/api/state.html#state-script-function

wateret commented 4 years ago

Do we need to use sol::environment? -> I don't see the reason for now.

I am not sure about this but the strategy for now is unset UNSAFE functions that are loaded by open_libraries().