/

CVE-2026-41196

Severity:

CRITICAL RISK

(10.0)

Code Injection / Sandbox Escape in Luanti / Minetest Mods

CVE-2026-41196

Analyzed

Vulnerability type

Category:

Code Injection / Sandbox Escape

CWE:

CWE-94

Impact:

Arbitrary Code Execution with Local Filesystem Access

Severity:

CRITICAL RISK

(10.0)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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 getfenv under 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.

Sources

SourceLink
github.comgithub.com/luanti-org/luanti/commit/8a929dfb97aa08337f49ba1bb96a56d6557dc896
github.comgithub.com/luanti-org/luanti/security/advisories/GHSA-g596-mf82-w8c3

Frequently asked

questions

Yes, in practice it can be. If a user connects to a server that provides malicious mods, or installs a malicious third-party mod, the attacker-controlled Lua code can be executed and escape the sandbox when LuaJIT is enabled. This can lead to arbitrary code execution on the client or server host.

An attacker must be able to cause vulnerable Lua mod code to run. That typically means controlling or influencing server-side mods, distributing a malicious mod that users install, or otherwise getting their Lua code executed within the Luanti / Minetest environment configured with LuaJIT.

The robust pattern is to harden the Lua sandbox by removing or gating powerful reflection and environment-control functions, reducing the Lua API surface exposed to mods, and ensuring that the scripting runtime cannot directly reach host-level capabilities. Any APIs that must perform privileged actions should be tightly controlled and mediated by the engine.

When embedding a scripting language, design the sandbox up front with a minimal, well-defined API; avoid exposing low-level reflection, debug, or environment manipulation features; regularly audit the exposed functions for escape vectors; and reinforce sandboxing with OS-level isolation (reduced privileges, separate processes, containers) so that a scripting escape does not immediately equate to full system compromise.

Find out what's already
exploitable in your codebase.