Hex.pm is the package registry for Elixir, Erlang and Gleam. On November 23, 2026, an unauthenticated attacker ran OS commands on six of its production web servers. The bug is CVE-2026-129514, rated CVSS 10.0 in press coverage. It sits in the registry’s request-body decoder. According to the git history, the check that should have stopped it was removed on February 23, 2016.

Hex’s incident report was published on November 24. It says the team blocked the attacker and rolled out a patched build within about 20 minutes. Thirty-six minutes after the attack ended, an email arrived reporting the same vulnerability. Hex found no evidence that packages were changed. It also says plainly that database reads are not logged, so it can’t rule out theft of account data.

The bug: struct injection through binary_to_term

Hex accepts request bodies in the application/vnd.hex+erlang format. A custom parser handles that content type, and it runs before routing and authentication. That means any anonymous POST reaches it. The parser decodes bodies with Plug.Crypto.non_executable_binary_to_term/2 and [:safe]. That combination rejects functions and new atoms, but it does not inspect maps. In Elixir a struct is just a map with a __struct__ key, so an attacker could make up a struct of any existing module and fill in any fields.

The gadget chain uses only libraries that were already loaded:

  1. The decoded term becomes body params. Plug.MethodOverride reads body_params["_method"], which calls fetch/2 on the module the attacker chose. That function doesn’t exist, so an UndefinedFunctionError is raised with the attacker’s struct in the stack trace.
  2. Error reporting (Sentry, Bandit logging, the JSON log formatter) calls inspect on the request data. Inspect dispatches to the protocol implementation for the struct’s module, which the attacker set to Ecto.Query.DynamicExpr.
  3. That Inspect implementation enumerates the binding field without checking that it is a list. The attacker put a DBConnection.Stream there.
  4. Enumerating the stream calls DBConnection.reduce/3 and then declare/4. Query encoding fails before a connection is checked out, but the error path still runs the stream’s :log option. That option is an attacker-supplied {module, function, args} tuple, and applying it gives arbitrary function calls. That leads to command execution as the BEAM user.

Plug, Ecto or db_connection each behave as documented on their own. The RCE comes from combining them, and it starts from a decoder that is only safe for trusted input.

Timeline and scope

  • Nov 19 onward: The two attacker IPs repeatedly downloaded hex.pm’s own dependencies, probably to build the chain against a local copy.
  • Nov 23, 18:16–18:29 UTC: 69 exploit requests were sent. The first attacker-created file appeared on a server 3 ms after the first request.
  • 18:27–18:33: A firewall block was added. At 18:28 a restart brought up three servers that were still vulnerable. All servers were replaced with the patched build at 18:30–18:31.
  • 18:47–18:49: The AWS access key used by the servers was replaced and then deactivated. Most infrastructure credentials were rotated by 20:21.
  • Nov 24: The database password was rotated, and so were all readable credentials except the registry signing key. Hex is replacing that key with a new signing system rather than rotating it in place. CVE-2026-129514 was published at 13:48 UTC.

Possibly exposed: email addresses, bcrypt password hashes, API key hashes, 2FA secrets, sessions and audit logs. Private packages and docs show no attacker requests in the CDN logs, but direct cloud-storage reads aren’t logged. Hex says API keys (HMAC-SHA256 hashes of 128-bit random values) don’t need rotation.

Integrity checks: All 23 releases published during the incident window match audit-log entries, and no older release changed. All 62 package tarballs and 186 registry files written since 18:00 match database checksums. Documentation archives have no stored checksums, so they could not be verified this way.

The same investigation led to coordinated fixes elsewhere in the ecosystem:

  • CVE-2026-124283 (Ash): crafted structs in keyset pagination cursors could lead to command execution or SQL injection. Fixed in ash 3.38.0.
  • CVE-2026-133555 (db_connection): :log callbacks taken from stream structs are applied without checks. A fix is coming.
  • Hardening is planned for plug_crypto (an option to reject structs), plug (refuse struct values as body params) and ecto (check binding in Inspect).

If your own Phoenix or Plug app feeds untrusted bytes into binary_to_term, non_executable_binary_to_term, or any [:safe] variant, this same chain may work against it.

What to do now

  1. Change your hex.pm password and reset 2FA: go to Dashboard → Security → Authenticator App → “Setup New App”, then save the new recovery codes. The 2FA secrets themselves may have been read.
  2. Fetch only from repo.hex.pm until the new signing system ships. Don’t trust third-party mirrors, because the old signing key may be exposed.
  3. Update the client when the new release lands: run mix local.hex --force, and update rebar3 and Gleam.
  4. Audit your lockfiles: check mix.lock checksums against known-good values for anything resolved recently, especially in CI caches.
  5. Watch for phishing that claims to come from Hex. Leaked emails make targeted lures likely. Forward suspicious mail to [email protected].
  6. Audit your own Elixir services for term decoding of unauthenticated input. Upgrade Ash to 3.38.0 and track the db_connection fix.

References