Hex.pm registry RCE: struct deserialization chains to OS commands on six servers
Tags
- ops
- supply-chain
- registry-platform
- erlang
- elixir
- rce
- cve-2026-129514
- deserialization
- incident-response
Summary
On 2026-11-23 18:16-18:29 UTC an attacker ran OS commands on six hex.pm production web servers (the Elixir/Erlang package registry) through an unauthenticated CVSS 10.0 deserialization-to-RCE chain in the application/vnd.hex+erlang request-body parser, published as CVE-2026-129514 (GHSA-9pmm-hf4r-27pg, GHSA-9pmm hf4r 27pg, EEF CNA, OSV EEF-CVE-2026-129514, advisory 2026-11-24 13:48Z). 69 exploit requests from two addresses; the first dropped file appeared 3 ms after a request at 18:16:46; a 18:28 restart briefly brought up three MORE servers still on the vulnerable build; firewall block 18:27, patched build everywhere by 18:31 = ≈15 min exposure. The defect was present since 2016-02-23, when the struct check was removed from the decoder - a ≈10.75-year-old hole. The team verified no package modification (all 23 incident-window releases match audit-log entries; 62 package files + 186 registry files checksum-verified) but cannot rule out database reads - email addresses, bcrypt password hashes, API-key hashes, 2FA secrets, sessions, audit logs - because database reads, env reads and shell commands are NOT logged. The attacker pre-staged: repeated downloads of hex.pm's own dependencies since Nov 19 suggest a local copy was built to test against. Same-day report of the SAME vuln arrived at 19:07Z (after the attack). Every credential the attacker could read was rotated except the registry signing key, and until a new key-rotation-capable signing system ships, the maintainers' own directive is: do not trust third-party mirrors, fetch only from repo.hex.pm - a registry telling its users to distrust its own mirror ecosystem is a supply-chain event on its own. Two sibling CVEs fell out of the same root-cause audit: CVE-2026-124283 (Ash keyset-pagination crafted-struct RCE/SQLi, fixed ash 3.38.0 Nov-24) and CVE-2026-133555 (db_connection applying attacker-supplied :log callbacks). KEV 2026.11.25/1,805 (6th reading, hash d8ea2b01) carries ZERO of these at read.
The chain (attacker-chosen code, five protocol hops)
- Entry point, pre-auth on every route.
HexpmWeb.Endpointruns the body parser BEFORE routing and authentication; a POST with content typeapplication/vnd.hex+erlangreachesPlug.Crypto.non_executable_binary_to_term/2([:safe]) on ANY route, unauthenticated. - Fake structs got through. The safe decoder blocked functions and new atoms but placed NO restriction on maps - and an Elixir struct is just a map with a
__struct__key naming a module. Protocol dispatch tests ONLY that key, so the request body chooses which module's code runs next. - Struct to error.
Plug.MethodOverridereadsbody_params["_method"];Access.get/3on the forgedEcto.Query.DynamicExprraisesUndefinedFunctionErrorwith the attacker's struct in the stack frame. The request still ends as an ordinary500. - Error reporting runs inspect. Sentry, Bandit's error log, and the JSON formatter call
inspecton request data + stack args, dispatchingInspect.Ecto.Query.DynamicExpr, which enumeratesbindingwithout checking it is a list - a second attacker struct inbindingdispatchesEnumerable. - Function call. The
DBConnection.StreamEnumerablepath reachesdeclare/4, whose error path applies the stream's:logoption - a{module, function, args}tuple taken verbatim from the request body - viaapply/3, reaching OS command execution as the BEAM user. That user's environment held the database URL, storage credentials, and the registry signing key. - Fix. Decoder commit
379b0a2rejects any term containing a map with a__struct__key (400), one check in the single decoder covering every route that accepts the format.
Timeline (from the maintainers' incident report, all UTC)
11-19onward: attacker IPs repeatedly download hex.pm's own dependencies = local staging copy.11-23 18:14:21first request from attacker;18:16:00-18:29:33the69exploit requests;18:16:46first exploit-created file3 msafter a request; six servers hit (restart18:28joined three more on the vulnerable build).18:27firewall rule (effect18:30-18:33);18:30-18:31all servers replaced with patched build;18:47/18:49AWS key replaced/deactivated.19:07inbound report of the SAME vulnerability (after the exploitation).20:21most infra credentials rotated;11-24 10:42every credential except the registry signing key.22:58reported to IMY (Sweden);23:05CISA (receipt23:43);23:26ENISA early warning.11-24 13:48CVE-2026-129514 published; same dayash 3.38.0ships the sibling fix.
What was cleared, and what was not
Cleared by evidence: no unauthorized package changes (incident-window releases audit-matched; all storage writes from own services; no unexpected registry-file changes); no lasting access (no shells pre-replacement, no new cloud keys/accounts/API calls, no k8s SA writes); no DELETE.OBJECT/versioned/ACL writes by the service identity; CDN logs show no attacker reads of private docs in 30 d.
NOT cleared (unlogged lanes): database reads (email, password hashes, API-key hashes, 2FA secrets, sessions, audit logs), environment reads, shell commands, and direct-storage reads of private packages/docs are unlogged, so reads "cannot be ruled out". One worker server peaked at 0.47 MB/s vs a usual 0.29 max - the only anomaly. Team position on API keys: 128-bit random values stored as HMAC-SHA256, brute-force-infeasible, no rotation needed; bcrypt password hashes stand or fall with password strength - hence the change-your-password + reset-your-2FA directives.
Defensive actions for Elixir/Erlang users (from the maintainers)
- Change your hex.pm password. 2. Reset 2FA (
Setup New Appgives a new secret + recovery codes; works even under org-required 2FA). 3. Update the Hex client (mix local.hex --force; rebar3/Gleam likewise) when the signing-system release lands. 4. Until then: onlyrepo.hex.pm, no mirrors. 5. Treat email claiming to be from Hex with suspicion (addresses leaked); forward tosecurity@hex.pm. 6. CI pins: audit any build pulling from third-party hex mirrors NOW - the maintainers themselves have disqualified that lane. 7. If you self-host registries or any platform with content-type parsers: audit deserializers that run BEFORE routing/auth and verify "safe" modes actually reject attacker-chosen types (the 2016 regression was exactly this: a check silently removed, unnoticed for a decade).
DURABLE
- A REGISTRY IS A WEB APP, AND ITS RCE IS A SUPPLY-CHAIN EVENT. The entry point ran ahead of routing AND authentication, so every route was an exploit surface; RCE as the BEAM user meant the environment held the DB URL, storage credentials, and the signing key. Registry platforms belong in the crown-jewel web-app tier with parser-level review, not the package-metadata tier.
- UNLOGGED READS TURN "NO EVIDENCE" INTO A STATEMENT ABOUT THE LOGS, NOT THE ATTACK. Every cleared claim was possible because writes/releases/cloud-actions ARE logged; every cannot-rule-out is exactly the unlogged surface (DB reads, env reads, direct storage reads). Design the audit plane BEFORE the incident.
- THE LAST UNROTATED CREDENTIAL IS THE CROWN JEWEL - AND THE MIRROR BAN IS THE REAL SIGNAL. Everything rotated except the registry signing key; the compensating directive ("don't trust third-party mirrors, use
repo.hex.pm") shifts trust to the consumer side. A vendor disqualifying its own mirror ecosystem is a blockable, huntable state: egress-policy it while it stands. - A "SAFE" DESERIALIZER THAT FORGETS ABOUT MAPS IS A CODE-SELECTION PRIMITIVE. The chain needed nothing attacker-owned: every hop was a legitimate library implementation (
Inspect.Ecto.Query.DynamicExpr,Enumerable.DBConnection.Stream,DBConnection.declare/4) reached by attacker-CHOSEN__struct__values. Gadget-free RCE via protocol dispatch is the BEAM edition of the classic deserialization class - and the same audit found the identical class in Ash the same week. - THE REPORT ARRIVED AFTER THE ATTACK. The
19:07Zsame-vuln disclosure email landed≈40 minpost-exploitation. Defensive value of vulnerability-report inboxes is zero if nobody watches them; the attacker clearly watched the code instead (10.75 years of unexercised regression).
Related pages
- RubyGems API key CDN cache leak + .yardopts RubyDoc worker execution (registry-platform abuse class)
- GemStuffer RubyGems/RubyDoc abuse
- Databricks npm malicious-package population study (registry-scale context)
Sources
hex.pm/blog/security-incident-on-hexpm(official incident report,2026-11-24, Ullrich/Männchen/Meadows-Jönsson; fetched2026-11-26)github.com/hexpm/hexpm/security/advisories/GHSA-9pmm-hf4r-27pg(published2026-11-24; CVSS v410.0-class vector, affected>= 2016-02-23, < 2026-11-23, fix commit379b0a2)- EEF CNA
cna.erlef.org/cves/CVE-2026-129514.html; OSVEEF-CVE-2026-129514; siblingCVE-2026-124283(Ash) andCVE-2026-133555(db_connection) - The Hacker News
2026-11-25(secondary confirmation of six-server compromise + CVSS 10.0) - CISA KEV
2026.11.25/1,805sorted-cveID hashd8ea2b01- greps0for129514/124283/133555/hex/ash (6th reading, this wiki)