MUSHclient 3.80 moves to Lua version 5.1. This has many improvements as described here:
http://www.gammon.com.au/forum/?id=7322
However a potential security problem is that the "loadlib" function has been moved from the base library to the package library, where the package library did not exist in earlier versions of Lua.
My concerns with loadlib are that it can be used to load any DLL into the Lua address space (and thus the MUSHclient address space).
This is certainly useful for various cases that have been documented on this web site, including:
However it also gives malicious coders a tool to inject viruses or trojan horse programs onto your PC. The general technique would be this:
In the past MUSHclient has had a "Lua sandbox" which has removed access to the loadlib function, like this:
There are also comments in the standbox showing how that it can be enabled for trusted plugins.
However the problem with Lua 5.1 is that the loadlib function is no longer in the global environment, and thus setting loadlib to nil does nothing, as it is already nil.
Loadlib is now inside the "package" library (package.loadlib).
To work around this issue, MUSHclient version 3.80 has a new checkbox on the Global Configuration Dialog (Lua sandbox page) called "Enable Package Library" which defaults to off. With this unchecked, MUSHclient removes the entire package library from the Lua address space while loading the Lua engine.
To preserve the security of your system, you are encouraged to leave this unchecked.
If you need to use loadlib (eg. to access a database) then you should edit the sandbox code and change:
You should probably follow the guidelines in the comments in the sandbox, and only allow the use of loadlib for trusted plugins.
[EDIT]
This is no longer the case, exactly, see below.
http://www.gammon.com.au/forum/?id=7322
However a potential security problem is that the "loadlib" function has been moved from the base library to the package library, where the package library did not exist in earlier versions of Lua.
My concerns with loadlib are that it can be used to load any DLL into the Lua address space (and thus the MUSHclient address space).
This is certainly useful for various cases that have been documented on this web site, including:
- Use of the MySQL database library
- Use of the ODBC database library
- Use of the LuaSocket library
- Use of the Lua COM library
- Use of the Logitech G15 keyboard library
- Use of the encryption library
However it also gives malicious coders a tool to inject viruses or trojan horse programs onto your PC. The general technique would be this:
- Write a virus or trojan horse as a DLL, which will have access to all of the Windows system libraries, including file IO, access to the Internet and so on
- Write a plugin which claims to do something useful (eg. a mapper)
- Claim that the plugin "must have" the DLL in order to operate properly
- Distribute both from a web site operated by the malicious coder, and encourage their use
- Once installed the DLL could cause various sorts of havoc
In the past MUSHclient has had a "Lua sandbox" which has removed access to the loadlib function, like this:
loadlib = nil
There are also comments in the standbox showing how that it can be enabled for trusted plugins.
However the problem with Lua 5.1 is that the loadlib function is no longer in the global environment, and thus setting loadlib to nil does nothing, as it is already nil.
Loadlib is now inside the "package" library (package.loadlib).
To work around this issue, MUSHclient version 3.80 has a new checkbox on the Global Configuration Dialog (Lua sandbox page) called "Enable Package Library" which defaults to off. With this unchecked, MUSHclient removes the entire package library from the Lua address space while loading the Lua engine.
To preserve the security of your system, you are encouraged to leave this unchecked.
If you need to use loadlib (eg. to access a database) then you should edit the sandbox code and change:
loadlib = nil
to:
package.loadlib = nil
You should probably follow the guidelines in the comments in the sandbox, and only allow the use of loadlib for trusted plugins.
[EDIT]
This is no longer the case, exactly, see below.