Summary
Luanti (formerly Minetest) contains a sandbox escape issue in its Lua execution environment that allows malicious mods to inject and execute arbitrary native code on a player's machine when LuaJIT is enabled.
Under affected versions, hostile server-side or client-side mods can break out of the intended sandbox, gaining full filesystem access and running arbitrary commands as the local user.
Affected context
The vulnerability occurs in Luanti / Minetest installations that:
- Run versions from 5.0.0 up to (but not including) 5.15.2
- Use LuaJIT as the Lua runtime for mods
- Load and execute untrusted or semi-trusted mods from servers or third parties
It affects multiple Lua execution environments, including:
- Server-side mods
- Asynchronous (async) and map generation (mapgen) scripts
- Client-Side Mods (CSM)
The issue is relevant when the game engine expects Lua code to be sandboxed but the environment still exposes escape primitives.
Exploit preconditions
- Attack surface: Mod execution environments in Luanti / Minetest (server-side, async/mapgen, and client-side mods) when LuaJIT is enabled.
- Required access:
- An attacker must be able to introduce a malicious mod:
- As a server operator or contributor controlling server-side mods, or
- As a third-party mod author whose mod is installed by users, or
- Through any mechanism that results in untrusted Lua code being executed by the client.
- Trigger point: The vulnerable Lua APIs are accessed during normal mod execution, allowing the mod to bypass sandbox restrictions.
- Why exploitation is possible: The Lua sandbox still exposes environment manipulation functionality (such as
getfenvunder LuaJIT) that can be combined with JIT/runtime features to access the underlying host environment, breaking the intended isolation guarantees and enabling arbitrary code injection (CWE-94).
Why this happens
At its core, this vulnerability is a sandbox design flaw: the Lua environment used for mods is intended to be restricted but still exposes powerful reflective capabilities.
Functions like getfenv allow Lua code to inspect and manipulate function environments, which, under LuaJIT, can interact with implementation details that the sandbox does not fully constrain.
This falls under CWE-94: Improper Control of Generation of Code, where untrusted Lua scripts can effectively generate or obtain executable code outside the intended policy boundaries.
The sandbox does not sufficiently remove or wrap these dangerous constructs in LuaJIT contexts, enabling a malicious mod to escalate its privileges from "scripted game logic" to full process-level code execution and filesystem access.
Potential impact
- Execution of arbitrary native or OS-level code with the privileges of the game process
- Full read/write access to the local filesystem (player's machine or server host)
- Theft or modification of user data, game worlds, configuration files, and credentials stored on disk
- Installation of additional malware, backdoors, or persistence mechanisms
- Use of compromised systems as part of a wider attack (e.g., botnets, lateral movement within a network)
- Undermining trust in community mods and servers due to potential silent compromise
General mitigation guidance
Effective mitigation focuses on hardening the Lua sandbox and shrinking the trust boundary around mod code:
- Remove or disable environment and reflection primitives (e.g.,
getfenv) that allow manipulating or escaping the sandbox. - Prefer a security-by-default scripting configuration where only a minimal, well-audited subset of Lua APIs is exposed to mods.
- Treat all mod code as untrusted by default and design the API surface so that it cannot reach host-level functionality (filesystem, OS commands) without explicit mediation.
- Use defense-in-depth: combine language-level sandboxing with process-level isolation where feasible (e.g., separate processes, reduced OS privileges, or containers for untrusted mods).
- Encourage mod authors to avoid relying on low-level reflection features that complicate sandboxing, and document safe alternatives.
- Apply least-privilege principles to the game process itself (no unnecessary OS-level permissions, constrained directories, and limited access to sensitive user data).
How teams detect issues like this
Detection can rely on a combination of static review and behavioral monitoring:
- Static analysis / code search:
- Scan mod and engine code for use of reflective or environment-manipulating functions (such as
getfenv,setfenv, raw access to debug APIs, or direct FFI/JIT hooks). - Flag patterns where mod code directly accesses global environments, debug libraries, or non-documented engine internals.
- Code review signals:
- Mods that require unusually broad access to engine internals, filesystem-like operations, or OS integration should receive deeper review.
- Any mod relying on LuaJIT-specific tricks or undocumented behavior is a candidate for scrutiny.
- Policy and tooling:
- Enforce policy that restricts or bans certain Lua APIs in mods and validates this during CI or mod publishing.
- Use automated linters or security-focused static analysis tools that understand Lua to catch risky patterns before deployment.
- On the platform side, add runtime assertions or logging when high-risk APIs are accessed from mod contexts to help identify abuse or unexpected usage.

