CVE
CVE-2026-129514, CVE-2026-133555, CVE-2026-130411
CWE
CWE-502, CWE-470
Affected Surface
- The hex.pm service (Elixir, Erlang and Gleam package registry) from 23 February 2016 until the fix deployed at 18:31 UTC on 23 November 2026; exploited on 23 November 2026 (CVE-2026-129514)
- Self-hosted deployments of the open-source `hexpm/hexpm` application from commit `ab1bbce` up to, but not including, fix commit `379b0a2`
- hex.pm user accounts: email addresses, bcrypt password hashes, HMAC-SHA256 API key hashes, 2FA secrets, sessions and audit logs may have been read
- Hex `db_connection` 1.1.0 up to but not including 2.10.3 (CVE-2026-133555), the gadget that turns a forged `DBConnection.Stream` into a function call
- Hex `flop` 0.8.0 to 0.26.6, 0.27.0 to 0.27.2, 0.28.0 and 0.29.0 to 0.29.1 (CVE-2026-130411), which decoded pagination cursors with `binary_to_term`
TL;DR
Hex.pm is the package registry for Elixir, Erlang and Gleam. On 23 November 2026, between 18:16 and 18:29 UTC, an attacker sent 69 requests that ran commands on six hex.pm web servers. Hex added a firewall rule at 18:27 and had every server on a patched build by 18:31. It published its incident report and CVE-2026-129514 (CVSS 4.0 10.0, E:A) the next day.
The bug was in how hex.pm parsed request bodies. Hex clients send Erlang terms with the content type application/vnd.hex+erlang, and the server decoded those bodies before routing or authentication. The decoder refused functions and unknown atoms, but it accepted maps with a __struct__ key, so a client could send forged Elixir structs. When the request failed, error reporting called inspect/1 on those structs, which led through Ecto.Query.DynamicExpr and DBConnection.Stream to an apply/3 on a module, function and arguments taken from the body.
Hex says it found no modified packages, no database changes and no persistence. Database reads aren’t logged, so it can’t rule out that the attacker read email addresses, password hashes, API key hashes, 2FA secrets, sessions and audit logs. It has rotated the storage, CDN, email and database credentials and the session and token signing keys. It has not rotated the registry signing key yet, because the current system doesn’t support rotation. New Hex clients with a new signing system are due “in the coming days”.
What to do now:
- If you have a hex.pm account, change your password and reset 2FA by setting up a new authenticator app. Then log the client in again with
mix hex.user authorrebar3 hex user auth. - Fetch packages only from
repo.hex.pmuntil the new Hex client ships. Unset anyHEX_MIRROR,HEX_MIRROR_URLormirror_urlsetting. - Upgrade
db_connectionto 2.10.3,flopto a fixed release, andashto 3.38.0 (our Ash write-up). - Search your own code and dependencies for
binary_to_termon input you don’t control. The[:safe]option does not block structs. - Treat emails claiming to come from Hex with suspicion, since addresses may have leaked.
Affected packages and projects
| Ecosystem | Package or service | Affected versions | Fixed or safe version |
|---|---|---|---|
| Service | hex.pm | 23 February 2016 to 23 November 2026 | Patched build deployed 18:30 to 18:31 UTC, 23 November 2026 |
| GitHub (self-hosted) | hexpm/hexpm | ab1bbce up to 379b0a2 | Commit 379b0a2 or later |
| Hex | db_connection | 1.1.0 to 2.10.2 (CVE-2026-133555) | 2.10.3 (24 November 2026) |
| Hex | flop | 0.8.0 to 0.26.6, 0.27.0 to 0.27.2, 0.28.0, 0.29.0 to 0.29.1 (CVE-2026-130411) | 0.26.7, 0.27.3, 0.28.1, 0.29.2 (24 November 2026) |
| Hex | ash | 3.31.3 to 3.37.x (CVE-2026-124283) | 3.38.0 (24 November 2026) |
| Hex clients | hex (Mix), rebar3, Gleam | Releases without the new registry signing system | Release with the new signing system, not yet published on 24 November |
The EEF records db_connection as “not exploitable in db_connection alone”. It received a CVE because attackers used its struct as the last hop of the chain. Any application that turns untrusted bytes into terms with binary_to_term and then inspects or enumerates the result is exposed in the same way, whether or not db_connection is loaded.
Technical analysis
1. The parser ran before authentication
HexpmWeb.Endpoint mounts a custom parser alongside the stock ones:
plug Plug.Parsers,
parsers: [:urlencoded, :json, HexpmWeb.PlugParser],
pass: ["*/*"],
json_decoder: JSON
HexpmWeb.PlugParser claims application/vnd.hex+erlang and application/vnd.hex+json, reads the body and hands it to the matching decoder. Endpoint plugs run before the router and before any authentication plug, so a POST to any path with that content type reached the decoder.
2. The decoder let structs through
This is HexpmWeb.ErlangFormat.decode/1 before the fix:
def decode(binary) do
term = Plug.Crypto.non_executable_binary_to_term(binary, [:safe])
{:ok, term}
rescue
ArgumentError ->
{:error, "bad binary_to_term"}
end
[:safe] makes the VM refuse atoms that don’t exist yet. non_executable_binary_to_term/2 also refuses functions. Neither looks at maps. An Elixir struct is a map whose __struct__ key names a module, and in a release every module name is already an atom, so the client can send a value the runtime treats as any struct it likes, with every field chosen.
The decoder used to be stricter. The 2016 commit ab1bbce, titled “Fix for some bad requests”, deleted an allow-list check:
term = :erlang.binary_to_term(binary, [:safe])
- if safe_term?(term) do
- {:ok, term}
- else
- {:error, "unsafe binary_to_term"}
- end
+ {:ok, term}
...
- # No atoms allowed!
- defp safe_term?(term) when is_number(term), do: true
- defp safe_term?(term) when is_binary(term), do: true
- defp safe_term?(term) when is_boolean(term), do: true
- defp safe_term?(term) when is_list(term), do: Enum.all?(term, &safe_term?/1)
- defp safe_term?(term) when is_tuple(term), do: Enum.all?(Tuple.to_list(term), &safe_term?/1)
- defp safe_term?(term) when is_map(term), do: Enum.all?(term, &safe_term?/1)
- defp safe_term?(_), do: false
safe_term?/1 rejected every atom, so a __struct__ key could never have passed. Everything from that commit onward is in the affected range.
3. From a bad request to apply/3
Hex’s post and the EEF record describe the same chain:
- The error. The decoded struct became the request’s body params.
Plug.MethodOverridereadsbody_params["_method"]on everyPOST. On a struct,Accesscallsfetch/2on the struct’s module.Ecto.Query.DynamicExprhas nofetch/2, so the request raisesUndefinedFunctionErrorwith the forged struct as a stack frame argument. - Error reporting runs
inspect. Sentry, Bandit’s error log (throughException.format/3) and the JSON log formatter all callinspect/1on request data and frame arguments.Inspectis a protocol, so it dispatches on__struct__and runsInspect.Ecto.Query.DynamicExpr. - The Ecto hop. That implementation calls
Enum.map/2on thebindingfield without checking it is a list. The attacker put aDBConnection.Streamstruct there, soEnumerabledispatches to db_connection. - The db_connection hop.
Enumerable.DBConnection.StreamcallsDBConnection.reduce/3, which callsdeclare/4with theconn,query,paramsandoptsfrom the struct. Query encoding fails before a connection is checked out, but the error path still calls the:loghook fromopts. - The call. For a
{module, function, args}tuple, the hook wasapply(mod, fun, [entry | args]). The log entry takes the first argument slot, so the attacker names a standard library function that ignores it and applies a further MFA. The EEF’s flop write-up uses{:proc_lib, :init_p, [[], module, function, arguments]}for this. The final call ran an OS command as the BEAM user.
Inspect.Algebra wraps struct inspect calls in a rescue, so each exploit request ended in an ordinary 500. Hex matched the first file the attacker created to a request at 18:16:46 that arrived 3 ms earlier.
The BEAM user could read the application environment, which held the database URL, the storage credentials and the registry signing key.
4. The fixes
Hex’s fix, commit 379b0a2, was authored at 18:26:41 UTC, while the attack was still running. It walks the decoded term and rejects any map that has a __struct__ key, in keys or values, inside lists or tuples:
def decode(binary) do
term = Plug.Crypto.non_executable_binary_to_term(binary, [:safe])
- {:ok, term}
+
+ if struct?(term) do
+ {:error, "bad binary_to_term"}
+ else
+ {:ok, term}
+ end
rescue
ArgumentError ->
{:error, "bad binary_to_term"}
end
+
+ defp struct?(map) when is_map(map) do
+ Map.has_key?(map, :__struct__) or
+ Enum.any?(map, fn {key, value} -> struct?(key) or struct?(value) end)
+ end
+
+ defp struct?([head | tail]), do: struct?(head) or struct?(tail)
+ defp struct?(tuple) when is_tuple(tuple), do: struct?(Tuple.to_list(tuple))
+ defp struct?(_other), do: false
The parser turns that error into a 400.
db_connection commit 9a4230a, shipped in 2.10.3, removes the last hop. stream/4 and prepare_stream/4 now convert a {mod, fun, args} :log option into a closure when the stream is built, and the code that runs inside the Enumerable implementation only calls closures:
def stream(%DBConnection{} = conn, query, params, opts \\ []) do
+ opts = normalize_log(opts)
%DBConnection.Stream{conn: conn, query: query, params: params, opts: opts}
end
...
- defp log({mod, fun, args}, entry), do: apply(mod, fun, [entry | args])
defp log(fun, entry), do: fun.(entry)
A forged struct can’t carry a closure, because the decoder refuses functions, so a tuple placed in opts by an attacker no longer gets applied.
Hex lists further hardening it is working on: a plug_crypto option to reject structs and documentation that its decoder is only safe for authenticated payloads, plug refusing struct body params, and ecto checking that binding is a list before enumerating it.
5. The same chain elsewhere
Hex found the same class of bug in Ash while investigating. Ash’s keyset pagination cursors went through binary_to_term and reached the same Ecto and db_connection gadgets. We covered that in detail in Ash keyset cursors allow code execution and SQL injection.
flop, a filtering and pagination library with about 46,000 downloads a week on Hex, had it too. Flop.Cursor.decode/2 decoded the after and before parameters with :erlang.binary_to_term/2 in :safe mode and rejected functions, PIDs, ports and references, but not maps. The EEF’s proof of concept wraps a DynamicExpr and DBConnection.Stream inside a DateTime struct’s year field. The cast to a :naive_datetime sort field succeeds, Ecto’s CastError inspects the value, and the stream’s :log MFA runs.
IOCs
Hex has not published the attacker’s two IP addresses or the commands it ran. What it did publish:
- First request from the attacker’s addresses: 23 November 2026, 18:14:21 UTC. Exploit requests: 18:16:00 to 18:29:33 UTC, 69 in total.
- Hex reviewed request logs for hex.pm, repo.hex.pm, builds.hex.pm and hexdocs.pm back to 19 November and found the same addresses repeatedly downloading hex.pm’s own dependencies. Hex reads this as the attacker building a local copy of hex.pm to test against.
- One worker server peaked at 0.47 MB/s of network traffic during the incident, against a usual maximum of 0.29 MB/s.
If you run hexpm yourself, or any Elixir service that decodes Erlang terms from clients, these are the traces to look for:
POSTrequests withContent-Type: application/vnd.hex+erlangto paths that don’t normally take a body, followed by a 500.- Request bodies containing the atom names
Elixir.Ecto.Query.DynamicExpr,Elixir.DBConnection.StreamorElixir.DBConnection.PrepareStream. Atoms are stored as plain text in the external term format, so a byte search on raw bodies finds them. UndefinedFunctionErrorforEcto.Query.DynamicExpr.fetch/2in Sentry or application logs.
Detection and remediation
Hex account holders. Hex’s steps, from its post and its Elixir Forum announcement:
-
Change your password at hex.pm. Passwords were stored with bcrypt, which slows guessing but doesn’t stop it for weak passwords.
-
Reset 2FA at
hex.pm/dashboard/security: under “Authenticator App”, choose “Setup New App” and verify a code. That issues a new secret and new recovery codes. GitHub sign-up users who set up 2FA should do this too. -
Log in to your client again, since the session and token signing keys were replaced:
mix hex.user auth rebar3 hex user auth -
When the Hex release with the new signing system is out, update with
mix local.hex --forceand update rebar3 and Gleam.
Hex says API keys are 128-bit random values stored as HMAC-SHA256 and doesn’t see a need to rotate them. Users who only run mix deps.get without a hex.pm account don’t need to change anything on the account side.
Mirrors. Until the new signing key ships, an attacker who read the old private key could sign registry data that current clients accept. Hex says not to trust third-party mirrors and to fetch only from repo.hex.pm. Check for mirror settings on developer machines and CI:
mix hex.config mirror_url
mix hex.config trusted_mirror_url
env | grep -E '^HEX_(TRUSTED_)?MIRROR'
grep -rnE 'HEX_(TRUSTED_)?MIRROR|mirror_url' .github/ .gitlab-ci.yml Dockerfile* 2>/dev/null
Dependencies. Check your lockfile for the three libraries:
grep -E '"(db_connection|flop|ash)":' mix.lock
mix deps.update db_connection flop ash
Your own decoders. Find every place that turns external bytes into terms, in your code and in your dependencies:
grep -rnE 'binary_to_term|non_executable_binary_to_term' lib/ deps/ --include='*.ex' --include='*.erl'
For each hit, check where the bytes come from. If a client can supply them (cookies, cursors, request bodies, job payloads, cache entries an attacker can write), either sign them and verify before decoding, switch the format to JSON, or reject any map with a __struct__ key the way Hex’s fix does. [:safe] only stops new atoms.
Self-hosted hexpm. Deploy commit 379b0a2 or later. If you ran an older build on the internet, search request logs and bodies for the IOCs above, and if anything matches, rotate every secret in the application environment, including your registry signing key.
Private organizations. Hex says reads of private packages during the incident came from its own servers and lined up with releases those organizations published, but a read made from a compromised server would look the same, and private documentation reads aren’t logged. Hex will contact affected organizations directly.
Timeline
- 2016-02-23: Commit
ab1bbceremoves thesafe_term?/1allow-list from the Erlang term decoder. - 2026-11-19 to 2026-11-23: In logs reviewed from 19 November, the attacker’s addresses repeatedly download hex.pm’s own dependencies.
- 2026-11-23 18:14:21 UTC: First request from the attacker’s addresses.
- 2026-11-23 18:16:00 to 18:29:33 UTC: 69 exploit requests. Commands run on six web servers; three of them were new servers brought up on the vulnerable build by a restart at 18:28.
- 2026-11-23 18:23:55 UTC: Hex’s first response on the servers.
- 2026-11-23 18:26:41 UTC: Fix commit
379b0a2authored. - 2026-11-23 18:27 UTC: Firewall rule added; fully effective between 18:30 and 18:33.
- 2026-11-23 18:30 to 18:31 UTC: Every web, worker and job server replaced with the patched build.
- 2026-11-23 18:49 UTC: The AWS access key used by the affected servers is deactivated.
- 2026-11-23 19:07 UTC: Hex receives an emailed security report describing the same vulnerability.
- 2026-11-23 19:26 UTC: db_connection fix commit
9a4230aauthored. - 2026-11-23 20:21 UTC: Most infrastructure credentials rotated.
- 2026-11-23 22:58 to 23:26 UTC: Hex reports a personal data breach to IMY (Sweden), reports the incident to CISA and sends an early warning to ENISA.
- 2026-11-24 02:57 UTC: ash 3.38.0 published on Hex.
- 2026-11-24 by 10:42 UTC: Every credential the attacker could have read is rotated, including the database password, except the registry signing key and some low-impact secrets.
- 2026-11-24 13:48 UTC: CVE-2026-129514 and GHSA-9pmm-hf4r-27pg published.
- 2026-11-24 14:08 UTC: db_connection 2.10.3 published; CVE-2026-133555 follows at 14:12.
- 2026-11-24 14:51 to 14:56 UTC: flop 0.29.2, 0.28.1, 0.27.3 and 0.26.7 published; CVE-2026-130411 follows at 14:58.
References
- Hex blog: Security incident on hex.pm
- GitHub Advisory GHSA-9pmm-hf4r-27pg
- EEF CNA: CVE-2026-129514
- hexpm fix commit 379b0a2
- hexpm commit ab1bbce (2016)
- EEF CNA: CVE-2026-133555 (db_connection)
- GitHub Advisory GHSA-gmmq-fw75-wq46 (db_connection)
- db_connection fix commit 9a4230a
- EEF CNA: CVE-2026-130411 (flop)
- Elixir Forum: Hex.pm - Security incident
- CyberSIXT: Hex.pm hacked through CVE-2026-129514 deserialization flaw
From research to remediation
Check whether this pattern exists in your codebase
Turn this research into a remediation workflow. Scan dependencies and package manifests for similar supply-chain risk, then prioritize fixes with reachability context.
References
- Hex blog (24 November 2026): Security incident on hex.pm
- GitHub Advisory GHSA-9pmm-hf4r-27pg: Unauthenticated remote code execution through struct values in Erlang term request bodies
- EEF CNA: CVE-2026-129514
- hexpm/hexpm commit 379b0a2: Refuse structs in Erlang term request bodies
- hexpm/hexpm commit ab1bbce (23 February 2016): Fix for some bad requests
- EEF CNA: CVE-2026-133555 (db_connection)
- GitHub Advisory GHSA-gmmq-fw75-wq46 (db_connection)
- elixir-ecto/db_connection commit 9a4230a: Normalize log entries outside of protocol implementations
- EEF CNA: CVE-2026-130411 (flop)
- Elixir Forum: Hex.pm - Security incident
- CyberSIXT (24 November 2026): Hex.pm hacked through CVE-2026-129514 deserialization flaw