CVE-2026-120961: binary_to_term Heap Overrun via FLOAT_EXT Without Terminating Zero Byte May Abort the VM

Published Nov 24, 2026
·
Updated

Summary

Out-of-bounds Read vulnerability in the external term format decoder in Erlang OTP erts allows an attacker who controls the input to binarytoterm/1,2 to read memory after the input, and to change one byte there, via a FLOATEXT term without a terminating zero byte. decodedsize in erts/emulator/beam/external.c checks only that the 31 bytes of the FLOATEXT field are present. decterm then passes the field to syscharstodouble, which scans to a NUL byte without a length limit. When the field has no NUL, the scan continues into the bytes after the field, and those bytes change the decoded float. When the radix character is found after the field and strtod does not accept it, syscharstodouble overwrites that byte (a , becomes a .). The VM can fault if the scan reaches an unmapped page.

The safe option does not prevent this. enifbinarytoterm() and the distribution protocol reach the same decoder, and distribution is assumed to run on trusted networks only. The write is limited to the one radix byte. No arbitrary write or code execution was shown.

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. binarytotermint first calls decodedsize in erts/emulator/beam/external.c. For FLOATEXT (tag 99), decodedsize skips 31 bytes and reserves heap for one float. It does not examine the content of the field.

2. Decode pass. decterm passes the pointer to the field to syscharstodouble and then advances by 31 bytes. The call carries no length. syscharstodouble (in erts/emulator/sys/unix/sysfloat.c and erts/emulator/sys/win32/sysfloat.c) treats the field as a C string.

3. Out-of-bounds read. syscharstodouble checks the float syntax one character at a time and requires a NUL after the last digit. A valid encoder pads the field with NUL bytes. When all 31 bytes are part of a float, the scan and the subsequent strtod call continue into the bytes after the field. When the field is the last term of the input, these are bytes after the input. If they complete a valid float and a NUL follows, the decoded value contains them.

4. One-byte write. syscharstodouble remembers the position of the radix character, which can be . or ,. If strtod stops before the end of the scanned string, the function replaces the radix character with the other one in place and calls strtod again. When the field contains only digits, the radix character is a byte after the field. A , there is changed to ..

5. Fault. The scan has no upper limit. If only digits follow up to the end of the mapped memory, the read faults and the VM aborts.

Proof of concept

1. Build a FLOATEXT field without a NUL byte: tag 99 followed by the 31 bytes 1.0e plus 26 times 0 plus 1. This is the float 10.0. 2. Put the field at the end of an input, for example as the last element of a SMALLTUPLEEXT after the version byte 131. 3. Build a larger binary that holds the input followed by the bytes 7 and NUL. Take the input as a sub-binary with binary:part/3. 4. Call binarytoterm/2 with [safe] on the sub-binary. The last element decodes as 1.0e17 and not 10.0: the decoder read the 7 after the input. 5. For the write, use the 31 digits 1234567890123456789012345678901 as the field and put ,5 and NUL after the input. After the call, the , byte in the parent binary is a ..

Impact

An attacker who can supply bytes to binarytoterm/1,2 or enifbinarytoterm() can make the decoder read bytes after the input, which then change the decoded float, and can change one , byte after the input to .. The VM can abort if the read reaches unmapped memory.

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 issue. It only restricts atom creation, not structural validation of binary encodings.

Other sources

Out-of-bounds Read vulnerability in the external term format decoder in Erlang OTP erts allows an attacker who controls the input to binarytoterm/1,2 to read memory after the input, and to change one byte there, via a FLOATEXT term without a terminating zero byte. decodedsize in erts/emulator/beam/external.c checks only that the 31 bytes of the FLOATEXT field are present. decterm then passes the field to syscharstodouble, which scans to a NUL byte without a length limit. When the field has no NUL, the scan continues into the bytes after the field, and those bytes change the decoded float. When the radix character is found after the field and strtod does not accept it, syscharstodouble overwrites that byte (a , becomes a .). The VM can fault if the scan reaches an unmapped page.

The safe option does not prevent this. enifbinarytoterm() and the distribution protocol reach the same decoder, and distribution is assumed to run on trusted networks only. The write is limited to the one radix byte. No arbitrary write or code execution was shown.

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 transport security = TLS with client certificate verification
  5. Compensating control

    For untrusted input, avoid binary_to_term/1,2 and enif_binary_to_term(); use JSON or Protocol Buffers for external data instead.

Event History

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

Frequently Asked Questions

1

Which Erlang/OTP deployments are exposed to attacker-controlled input?

Any deployment that passes attacker-controlled external term data to binary_to_term/1 or binary_to_term/2 is exposed. Native code using enif_binary_to_term() reaches the same decoder, and the distribution protocol also uses it.

2

Does using the safe option with binary_to_term prevent the issue?

No. The safe option does not prevent this vulnerability.

3

What can happen if the malformed input is processed?

The decoder can read beyond the supplied input and may alter one radix-character byte after the FLOAT_EXT field. The VM can abort if the scan reaches an unmapped memory page; no arbitrary write or code execution was shown.

4

What should be done if patching cannot happen immediately?

Do not allow untrusted parties to supply external term data to the affected decoding APIs. Keep distribution traffic limited to trusted networks, consistent with the distribution protocol's trust assumption.

5

Which releases are affected?

Affected versions begin with OTP 17.0 and include releases before OTP 27.3.4.20, OTP 28.5.0.9, and OTP 29.1.3. The issue corresponds to erts versions from 6.0 before 15.2, based on the available version information.

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