Skip to content

v0.5.4 - security: limit overruns cannot be hidden, budgeted lookups and close; lua2js keeps Lua truth

Choose a tag to compare

@datamoc datamoc released this 11 Oct 08:32
· 37 commits to master since this release

Security (execution limits) - do not use 0.4.x to 0.5.3 for untrusted scripts with limits:

  • A limit overrun could be hidden by the script: a coroutine created by Lua that exceeded the budget made coroutine.resume / pcall return normally and vm.run() returned its value. Every host entry point (run, call, callRef, Coroutine#resume, protect) now fails with a LimitError whenever a limit was hit during the call, even if Lua caught it.
  • Coroutine#close() ran its __close handlers without a budget; it now gets a fresh one.
  • Global path lookups (call, callMulti, compile, coroutine) ran before the budget, so an __index metamethod on _G could loop forever. They now run in a protected call under the limits.
  • sandbox: true no longer leaves the __random helper readable as a global.

lua2js: a or b was translated to a ?? b, which returns false where Lua returns b. It now keeps Lua's meaning; the old form is the nullishOr option (--nullish-or).

New: print option ('buffer' | 'native' | false) so a host no longer re-opens libraries to get Lua's own print (which restored string.dump after the sandbox removed it); LuaRef.type is typed 'function' | 'thread' | 'userdata'; vm.resolvePath, vm.failIfLimitHit declared.

Docs: compile is intentionally disabled while limits are active (see the README).

See CHANGES.md for details.