Luarocks.org remote code execution exploit
The luarocks.org rockspec parser loaded untrusted input with loadstring(), which also accepts precompiled Lua bytecode, and the sandbox did not verify it. An attacker with a regular account could upload crafted bytecode that reads out-of-bounds memory, finds the package.loaded table, reaches the global environment through debug.getfenv, and runs arbitrary Lua code as root on the server.
vhyrro.neorg.org
Published on vhyrro.neorg.org
Today I am going to do a technical writeup like I’ve never done before: about an incredibly dangerous remote code execution vulnerability, allowing anybody to take over the entirety of luarocks.org — a massive repository of Lua packages, with the most downloaded package sitting at 24 million downloads.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the parser passed untrusted uploads to loadstring(), which silently accepts precompiled bytecode, and the sandbox relied on setfenv plus a debug hook without verifying that the input was source text.
Impact
An attacker with a regular account could run arbitrary Lua code with root privileges on the server, and the text says the exploit was actively used since July 2026 to run shell commands and attempt a remote shell.
What the attacker needed
A regular user account; ability to upload a package
How it was found
- Create a regular account and prepare a rockspec for upload.
- Compile the rockspec to bytecode and patch the KNUM and ISNEP instructions so reads go out of bounds and comparisons test for tables.
- Upload the modified bytecode so the site loads and runs it.
- Scan the out-of-bounds memory for the package.loaded table and confirm the hit by changing the package description.
- Use debug.getfenv on itself to obtain the global environment and call loadstring with the final payload.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A rockspec is a small Lua script that describes a package, and the site runs it to read the details. Lua can also load a compiled form of a script called bytecode, and the site did not check that the uploaded file was plain text. By hand-editing that bytecode, the author made the program read memory it should not see and eventually run their own code on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.