~ 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.
