News Security & Bugs

OpenResty Stream Lua Flaw CVE-2026-136412: How to Check and Update

A use-after-free in OpenResty's stream-lua-nginx-module before 0.0.20rc4 can crash or corrupt an nginx worker. Who is affected, how to check your build, and how to update to OpenResty 1.31.9.1.

A memory-safety flaw in OpenResty's stream-lua-nginx-module, the module that runs Lua code for TCP and UDP services in nginx, was published on 24 November 2026 as CVE-2026-136412. All versions of the module before 0.0.20rc4 are affected. A remote peer that breaks a connection at the right moment can make an nginx worker process read memory that was already freed, which crashes the worker or corrupts its memory.

The fix is in module version 0.0.20rc4, which ships in OpenResty 1.31.9.1, released on 23 November 2026. Plain nginx does not include this module and is not affected by this CVE.

How serious it is

The CVE record was issued by VulnCheck, not by the OpenResty project, and carries two scores:

Scoring systemScoreRating
CVSS 4.09.2Critical
CVSS 3.18.1High

Both vectors say the attack works over the network without an account, and both rate the attack complexity as high: the attacker has to hit a timing condition. The record describes a crash or memory corruption of the worker. It does not claim that code execution has been demonstrated, and it contains no statement about attacks in the wild. On 26 November 2026 we found no report of exploitation, which is not the same as proof that none exists.

Even the crash matters. When a worker dies, every connection it was handling is dropped, and nginx starts a new one. An attacker who can repeat the trigger can keep a TCP proxy unstable.

What goes wrong

Lua code in OpenResty talks to the network through "cosockets". receiveuntil() is the cosocket call that returns an iterator for reading data up to a delimiter, for example up to the next line break. According to the CVE record, the bug appears when that iterator is garbage-collected by Lua while the socket still holds a pointer to its compiled pattern. If the peer then interrupts or closes the connection, a later read or the socket cleanup uses the stale pointer.

Two commits in the module's repository address it: one from 16 September 2026 and a second from 17 November 2026 that detaches the pattern after every read. Only 0.0.20rc4 contains both.

Are you affected?

You are exposed only if all three are true:

  • you run OpenResty, or nginx compiled with stream-lua-nginx-module, older than 0.0.20rc4;
  • the configuration has a stream { } block that runs Lua (directives such as content_by_lua_block or preread_by_lua_block inside stream);
  • that Lua code, or a library it loads, calls receiveuntil().

An OpenResty server that only serves HTTP does not run this module's code. The CVE covers the stream module only; the HTTP Lua module is a separate code base and is not named in the record.

Check the module version in your build. OpenResty prints its build options, including the bundled module directories with their versions:

openresty -v
openresty -V 2>&1 | tr ' ' '\n' | grep -i stream_lua

A line ending in ngx_stream_lua-0.0.20rc3 or lower means the build is affected. If the second command prints nothing, the module is not compiled in. Then check whether the configuration and code use it:

sudo openresty -T 2>/dev/null | grep -n -E "^\s*stream\s*\{|_by_lua"
sudo grep -rn "receiveuntil" /usr/local/openresty/nginx/conf /usr/local/openresty/site/lualib /usr/local/openresty/lualib

Adjust the paths to where your Lua code lives. These commands follow the OpenResty documentation and were not run on a test server for this article.

For reference, the module version bundled with recent OpenResty releases, read from the release build scripts in the OpenResty repository:

OpenRestyBundled stream-lua moduleStatus
1.31.9.10.0.20rc4Fixed
1.31.8.10.0.20rc3Affected
1.31.1.10.0.19rc4Affected
1.29.2.4, 1.29.2.50.0.19rc3Affected

Update from the official packages

The 1.31.9.1 announcement says pre-built Linux packages are available. We did not confirm the package version in each repository, so look at what your system offers before upgrading:

# Ubuntu, Debian
sudo apt update
apt-cache policy openresty
sudo apt install --only-upgrade openresty

# AlmaLinux, Rocky Linux, RHEL
sudo dnf check-update openresty
sudo dnf upgrade openresty

The candidate version should start with 1.31.9.1. Test the configuration and restart. A reload is not enough after a binary upgrade, because the running master process still uses the old binary:

sudo openresty -t
sudo systemctl restart openresty
openresty -V 2>&1 | tr ' ' '\n' | grep -i stream_lua
systemctl status openresty --no-pager

The version line should now end in 0.0.20rc4. A restart drops open connections; on a busy TCP proxy, do it in a quiet period.

Update a source build

If you compiled OpenResty yourself, rebuild with the same options. Save them first:

openresty -V 2>&1 | grep "configure arguments" > ~/openresty-configure-args.txt

cd /usr/local/src
curl -O https://openresty.org/download/openresty-1.31.9.1.tar.gz
curl -O https://openresty.org/download/openresty-1.31.9.1.tar.gz.asc
gpg --verify openresty-1.31.9.1.tar.gz.asc openresty-1.31.9.1.tar.gz
tar -xzf openresty-1.31.9.1.tar.gz
cd openresty-1.31.9.1

gpg --verify needs the OpenResty signing key in your keyring; the key is given on the download page. Then run ./configure with the options you used before. The saved line contains internal options added by OpenResty's own script, so take your original command from your notes or build script if you have it, and use the saved line to check that nothing is missing.

./configure --prefix=/usr/local/openresty --with-stream --with-stream_ssl_module   # your own options here
make -j"$(nproc)"
sudo make install
sudo openresty -t && sudo systemctl restart openresty

If you build stock nginx and add the module with --add-module, check out tag v0.0.20rc4 of stream-lua-nginx-module, rebuild nginx against it and restart. The module's documentation lists which nginx and lua-resty-core versions it is tested with; mixing versions can fail at start-up.

If you cannot update yet

The CVE record lists no workaround. What reduces exposure in the meantime is our own suggestion, not vendor guidance:

  • limit who can reach the stream listeners with the firewall, if the service is not meant for the whole internet; see VPS firewall setup;
  • watch the error log for workers that exit on a signal, which is how a crash shows up: sudo grep -E "exited on signal" /usr/local/openresty/nginx/logs/error.log | tail.

Products built on OpenResty, such as API gateways, ship their own copy of the module. Their status is not covered by this CVE record and we did not check them; follow the vendor's advisory and do not replace their bundled OpenResty by hand.

One more reason to move to 1.31.9.1

The same release updates the nginx core to 1.31.9, which according to the announcement brings in 10 upstream security fixes, including the HTTP/2 flaws we covered in the nginx HTTP/2 advisory. An OpenResty server that only serves HTTP is not affected by CVE-2026-136412 but still needs this update for those.

Sources: the CVE record and advisory published by VulnCheck, the two patch commits, and OpenResty's 1.31.9.1 announcement, change log and download page. The finder is credited in the record as Nuno of Maze HQ.

Share story:

Continue reading other guides on How VPS.