The "trusting" in Lua sandbox has had me confused for a long time, so I've decided to settle this and stop wiping out the sandbox after each fresh install once and for all. Here's the problem, in one of Nick's recent posts:
But in my experience, and judging from the sandbox's code, this alone won't work. You'd have to also add the id of each world where this plugin is used to the list of trusted worlds, otherwise the block that checks for trusted worlds will kick in and sandbox the plugin regardless of whether the latter is trusted or not. But both the comments in the sandbox and Nick's post above imply that worlds and plugins should be checked for "trust" separately. Meaning, that if a plugin is trusted but a world it is loaded in is not, then the plugin shouldn't be sandboxed.
On the other hand, I can see a good reason to have the "trustworthyness" of a plugin depend on that of the world - it prevents someone from using one of the default id's, listed above, in his own plugin and thus bypassing the sandbox without the user knowing anything about it. On yet another (third) hand, if to trust a plugin you also have to trust its' world, then the moment you decide to trust any legit plugin, you open yourself up for this "default id" trick.
The only way to safeguard yourself against it is to keep any plugins you don't actually have installed off the "trust" list, since two plugins with the same id can't be loaded at the same time.
So, what did you have in mind, Nick? Please clarify.
To clarify my own view: I believe keeping plugins separate from worlds makes more sense than the way it works now. If you are interested, I have the code to implement it and could look into some way of enforcing the "only loaded plugins can be trusted" rule also.
Quote:
Slightly safer is not to trust all plugins but instead add one line further down:
-- Plugin IDs of plugins we trust - add your plugins to the table
local trusted_plugins = {
[""] = "", -- trust main script (ie. if no plugin running)
["03ca99c4e98d2a3e6d655c7d"] = "Chat",
["982581e59ab42844527eec80"] = "Random_Socials",
["4a267cd69ba59b5ecefe42d8"] = "Installer_sumcheck",
["83beba4e37b3d0e7f63cedbc"] = "Reconnecter",
["35dfdbf3afc8cbf60c91277c"] = "xCreate_World_File", --> add this line
} -- end of trusted_plugins
Slightly safer is not to trust all plugins but instead add one line further down:
-- Plugin IDs of plugins we trust - add your plugins to the table
local trusted_plugins = {
[""] = "", -- trust main script (ie. if no plugin running)
["03ca99c4e98d2a3e6d655c7d"] = "Chat",
["982581e59ab42844527eec80"] = "Random_Socials",
["4a267cd69ba59b5ecefe42d8"] = "Installer_sumcheck",
["83beba4e37b3d0e7f63cedbc"] = "Reconnecter",
["35dfdbf3afc8cbf60c91277c"] = "xCreate_World_File", --> add this line
} -- end of trusted_plugins
But in my experience, and judging from the sandbox's code, this alone won't work. You'd have to also add the id of each world where this plugin is used to the list of trusted worlds, otherwise the block that checks for trusted worlds will kick in and sandbox the plugin regardless of whether the latter is trusted or not. But both the comments in the sandbox and Nick's post above imply that worlds and plugins should be checked for "trust" separately. Meaning, that if a plugin is trusted but a world it is loaded in is not, then the plugin shouldn't be sandboxed.
On the other hand, I can see a good reason to have the "trustworthyness" of a plugin depend on that of the world - it prevents someone from using one of the default id's, listed above, in his own plugin and thus bypassing the sandbox without the user knowing anything about it. On yet another (third) hand, if to trust a plugin you also have to trust its' world, then the moment you decide to trust any legit plugin, you open yourself up for this "default id" trick.
The only way to safeguard yourself against it is to keep any plugins you don't actually have installed off the "trust" list, since two plugins with the same id can't be loaded at the same time.
So, what did you have in mind, Nick? Please clarify.
To clarify my own view: I believe keeping plugins separate from worlds makes more sense than the way it works now. If you are interested, I have the code to implement it and could look into some way of enforcing the "only loaded plugins can be trusted" rule also.