Hex.pm: a "safe" decoder let fake structs through and ended in a shell
On November 23, 2026, between 18:16 and 18:29 UTC, someone sent 69 malicious requests to hex.pm, the package registry for Elixir and Erlang, and ran commands on six of its web servers. The Hex team tells the story itself in its incident report, published on November 24.
The flaw is CVE-2026-129514. The record, issued by the CNA of the EEF, the foundation that brings together the Erlang and Elixir community, gives it the maximum score in CVSS 4.0, a 10, with the exploitation metric set to “Attacked”. No authentication was needed.
The interesting part is not the score; it is the path. The request carried no code, only data.
That data chose which Ecto and DBConnection functions ran, and the last one in the chain called a function with arguments taken from the request itself.
I read the Hex report, the four CVE records that describe the same chain and the August one for Ash, the GitHub advisory, the two commits involved, the db_connection and Ash changelogs and the Erlang and Plug.Crypto documentation. This is what they say, and what I think they teach anyone who decodes data from a client.
What happened on hex.pm on November 23?
The timeline from the Hex report, in UTC:
| Time (UTC) | Event, according to the Hex report |
|---|---|
| Nov 23, 18:14:21 | First request of any kind from the attacker’s addresses |
| 18:16:00 | First exploitation request; Sentry logs the first error |
| 18:16:46 | Request after which, 3 ms later, the first file created on a server appears |
| 18:27 | Firewall rule against the attacker’s traffic; effective between 18:30 and 18:33 |
| 18:29:33 | Last exploitation request that reaches a server |
| 18:30 to 18:31 | All servers replaced with a fixed version |
| 18:49 | AWS access key of the affected servers disabled |
| 19:07 | A security report describing the same vulnerability arrives by email |
| 22:58 to 23:26 | Notifications to IMY (the Swedish data protection authority), CISA and ENISA |
| Nov 24, 10:42 | All credentials the attacker could read rotated, except the registry signing key and some low-impact secrets |
| Nov 24, 13:48 | CVE-2026-129514 published |
Six servers were affected because, according to Hex, a restart at 18:28 brought up three new servers that were still running the vulnerable version. From the first exploitation request until everything was fixed, about 15 minutes passed.
The report adds a detail about the attacker. In the logs reviewed since November 19, the same addresses repeatedly downloaded the hex.pm dependencies.
Hex reads this as the attacker setting up a local copy of the service to test against. If Hex is right, the chain was not improvised live.
How did a “safe” decoder end up running commands?
hex.pm accepts request bodies in Erlang term format, the application/vnd.hex+erlang type. The parser decoded them with Plug.Crypto.non_executable_binary_to_term/2 and the [:safe] option. According to the CVE record, that parser ran in the endpoint before routing and authentication, so any POST with that content type, to any route, reached it.
The decoder rejected anonymous functions and new atoms, but it did not look at maps.
In Elixir a struct is a map with a __struct__ key that names a module, and the language dispatches protocols based on that key. If a client sends a map with __struct__ pointing to an already loaded module, the runtime treats it as a real struct of that module, with whatever fields the client wants.
The Hex report describes the rest step by step:
| Step | Component | What happens, according to Hex and the CVE record |
|---|---|---|
| 1 | hex.pm parser | Decodes the body without authentication; the fake struct passes the :safe filter |
| 2 | Plug.MethodOverride | Reads _method from the parameters; on a struct it calls the module’s fetch/2, which does not exist, and an UndefinedFunctionError is raised |
| 3 | Sentry, Bandit, log formatter | When reporting the error they call inspect on the request data |
| 4 | Ecto.Query.DynamicExpr | Its Inspect implementation walks the binding field without checking that it is a list |
| 5 | DBConnection.Stream | Its Enumerable implementation fails to encode the query, and the error path applies the :log option |
| 6 | apply/3 | The :log option is a {module, function, args} tuple taken from the request; it ends in a system command |
No link is an obvious bug on its own. MethodOverride does what it should, and inspecting an error is normal. So is inspect walking a field and a stream logging its activity.
The problem is that the client chose the type of each value, and with the type it chose the code.
Anyone coming from Java will recognize the pattern: it is a gadget chain, like the ones in Java object deserialization. Here the gadgets are not classes with magic deserialization methods. They are protocol implementations that run when someone inspects or walks a value.
Why did :safe not mean safe?
Because :safe protects the virtual machine, not the application. The Erlang documentation for binary_to_term/2 explains that the option prevents the creation of new atoms and external function references, resources that are not freed and can exhaust memory. The same page warns that it does not guarantee the data is safe for your application, and recommends validating or signing it.
The Plug.Crypto documentation went further. It recommends signing or encrypting whatever is decoded with non_executable_binary_to_term/2. And it warns that, although the function discards anonymous functions, a {module, function, args} tuple can slip into the decoded data, for example inside a struct.
In other words, the warning that describes this attack was written in the documentation of the function that was used.
The function name says “non executable” and the option says “safe”. Both names are accurate for what they promise, and both invite you to believe they promise more.
Hex now proposes hardening four libraries, according to its report:
- plug_crypto: document that the decoder is only safe with authenticated payloads and add an option to reject structs.
- plug: reject structs as body parameters.
- ecto: check that
bindingis a list before walking it. - db_connection: do not apply
:logcallbacks that come from stream structs.
The last one is already published. The db_connection changelog records in version 2.10.3, from November 24, that it no longer accepts function tuples inside its Enumerable implementations.
The changelog itself says this is not a DBConnection vulnerability, and the CVE-2026-133555 record explains it: the root cause is in the component that decodes untrusted data without restricting which terms it accepts.
Why did the filter disappear in 2016?
The CVE record marks the affected version as starting from commit ab1bbce, from February 23, 2016. Its message is “Fix for some bad requests”.
Before that commit, the decoder had a safe_term? function with an explicit comment: atoms are not allowed. It accepted numbers, binaries, booleans, lists, tuples and maps made only of those types.
A struct needs at least one atom, the __struct__ key, so that allowlist would have rejected it. The commit deleted it and left only :erlang.binary_to_term/2 with [:safe].
The commit message does not explain why the check was removed, and I am not going to guess. What it does show is how a defense ages.
Later the decoder switched to Plug.Crypto.non_executable_binary_to_term/2, as the code the fix changes shows. That filter blocks functions, not structs. Since 2016, neither layer rejected the types this chain needed.
The fix, commit 379b0a2 from 18:26 UTC on November 23, walks the decoded term and returns a 400 if any map in the term, at any depth (lists, tuples, map keys or values), has the __struct__ key. Since it lives in the only decoder for that format, it covers every route.
Is it a hex.pm-only flaw?
It spans more than one project. The same chain through ecto and db_connection appears in other records published the same week by the same CNA:
| CVE | Component | Untrusted input | CVSS 4.0 | Fixed version |
|---|---|---|---|---|
| CVE-2026-129514 | hex.pm (service) | application/vnd.hex+erlang body | 10 | commit 379b0a2 |
| CVE-2026-124283 | Ash | Keyset pagination cursor | 8.9 | 3.38.0 |
| CVE-2026-130411 | Flop | after and before cursors | 9.2 | 0.26.7, 0.27.3, 0.28.1, 0.29.2 |
| CVE-2026-133555 | db_connection | None on its own (hardening) | 8.9 | 2.10.3 |
The Ash case teaches something more. In August, CVE-2026-67579 had already been published, a filter injection with forged cursors, fixed in 3.31.3.
The new record explains that Ash rejects decoded expressions with Ash.Expr.expr?/1, and that this check does not examine the fields of a struct. Its affected range starts at 3.31.3, the version that fixed the August flaw.
Patching the gadget you just saw leaves open the ones you have not seen. The Ash 3.38.0 fix, according to its changelog, changes the approach: it encodes cursors as JSON unless keyset_signing_secret is configured, so a forged cursor is never decoded as an Erlang term.
Three of the four records give AV:L or AT:P in their vector, because they depend on how the application uses the library.
You should not read those scores as the risk to your service. If your application decodes terms from a client without a signature, the risk looks more like hex.pm’s than like the library’s score.
What do we not know yet?
It cannot be ruled out that the attacker read the database. Hex explains that reads, environment variables and shell commands are not logged.
The database holds email addresses, password and API key hashes, 2FA secrets, sessions and audit logs.
Hex found no unexpected writes. It restored a copy of the database from 18:13:59, before the first request, and compared every row with the production database.
The 23 versions published during the incident match its audit log. The 62 package files written since 18:00 match the checksums in the database, and the 186 registry files match its contents.
The report itself points out the limit: a row modified and then restored would not show up in that comparison, and the documentation has no stored checksum.
The registry signing key is the sensitive point. The GitHub advisory says the process environment contains, among other things, that key.
According to the report, it was one of the few things not rotated on November 24. The same report says Hex is building a signing system that supports key rotation, with new clients in the coming days.
Hex does not say the key was read; it says the attacker’s commands could read the servers’ credentials.
Nor do we know who it was. The report does not attribute the attack, and I have not found any primary source that does.
CVE-2026-129514 does not appear in the CISA KEV catalog in its November 25 version.
What would I do this week?
If you have a hex.pm account, do what Hex asks: change your password and regenerate 2FA from the security dashboard, because that gives you a new secret and new recovery codes.
Until the client with the new signing system is out, download packages only from repo.hex.pm and not from third-party mirrors. When it is out, update the client with the mix local.hex command and the force option, as the Hex report indicates, and also update rebar3 or Gleam if you use them.
If you maintain services in Elixir or Erlang, search for binary_to_term and non_executable_binary_to_term in all code that touches client data: bodies, cookies, cursors, queues.
For each one, the question is not whether it uses :safe. It is whether the data is signed or encrypted by you before decoding it. If it is not, change the format or sign the payload.
Update db_connection to 2.10.3 and Ash to 3.38.1 or later, which according to its changelog adds another security fix. For Flop, the fixed version of your branch, or 0.26.7 or higher if you use an earlier one. These are cheap fixes, although none protects you if your own code decodes unsigned terms: the db_connection record warns that structs from other libraries can serve the same purpose.
And review what your error reporting does with request data. In this chain, the inspect in the error report was the step that turned a type error into code execution.
That is no reason to turn off Sentry. It is a reason to make sure untrusted data never reaches it as structs.
Frequently asked questions
Was any package published on hex.pm modified?
According to Hex, there are no signs of it. The 23 versions published during the incident match its audit log, no earlier version changed, the package files match the checksums and the registry files match the contents of the database.
Does it affect me if I only use Hex as a client to install dependencies?
The flaw was in the hex.pm server, not in the client. What affects you is what Hex asks of users: password, 2FA, downloading only from repo.hex.pm until the new client, and distrusting emails that claim to come from Hex.
Do I have to rotate my Hex API keys?
Hex says it does not consider it necessary, because of how it generates and stores them: random 128-bit values stored as HMAC-SHA256. That is its assessment; if a key has broad publishing permissions, rotating it costs little.
Would adding the :safe option to my code be enough?
No. hex.pm already used it. :safe prevents the virtual machine’s memory from being exhausted with new atoms; it does not stop a map with __struct__ from reaching your application as a struct of a loaded module.
Sources
- Hex, Security incident on hex.pm, Peter Ullrich, Jonatan Männchen and Eric Meadows-Jönsson, November 24, 2026.
- EEF CNA, CVE-2026-129514, published November 24, 2026.
- GitHub, advisory GHSA-9pmm-hf4r-27pg in hexpm/hexpm, November 24, 2026.
- hexpm/hexpm, commit 379b0a2, “Refuse structs in Erlang term request bodies”, November 23, 2026.
- hexpm/hexpm, commit ab1bbce, “Fix for some bad requests”, February 23, 2016.
- EEF CNA, CVE-2026-124283 (Ash), CVE-2026-130411 (Flop) and CVE-2026-133555 (db_connection), November 24, 2026.
- EEF CNA, CVE-2026-67579 (Ash), August 12, 2026.
- elixir-ecto, db_connection changelog, version 2.10.3.
- ash-project, Ash changelog, versions 3.38.0 and 3.38.1.
- Erlang/OTP,
erlang:binary_to_term/2documentation. - Plug.Crypto,
non_executable_binary_to_term/2documentation. - CISA, Known Exploited Vulnerabilities catalog, version 2026.11.25.