LuaJIT 2.1.1774638290 - Arbitrary Code Execution
LuaJIT 2.1.1774638290 - Arbitrary Code Execution đ¨
An exploit titled âLuaJIT 2.1.1774638290 - Arbitrary Code Executionâ was released on March 29, 2026 by author TaurusOmar. This vulnerability targets LuaJIT 2.1.1774638290 (latest version), verified on Linux x86-64 (Arch Linux). LuaJITâs Foreign Function Interface (FFI) provides unrestricted access to native C functions including syscall(), mmap(), mprotect(), and arbitrary shared library loading. When FFI is accessible to untrusted Lua code in embedding scenarios (OpenResty, Redis, game engines, IoT), an attacker can achieve arbitrary code execution with full process privileges including shellcode execution via mmap(RWX) + ffi.copy() + ffi.cast().
This affects any application embedding LuaJIT 2.1.x without explicitly disabling FFI (-DLUAJIT_DISABLE_FFI) or removing it from the sandbox environment before executing untrusted scripts. The vulnerability was verified on LuaJIT 2.1.1774638290 (March 2026) â the latest version. Attack scenarios include OpenResty/Nginx with user-controlled Lua scripts, Redis with exposed EVAL interface, game engines with Lua modding systems, and IoT devices with Lua scripting interface.
The provided Proof of Concept (PoC) demonstrates âFFI Unrestricted Syscall Accessâ. It shows ffi.C.getpid() via dlsym, noting that âdlsym resolves libc symbols without restrictionâ, and also via direct syscall(39), confirming âBoth channels confirmed activeâ. The PoC outlines ASLR bypass via /proc/self/maps to find the âlibc baseâ. Arbitrary command execution is achieved through ffi.C.system('id'), demonstrating direct execution of system commands. Most critically, the PoC illustrates shellcode execution via mmap(RWX). This involves mapping an RWX region, copying a specific x86-64 shellcode for execve('/bin/sh', NULL, NULL) into it, and then executing the copied shellcode, resulting in the message âShellcode written. Executing execve(â/bin/shâ)âŚâ.
Mitigation steps are crucial to prevent this arbitrary code execution. Organizations should compile with -DLUAJIT_DISABLE_FFI or remove âffiâ from the sandbox environment table. Additionally, applying OS-level restrictions such as seccomp-bpf, AppArmor, or namespaces is recommended.