Sungho Park

#45331of 61,220
7Total CVSS
Vulnerabilities · 1
PT-2026-157779
2026-11-24
7.0
CVE-2026-116293
Erlang
Otp
## Summary Out-of-bounds Write vulnerability in the external term format decoder in Erlang OTP erts allows an attacker who controls the input to `binary to term/1,2` to abort the Erlang VM via a `NEWER REFERENCE EXT` term with a zero-length ID. `decoded size` in `erts/emulator/beam/external.c` accepts a reference whose 16-bit `Len` field is zero, but `dec term` always reads one ID word. `dec term` then runs 4 bytes ahead of the position that `decoded size` validated. It decodes the bytes that follow as terms that were never sized, and writes past the reserved process heap. The abort takes down every process on the node. Supervision, `try`/`catch` and the `safe` option do not prevent it. `enif binary to term()` and the distribution protocol reach the same decoder, and distribution is assumed to run on trusted networks only. `NEW REFERENCE EXT` also accepts a zero length, but its range check on the first ID word rejects the shifted input. On 32-bit builds, a zero-length reference of either type at the end of the input, followed by trailing bytes, can write one word past the reserved heap. This issue affects OTP from OTP 17.0 before OTP 27.3.4.20, OTP 28.5.0.9, and OTP 29.1.3, corresponding to erts from 6.0 before 15.2.7.15, 16.4.0.8, and 17.1.2. Whether OTP before OTP 17.0, corresponding to erts before 6.0, is affected is unknown. ## Details **1. Size pass.** `binary to term int` first calls `decoded size` to reserve the process heap. For `NEWER REFERENCE EXT`, `decoded size` rejects an ID-word count above `ERTS MAX REF NUMBERS` but not a count of zero. With `Len` 0 it skips the tag, the length, the node atom and the 4-byte creation, and no ID bytes. **2. Decode pass.** `dec term` reads `Len`, the node atom and the creation, then reads the first ID word `r0` without checking `Len`. From here `dec term` is 4 bytes ahead of the position `decoded size` validated. **3. Heap overrun.** In the reported input, the reference is followed by a `BINARY EXT`. `decoded size` treats the binary payload as opaque bytes. The shifted `dec term` consumes the binary tag and the top three length bytes as `r0`, reads the low length byte (105, `LARGE TUPLE EXT`) as the next tag, and builds a tuple from the payload. The tuple-build loop stores past the heap that was reserved for a reference and a binary. **4. Abort.** After `dec term` returns, `binary to term int` compares the heap pointer with the reserved end and calls `erts exit` with `heap overrun`. That check runs after the out-of-bounds stores. Larger inputs can fault with SIGSEGV first. **`NEW REFERENCE EXT`.** Tag 114 also accepts `Len` 0, but `dec term` rejects `r0 >= MAX REFERENCE` for that tag. A shifted `r0` begins with a term tag byte, so the input fails with `badarg`. ## Proof of concept 1. Build a `NEWER REFERENCE EXT` (tag 90) with `Len` 0, the node atom `nonode@nohost` as `SMALL ATOM UTF8 EXT`, and a 4-byte creation for another node, for example 1. 2. Build a `BINARY EXT` (tag 109) whose payload starts with a 32-bit arity N, followed by N `SMALL INTEGER EXT` elements. Pad the payload so that the low byte of the 32-bit binary length is 105 (`LARGE TUPLE EXT`). 3. Wrap both in a two-element `SMALL TUPLE EXT` after the version byte 131. With N = 40 the input is 391 bytes. 4. Call `binary to term/1`, or `binary to term/2` with `[safe]`, on the input. The VM aborts with `heap overrun by 33 words(s)` instead of raising `badarg`. ## Impact An attacker who can supply bytes to `binary to term/1,2` or `enif binary to term()` can abort the Erlang VM and stop every application on the node. ## Workarounds * Do not call `binary to term/1,2` on data from untrusted sources. The OTP Secure Coding Guidelines (DSG-011) recommend avoiding these functions altogether on untrusted data. * If distribution is exposed to untrusted networks, configure it to use TLS with client certificate verification. * Use alternative serialization formats (JSON, Protocol Buffers) for untrusted external input. Note: the `[safe]` option to `binary to term/2` does NOT protect against this crash. It only restricts atom creation, not structural validation of binary encodings.