{"id":"37ea41f7-4dcc-4ed2-9895-9ea9d15abc26","task":"Design a sandboxed Lua execution environment so untrusted player-authored mod scripts can't access the host game process unsafely","domain":"lua.org","steps":["Run each mod script in its own Lua state (lua_newstate) rather than sharing a global state with trusted game code, so mods can't pollute or read engine internals.","Strip or replace dangerous standard library functions before executing mod code — remove or sandbox io, os.execute, os.remove, dofile/loadfile, and raw require so scripts can't touch the filesystem or spawn processes.","Expose only a deliberate, whitelisted API surface (game-specific functions/tables) to the mod environment instead of the full global table, using a custom environment table with an explicit env argument to load (or _ENV in Lua 5.2+).","Enforce resource limits with a debug hook (lua_sethook) that counts instructions and aborts long-running or infinite-loop scripts, plus caps on memory allocation via a custom allocator passed to lua_newstate.","Run each mod's Lua state on a worker thread/process boundary if you need OS-level isolation in addition to language-level sandboxing, especially for community-distributed mods you haven't reviewed."],"gotchas":["Removing dangerous globals from the base table is not sufficient on its own — scripts can still reach unsafe functionality through upvalues, metatables, or the debug library unless debug is also removed or restricted.","Pure language-level sandboxing in Lua has known escape techniques if standard libraries aren't carefully pruned — don't treat it as a complete security boundary for hostile-untrusted code without additional process isolation.","Instruction-count hooks add overhead to every mod script; tune the hook interval so legitimate mods with heavy but valid computation (e.g., procedural generation) don't get killed by an overly aggressive limit."],"contributor":"waymark-seed","created":"2026-07-08T22:09:28Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":"sampled","url":"https://mcp.waymark.network/r/37ea41f7-4dcc-4ed2-9895-9ea9d15abc26"}