|  | 
 
 Differences from Standard Lua
  LuaSandbox provides a sandboxed environment which differs in some ways from standard Lua 5.1.
  
  Features that are not available
    
    
     
      dofile(),loadfile(), and theiopackage, as they allow direct filesystem access. If needed, filesystem access should be done via PHP callbacks.
     
      The packagepackage, includingrequire()andmodule(), as it depends heavily on direct filesystem access. A pure-Lua rewrite such as that used in the MediaWiki Scribunto extension may be used instead.
     
      load()andloadstring(), to allow for static analysis of Lua code.
     
      print(), since it outputs to standard output. If needed, output should be done via PHP callbacks.
     
      Most of the ospackage, as it allows manipulation of the process and executing of other processes. 
      
     
      Most of the debugpackage, as it allows manipulation of Lua state and metadata in ways that can break sandboxing. 
      
     
      string.dump(), as it may expose internal data.
     
      collectgarbage(),gcinfo(), and thecoroutinepackage have not been reviewed for security. 
  Features that have been modified
    
    
     
      pcall()andxpcall()cannot catch certain errors, particularly timeout errors.
     
      tostring()does not include pointer addresses.
     
      string.match()has been patched to limit the recursion depth and to periodically check for a timeout.
     
      math.random()andmath.randomseed()are replaced with versions that don't share state with PHP'srand().
     
      The Lua 5.2 __pairsand__ipairsmetamethods are supported bypairs()andipairs(). |