Skip to content
Exploit for CVE-2026

Exploit for CVE-2026

Sploitus • November 25, 2026

[![Research status: validated](

| **Component** | OpenResty — `src/ngx_stream_lua_socket_tcp.c::ngx_stream_lua_socket_tcp_finalize_read_part` |

| **Impact** | A `receiveuntil` iterator's compiled pattern held a back-pointer to the socket. When a read error occurred, the iterator could be garbage-collected after the socket was finalized; its `__gc` handler then wrote through the dangling pointer. A remote peer able to trigger the read-error path could corrupt runtime memory |

| **Vector** | client that drives a stream-lua socket into a read error while an iterator exists |

| **Trigger** | iterator GC running after socket finalization |

// pre-fix (verbatim behavior in the lab)

// finalize_read_part did not detach the compiled pattern's back-pointer

// cp->upstream still referenced the socket to be freed

The fix detaches the back-pointer before teardown:

// fixed (commit 7581c68b, verbatim in the lab)

if (u->input_filter_ctx != NULL && u->input_filter_ctx != u) {

((ngx_stream_lua_socket_compiled_pattern_t *)

The socket's `input_filter_ctx` owned a compiled pattern whose `__gc` handler

dereferenced `upstream` back to the socket. Finalization freed the socket

without first clearing that link, so the Lua collector's later `__gc` call

operated on freed memory. The fix severs both directions of the reference

| `lua-vuln` | `cve-2026-136412:vuln` | dangling back-pointer |

| `lua-fixed` | `cve-2026-136412:fixed` | verbatim detach guard |

| `poc` | `cve-2026-136412-poc:local` | stdlib-only Python driver |

Both target images are compiled with AddressSanitizer. The C harness frees the

socket, then invokes the iterator's `__gc` handler, reproducing the exact

./run-lab.sh build # builds both sides (gcc 14, ASan)

./run-lab.sh up # cve136412lab network: lua-vuln / lua-fixed

* **check** — exit 1 when ASan reports the UAF, 0 when shutdown is clean;

* **exploit** — narrated chain: read error → iterator GC → `__gc` through freed

* **probe** — crash status and sanitizer report.

* **mitigation** — `7581c68b` / detach `cp->upstream`.

A standalone full-chain exploit ships at `exploit/exploit.py`:

python3 exploit/exploit.py --host=lua-vuln

# exit 1 on confirmed ASan UAF, 0 on a safe target

| | `lua-vuln` (pre-fix) | `lua-fixed` (`7581c68b`) |

| socket freed before iterator `__gc` | **ASan `heap-use-after-free`** | **`clean shutdown`** |

Captured runs: `evidence/check-*-run.txt`, `evidence/exploit-*-run.txt`,

`evidence/probe-*-run.txt`, `evidence/mitigation-*-run.txt`,

`evidence/exploit-standalone-run.txt`, `evidence/exploit-standalone-fixed-run.txt`,

`evidence/versions.txt`, `evidence/0day-sweep.txt`.

* Podman (or Docker); bounded containers on the isolated `cve136412lab`

* Real-world exploitation requires a stream-lua application using

`receiveuntil` on a socket that can be driven into a read error.

## 7. Additional findings (0-day sweep on the fixed line)

`finalize_read_part()` detaches the compiled pattern's `upstream` pointer and

clears `input_filter_ctx`, so a later `__gc` cannot touch a freed socket. Normal

`receiveuntil` iterators that are collected before socket close remain

run-lab.sh environment driver (build / up / sweep / down)

Makefile convenience targets

poc/poc.py the PoC (check / exploit / probe / mitigation)

exploit/exploit.py standalone full-chain exploit

lab/harness-*.c verbatim detach guard per side (ASan)

lab/service.py HTTP wrapper (POST /check), child-process isolation

evidence/ captured runs of every mode on both sides

TRACKING.md excluded (working record)

* CVE record —

* Fix commit —

Extracted Entities

CWE Weaknesses (1)

Platforms (1)