Skip to content
Security incident on Hex.pm

Security incident on Hex.pm

Lobste.Rs • November 24, 2026

~ Hex implemented accepting Erlang's external term format over the network for their own purposes in HexpmWeb.ErlangFormat , it's (thankfully) not built into Plug. You can see the fix to that module in the linked commit . ETF is really useful for avoiding encoding/parsing overhead. It makes a lot of sense to use when 2 parties both speak in Erlang terms, and for something at the scale of a package registry like Hex, it's a good choice from a performance perspective. Erlang is a hardened, network-first language, and my guess is that you can trust the :safe in :erlang.binary_to_term(..., [:safe]) . The issue is that Elixir has decided to build structs on top of Erlang's existing map data type . On top of that, structs open the door to a lot of implicit code calling given how they interact with protocols . It seems like the big miss here was that it was assumed that terms that would be safe in Erlang would also be safe in Elixir. Given how structs interact with protocols, that is absolutely not the case (as the attack clearly shows). I think the Elixir community, and ideally the core Elixir team, should remedy this situation by providing safe term conversion functions of its own. A stricter subset on top of ETF that disallows structs (or maybe converts safely between standard library structs) would be nice, and that's what Hex has implemented ad-hoc in HexpmWeb.ErlangFormat . If that gets implemented, compilation warnings on usage of binary_to_term that suggest the use of the safe Elixir variant could prevent a vulnerability like this in the future.

~ Hex implemented accepting Erlang's external term format over the network for their own purposes in HexpmWeb.ErlangFormat , it's (thankfully) not built into Plug. You can see the fix to that module in the linked commit . ETF is really useful for avoiding encoding/parsing overhead. It makes a lot of sense to use when 2 parties both speak in Erlang terms, and for something at the scale of a package registry like Hex, it's a good choice from a performance perspective. Erlang is a hardened, network-first language, and my guess is that you can trust the :safe in :erlang.binary_to_term(..., [:safe]) . The issue is that Elixir has decided to build structs on top of Erlang's existing map data type . On top of that, structs open the door to a lot of implicit code calling given how they interact with protocols . It seems like the big miss here was that it was assumed that terms that would be safe in Erlang would also be safe in Elixir. Given how structs interact with protocols, that is absolutely not the case (as the attack clearly shows). I think the Elixir community, and ideally the core Elixir team, should remedy this situation by providing safe term conversion functions of its own. A stricter subset on top of ETF that disallows structs (or maybe converts safely between standard library structs) would be nice, and that's what Hex has implemented ad-hoc in HexpmWeb.ErlangFormat . If that gets implemented, compilation warnings on usage of binary_to_term that suggest the use of the safe Elixir variant could prevent a vulnerability like this in the future.

~ Hex implemented accepting Erlang's external term format over the network for their own purposes in HexpmWeb.ErlangFormat , it's (thankfully) not built into Plug. You can see the fix to that module in the linked commit . ETF is really useful for avoiding encoding/parsing overhead. It makes a lot of sense to use when 2 parties both speak in Erlang terms, and for something at the scale of a package registry like Hex, it's a good choice from a performance perspective. Erlang is a hardened, network-first language, and my guess is that you can trust the :safe in :erlang.binary_to_term(..., [:safe]) . The issue is that Elixir has decided to build structs on top of Erlang's existing map data type . On top of that, structs open the door to a lot of implicit code calling given how they interact with protocols . It seems like the big miss here was that it was assumed that terms that would be safe in Erlang would also be safe in Elixir. Given how structs interact with protocols, that is absolutely not the case (as the attack clearly shows). I think the Elixir community, and ideally the core Elixir team, should remedy this situation by providing safe term conversion functions of its own. A stricter subset on top of ETF that disallows structs (or maybe converts safely between standard library structs) would be nice, and that's what Hex has implemented ad-hoc in HexpmWeb.ErlangFormat . If that gets implemented, compilation warnings on usage of binary_to_term that suggest the use of the safe Elixir variant could prevent a vulnerability like this in the future.

Hex implemented accepting Erlang's external term format over the network for their own purposes in HexpmWeb.ErlangFormat , it's (thankfully) not built into Plug. You can see the fix to that module in the linked commit .

ETF is really useful for avoiding encoding/parsing overhead. It makes a lot of sense to use when 2 parties both speak in Erlang terms, and for something at the scale of a package registry like Hex, it's a good choice from a performance perspective.

Erlang is a hardened, network-first language, and my guess is that you can trust the :safe in :erlang.binary_to_term(..., [:safe]) . The issue is that Elixir has decided to build structs on top of Erlang's existing map data type . On top of that, structs open the door to a lot of implicit code calling given how they interact with protocols .

It seems like the big miss here was that it was assumed that terms that would be safe in Erlang would also be safe in Elixir. Given how structs interact with protocols, that is absolutely not the case (as the attack clearly shows).

I think the Elixir community, and ideally the core Elixir team, should remedy this situation by providing safe term conversion functions of its own. A stricter subset on top of ETF that disallows structs (or maybe converts safely between standard library structs) would be nice, and that's what Hex has implemented ad-hoc in HexpmWeb.ErlangFormat . If that gets implemented, compilation warnings on usage of binary_to_term that suggest the use of the safe Elixir variant could prevent a vulnerability like this in the future.

The full story

This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.

Hex.pm unauthenticated RCE via Erlang term format deserialization (CVE-2026-129514) Hex.pm, the package registry for the Erlang and Elixir ecosystems, suffered a security incident involving its handling of Erlang external term format (ETF) request bodies. CVE-2026-129514 describes a deserialization flaw in the application/vnd.hex+erlang request body parser in hexpm that allows an unauthenticated remote attacker to execute operating system commands via a crafted request. The CNA record states the vulnerability was against the hex.pm service on 2026-11-23. The parser decodes bodies with Plug.Crypto.non_executable_binary_to_term/2, which accepts maps containing a __struct__ key; the decoded term is returned as request params before routing and authentication run, so a POST to any route reaches it. Per the CNA record, Elixir protocol dispatch on the __struct__ key lets the client select Inspect and Enumerable implementations during error reporting, and a chain through Ecto.Query.DynamicExpr and DBConnection.Stream reaches an apply/3 call on a client-supplied {module, function, args} tuple. The affected range is given as hex.pm from 2016-02-23 until 2026-11-23, and hexpm/hexpm from commit ab1bbcef7cc8395d1056d3b1aa6a174353492d59 until 379b0a29bcc95164249f38ad7d772a37a8ff9533, which is the fixed commit. The Lobste.rs discussion, which links a commit changing HexpmWeb.ErlangFormat, argues that Erlang's:safe option for binary_to_term is not sufficient in Elixir because structs are built on maps, and proposes Elixir-level safe conversion functions. The articles do not provide a CVSS score, and the Lobste.rs post does not describe the scope of data exposure or any post-exploitation activity. 1 sources 75

Extracted Entities

Attack Types (1)

Domains (1)

Platforms (2)