Hex.pm Hacked Through a 10-Year-Old Bug — Reset Your Password and 2FA Now
A package registry is one of the most trusted pieces of infrastructure in software development. Every time you install a library, you trust the registry to hand you the real code. On 23 November 2026, hex.pm — the registry for Erlang, Elixir and Gleam, hosting more than 27,000 packages and serving over 16 billion downloads — was breached through a bug that had been sitting in its code for more than ten years.
What Happened
Hex disclosed the incident on 24 November. The timeline is brutally fast. The attacker's first request arrived at 18:14 UTC on 23 November. The first exploit request followed at 18:16. Over the next 15 minutes, 69 requests ran operating system commands on six of hex.pm's web servers. Hex added a firewall rule at 18:27 and had every server running a patched build by 18:31 — just 17 minutes after the first probe.
The flaw is CVE-2026-129514, scored a perfect 10.0 under CVSS 4.0. It is a deserialization bug (CWE-502) in the way hex.pm parses request bodies. Hex clients send data as Erlang terms with the content type application/vnd.hex+erlang, and the server decoded those bodies before routing or authentication — so a POST to any route reached the vulnerable parser.
The Bug: A `__struct__` Key That Should Never Have Been Trusted
The parser used Plug.Crypto.non_executable_binary_to_term/2, which refuses functions and unknown atoms but accepts maps carrying a __struct__ key. That let an attacker send a forged Elixir struct in the request body. When the request failed, error reporting called inspect/1 on that struct, and the chain ran through Ecto.Query.DynamicExpr and DBConnection.Stream until it reached an apply/3 call on a module, function and arguments taken straight from the attacker's body. That is unauthenticated remote code execution from a single crafted request.
The vulnerable code dates to 23 February 2016, when a safety check was removed — so the hole sat in the registry for over a decade. Hex says activity from the attacker since 19 November suggests they built a local copy of hex.pm to test against, which is possible because the hexpm server code is open source. The fix, commit 379b0a2, makes the decoder reject any map with a __struct__ key.
What Was (and Wasn't) Taken
Hex says it found no modified packages, no database changes and no persistence on its servers. That is the good news, and it matters: a poisoned package in a registry used by thousands of projects would have been a supply-chain disaster.
The bad news is what Hex cannot rule out. Database reads are not logged, so the attacker may have read email addresses, bcrypt password hashes, HMAC-SHA256 API key hashes, 2FA secrets, sessions and audit logs. Hex has already rotated its storage, CDN, email and database credentials, plus the keys that sign sessions and access tokens, which logged everyone out. One thing has not been rotated yet: the registry signing key, because the current system does not support rotation. Hex is building a new signing system and says new Hex clients with support for it are due in the coming days. The incident was reported to Sweden's data protection authority (IMY), to CISA and to ENISA on the evening of 23 November.
What to Do Right Now
- If you have a hex.pm account, change your password now, then reset 2FA. Go to hex.pm/dashboard/security, choose "Setup New App" under Authenticator App, and save the new recovery codes. Do both — a leaked 2FA secret makes your old authenticator codes useless to trust.
- If you self-host hexpm, update past the fix commit. The vulnerable code runs from commit
ab1bbceup to, but not including, fix commit379b0a2. Any self-hosted instance on an older build is exploitable the same way. - Update the libraries in the same gadget chain.
db_connection1.1.0 up to 2.10.3 has the related CVE-2026-133555 — update to 2.10.3.flophas CVE-2026-130411 — update to a fixed release.ashhas a similar bug, CVE-2026-124283, fixed in 3.38.0. - Audit your own deserialization. If your app decodes untrusted data with
binary_to_term, Pythonpickle, Java serialization or any equivalent, that is the same class of bug. Never decode data from a client into live objects — parse it into plain data structures and validate every field.
The Lesson for Everyone Else
This is the third deserialization RCE in a major open-source project in as many weeks, and the pattern is identical every time: dangerous decoding runs before authentication, and a "safe" decoder turns out to accept one more type than anyone remembered. The fix is not a patch, it is a rule — decode untrusted input into dumb data, never into objects that can run code.
Remember the golden rule: only test systems you own or have written permission to test. This post is about defense — secure your own hex.pm account, update your own dependencies, and check your own code for the same mistake.



Comments
Post a Comment