CVE-2026-117642: binary_to_term Stack Exhaustion via Nested Funs in NEW_FUN_EXT and EXPORT_EXT Aborts the VM

Published Nov 24, 2026
·
Updated

Summary

Uncontrolled Recursion vulnerability in the external term format decoder in Erlang OTP erts allows an attacker who controls the input to binarytoterm/1,2 to abort the Erlang VM via a fun term with funs nested in its integer fields. decterm in erts/emulator/beam/external.c decodes terms iteratively, except for the OldIndex and OldUniq fields of NEWFUNEXT and the Arity field of EXPORTEXT. For these fields it calls itself, and it checks that the result is a small integer only after the call returns. An input that places another fun in such a field, nested to sufficient depth, recurses once per level, exhausts the stack of the scheduler thread and crashes the VM. The input must be large enough to reach that depth.

The abort takes down every process on the node. Supervision, try/catch and the safe option do not prevent it. enifbinarytoterm() and the distribution protocol reach the same decoder, and distribution is assumed to run on trusted networks only.

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. Iterative decoder. decterm in erts/emulator/beam/external.c walks the external term format with an explicit work list, so nested tuples, lists and maps do not grow the C stack. decodedsize runs first and sizes the input the same way.

2. Recursive integer fields. Two tags break that pattern. For NEWFUNEXT (112), decterm reads the OldIndex and OldUniq fields by calling itself and checks issmall on the result afterwards. For EXPORTEXT (113), it reads the Arity field the same way. On current release lines the discarded creator pid of NEWFUNEXT is also read by a recursive call. The recursive call accepts any term, so a fun placed in one of these fields is decoded as a fun, and its own integer fields recurse again.

3. Stack exhaustion. Each nesting level costs one decterm frame on the scheduler thread's stack. decodedsize accepts the input because it only counts terms and heap words. An input nested deeply enough overflows the stack before any issmall check fails, and the VM aborts. The depth needed depends on the stack size of the thread, so the input must be correspondingly large.

4. Fix. The fix decodes these fields with a dedicated decint32 that accepts only SMALLINTEGEREXT and INTEGEREXT, and decodes the creator pid through decpid, leaving no recursive call to decterm.

Proof of concept

1. Build a NEWFUNEXT (tag 112) term with a valid module atom and zero free variables. 2. In place of the OldIndex field, which must be a small integer, encode another NEWFUNEXT term. Repeat this nesting until the chain is deep enough to exhaust the stack of a scheduler thread. The OldUniq field, or the Arity field of an EXPORTEXT (tag 113), can carry the nested fun instead. 3. Prefix the result with the version byte 131 and call binarytoterm/1, or binarytoterm/2 with [safe], on it. 4. The VM aborts from stack exhaustion instead of raising badarg.

Impact

An attacker who can supply bytes to binarytoterm/1,2 or enifbinarytoterm() can abort the Erlang VM and stop every application on the node.

Workarounds

Do not call binarytoterm/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 binarytoterm/2 does NOT protect against this crash. It only restricts atom creation, not structural validation of binary encodings.

Other sources

Uncontrolled Recursion vulnerability in the external term format decoder in Erlang OTP erts allows an attacker who controls the input to binarytoterm/1,2 to abort the Erlang VM via a fun term with funs nested in its integer fields. decterm in erts/emulator/beam/external.c decodes terms iteratively, except for the OldIndex and OldUniq fields of NEWFUNEXT and the Arity field of EXPORTEXT. For these fields it calls itself, and it checks that the result is a small integer only after the call returns. An input that places another fun in such a field, nested to sufficient depth, recurses once per level, exhausts the stack of the scheduler thread and crashes the VM. The input must be large enough to reach that depth.

The abort takes down every process on the node. Supervision, try/catch and the safe option do not prevent it. enifbinarytoterm() and the distribution protocol reach the same decoder, and distribution is assumed to run on trusted networks only.

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.

— MITRE

Affected Software

1 affected component
Ericsson Erlang/OTP>=17.0<27.3.4.20, >=28.0<28.5.0.9, >=29.0<29.1.3

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade Erlang/OTP to a version that resolves this vulnerability.

    Fixed in 27.3.4.20
  2. Upgrade

    Upgrade Erlang/OTP to a version that resolves this vulnerability.

    Fixed in 28.5.0.9
  3. Upgrade

    Upgrade Erlang/OTP to a version that resolves this vulnerability.

    Fixed in 29.1.3
  4. Configuration

    If distribution is exposed to untrusted networks, configure it to use TLS with client certificate verification.

    Erlang distribution TLS client certificate verification = enabled
  5. Compensating control

    Do not use binary_to_term/1,2 on untrusted data; use JSON or Protocol Buffers for untrusted external input instead.

Event History

Nov 24, 2026
CVE Published
via MITRE·03:09 PM
Data Sourced
via MITRE·03:09 PM
DescriptionWeakness
Data Sourced
via OSV·03:09 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·03:17 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

Which Erlang/OTP deployments are exposed?

Deployments using OTP 17.0 or later are affected when running a version before OTP 27.3.4.20, 28.5.0.9, or 29.1.3. The provided data does not establish whether OTP releases before 17.0 are affected.

2

What access does an attacker need to crash a node?

An attacker must control input passed to binary_to_term/1 or binary_to_term/2, including through enif_binary_to_term(). The distribution protocol also reaches the vulnerable decoder, although distribution is intended for trusted networks.

3

Does binary_to_term's safe option or Erlang fault handling mitigate the issue?

No. The safe option, supervision trees, and try/catch do not prevent the scheduler-thread stack exhaustion or the resulting VM abort.

4

What is the impact when exploitation succeeds?

The scheduler thread exhausts its stack and the Erlang VM aborts. This terminates every process on the affected node.

5

What should be prioritized if an update cannot be applied immediately?

Restrict untrusted sources from supplying external-term-format data to binary_to_term/1, binary_to_term/2, or enif_binary_to_term(). Ensure Erlang distribution is not reachable from untrusted networks.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203