This is the English adaptation of the original Korean analysis at dohyeontech.github.io.
At 18:16 UTC on 23 November 2026, an exception landed in hex.pm's Sentry instance. Between then and 18:29:33 the service took 69 requests, and files appeared on six web servers. The first of those files was created 3 milliseconds after a request arrived. By 18:30–18:31 every web, worker and job server had been replaced with a patched build. Fifteen minutes from the first malicious request to full coverage.
hex.pm is the default registry that mix deps.get, rebar3 and gleam add reach for. What happened there was not one service losing its own data; it was the input to everyone's build being reachable by whoever sent those 69 requests. Most coverage reduced the technical story to two sentences: the Erlang term parser accepted structs, and Ecto plus DBConnection turned that into command execution. This article unpacks those two sentences at the code level — why a decoder invoked with [:safe] and named non_executable_binary_to_term still allowed execution, what check was deleted on 23 February 2016, why the fix sits in one decoder, and why the Ash, db_connection and Flop records published the same week are the same disease with different symptoms.
1. What is established, and where the proof stops
Sources disagree slightly on scores and dates, so separate them first.
| Field | Value | Source |
|---|---|---|
| CVE | CVE-2026-129514 | EEF CNA (published 2026-11-24 13:48 UTC) |
| Score | CVSS 4.0 10.0 · AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H/E:A | GHSA-9pmm-hf4r-27pg |
| Weakness | CWE-502 (deserialization of untrusted data) · CAPEC-586 | CNA record |
| Affected range | hex.pm 2016-02-23 – 2026-11-23, repository ab1bbce – 379b0a2 | GHSA affected/patched |
| Exploitation | 2026-11-23 18:16:00–18:29:33 UTC · 69 requests · 6 web servers | Incident report |
| NVD status | Awaiting Analysis (lastModified 2026-11-24 19:12 UTC) | NVD API 2.0 |
| EPSS | 1.65%, 76.9th percentile (2026-11-25) | FIRST |
| CISA KEV | not listed (catalog 2026.11.25, 1,805 entries; checked 2026-11-26 09:05 KST) | KEV JSON |
E:A (Exploit Maturity: Attacked) is the metric that describes this case honestly: it is scored as a vulnerability with confirmed exploitation, not a theoretical one. EPSS at 1.65% points the other way, and that is expected. EPSS estimates the chance that automated internet-wide scanning will hit a given CVE; the hex.pm server code is public but the running service is a single target, so the automatable surface is thin. When the two disagree, E:A wins every time.
The timeline is where the density shows. All times UTC.
| Time | Event |
|---|---|
| from 11-19 | Two addresses repeatedly download hex.pm's own dependencies — consistent with building a local copy to test against |
| 11-23 18:14:21 | First request from either address (not an exploit) |
| 18:16:00 | First exploit request; Sentry records its first exception |
| 18:16:46 | A file appears on a web server 3 ms after a request |
| 18:23:55 | First response action on the servers |
| 18:27 | Firewall rule added (fully effective 18:30–18:33) |
| 18:30–18:31 | Every web, worker and job server replaced with the patched build |
| 18:29:33 | Last exploit request to reach a server |
| 18:33:48 | All further requests from the attacker addresses denied |
| 18:47 / 18:49 | Replacement AWS key created / affected servers' key deactivated |
| 19:07 | Email arrives describing the same vulnerability (after the attack ended) |
| 20:21 | Most infrastructure credentials rotated (database password followed on 11-24) |
| 22:58 · 23:05 · 23:26 | Reported to Sweden's IMY · CISA (receipt 23:43) · ENISA early warning |
| 11-24 10:42 | All credentials rotated except the registry signing key and a few low-impact secrets |
| 11-24 13:48 | CVE-2026-129514 published |
One operational lesson deserves emphasis. A restart resurrected the vulnerable build. The fleet was replaced at 18:30, but a restart at 18:28 brought up three servers still running the old build, and those three joined mid-attack — half of the six compromised hosts. While patched and unpatched images circulate at the same time, a rollout is not atomic. That is why the report paired each server's creation time with its build, host by host.
What was proven, and what could not be
The public investigation is the most honest part of this incident: the line between "we proved this" and "we could not rule this out" is drawn in every paragraph.
Proven. No package tampering. All 23 releases published during the incident match a publish or stage entry in the audit log, and no older release changed. All 62 package files and 186 registry files written since 18:00 match the checksums stored in the database. No database writes: a snapshot from 18:13:59, two minutes before the first request, was restored and compared row by row across every table, and every difference traced to another address's audit entry, a background job, or the team's own response actions. No leftover shells, no new accounts, no new cloud keys. No credential use from outside: 15,635 S3 access log records were cross-referenced so that each of the 288 versions and markers between 18:00 and 20:00 had a log record from the same key within 3 seconds, and all 6,279 hexpm-prod requests came from three node IPs.
Not proven. Database reads, environment variable reads and shell command output are not logged. Email addresses, bcrypt password hashes, HMAC-SHA256 API key hashes, 2FA secrets, sessions, audit logs and private packages therefore cannot be ruled out. Direct reads of private documentation from object storage are unlogged too.
Two self-reported gaps in the integrity evidence are worth keeping in view. Documentation archives have no stored checksum to compare against, so documentation tampering is not excluded by the checksum sweep. And a row that changed and then changed back, or one that a later legitimate write overwrote, does not appear in a snapshot comparison at all. Integrity checks are only as wide as what they compare.
2. What "non-executable" actually promised
2.1 A parser ahead of authentication
HexpmWeb.Endpoint mounts Plug.Parsers with a custom HexpmWeb.PlugParser ahead of the router and authentication plugs, because the body has to become parameters before routing can happen. The entry point in lib/hexpm_web/plug_parser.ex:
# lib/hexpm_web/plug_parser.ex @formats ~w(erlang json) def parse(%Conn{} = conn, "application", "vnd.hex+" <> format, _headers, opts) when format in @formats do decoder = get_decoder(format, opts) conn |> Conn.read_body(opts) |> decode(decoder) end application/vnd.hex+erlang is a media type the Hex client really uses. A POST to any path reaches this code, with or without a valid route, with or without credentials. That single fact explains PR:N and AV:N.
2.2 The decoder's contract
Before the fix, decode/1 in lib/hexpm_web/erlang_format.ex was one call:
# lib/hexpm_web/erlang_format.ex (pre-patch) def decode(binary) do term = Plug.Crypto.non_executable_binary_to_term(binary, [:safe]) {:ok, term} rescue ArgumentError -> {:error, "bad binary_to_term"} end The helper accepts only terms that cannot be executed. Its internals draw the boundary precisely:
# lib/plug/crypto.ex defp non_executable_terms(other) when is_atom(other) or is_number(other) or is_bitstring(other) or is_pid(other) or is_reference(other) do other end defp non_executable_terms(other) do raise ArgumentError, "cannot deserialize #{inspect(other)}, the term is not safe for deserialization" end Funs match no clause and are rejected. That is exactly what the function guards: terms that are themselves code.
In Elixir, a struct is not a special object. It is a map whose :__struct__ key names a module, and protocol dispatch looks at that key and nothing else.
# same runtime value %{__struct__: URI, host: "example.com"} # == %URI{host: "example.com"} So a request body can declare "this is an Ecto.Query.DynamicExpr". The [:safe] option to :erlang.binary_to_term/2 only rejects atoms not already present in the VM, and in a release every module the application depends on is already an atom. Ecto.Query.DynamicExpr and DBConnection.Stream are not new atoms. They pass.
The invariant that broke is one sentence: "a value taken from a request body is data and invokes no library implementation." Once that fails, inspect/1, Enum.map/2 and Access.get/3 — ordinary kernel-level functions — all become attacker-chosen dispatch points. Blocking functions and blocking code selection turned out to be entirely different problems.
2.3 The check deleted on 23 February 2016
The age of the flaw comes from git history. Commit ab1bbce on 23 February 2016 removed the safety check. The code before it:
# web/erlang_format.ex (before 2016-02-23) def decode(binary) do try do term = :erlang.binary_to_term(binary, [:safe]) if safe_term?(term) do {:ok, term} else {:error, "unsafe binary_to_term"} end rescue ArgumentError -> {:error, "unsafe binary_to_term"} end end # 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 The comment states the intent: "No atoms allowed!" This rejected every atom, and since :__struct__ is an atom key, the attack dies at step 1 if that check is live.
But the check also rejected legitimate traffic. Atom keys in maps are a normal shape for Hex client payloads. The commit's subject is "Fix for some bad requests"; the same change flips debug_errors: true to false and renames an exception module. In a commit that quiets debug responses and tidies bad-request handling, the over-broad safety check was lifted wholesale. It is possible the author judged the atom walk redundant next to [:safe], which already blocks new atoms. Either way the outcome is the same: a boundary was needed that rejects the attack without rejecting normal traffic, and the boundary was removed instead.
In 2018 the hand-written decoder was replaced by the Plug.Crypto one (commit 38f4696), whose contract is "reject executable terms" and whose name became non_executable_binary_to_term. The name sounds stronger; the guarantee got narrower. It blocks functions and does nothing about data that selects code. hex.pm's own hardening list opens with documenting that the decoder is only safe for authenticated payloads — an admission that the name misled people, the maintainers included.
2.4 Four faces of one disease
The four EEF CNA records published this week share a root. They are independent defects, all describable in one sentence: untrusted terms were decoded and then handed to protocol dispatch.
| Target | CVE | Entry point | Fix |
|---|---|---|---|
| hexpm | CVE-2026-129514 | application/vnd.hex+erlang request body parser | deployed 2026-11-23 |
| ash | CVE-2026-124283 | keyset pagination cursor (page[:after]) with keyset_signing_secret unset | ash 3.38.0 |
| db_connection | CVE-2026-133555 | not exploitable alone — something must enumerate a forged DBConnection.Stream | 2.10.3 |
| flop | CVE-2026-130411 | after/before cursor pagination parameters | 0.26.7 · 0.27.3 · 0.28.1 · 0.29.2 |
Ash's conditions are specific enough to be instructive. The cursor is :erlang.term_to_binary/1 encoded and [:safe] decoded, and Ash.Expr.expr?/1 does not look inside a struct that is not an expression struct. The type cast then passes structs through for :ci_string, :map, :struct and :term. If the sort field is one of those four and no signing secret is configured, a single cursor reaches the same gadget chain. Swap the payload for an %Ash.Query.Function.Fragment{} inside an %Ash.CiString{} and raw SQL lands in the WHERE clause — code execution and SQL injection diverging from the same input.
3. Seven steps from request to function call
The report and the advisory publish the whole chain. Paths and function names below are the sources' own.
Step 1 — decode. The endpoint parser hands the body to HexpmWeb.ErlangFormat.decode/1, and Plug.Crypto.non_executable_binary_to_term(binary, [:safe]) returns the map. If the decoded term is a map, the parser returns it as body params and Plug.Parsers merges it into conn.params. From here the request data is treated as a struct.
Step 2 — force an error. Plug.MethodOverride evaluates body_params["_method"] on every POST. For a struct, Access.get/3 calls fetch/2 on the named module. Ecto.Query.DynamicExpr has no fetch/2, so an UndefinedFunctionError is raised and the attacker's struct sits in the top stack frame's arguments.
Step 3 — inspect dispatch. Error reporting calls inspect/1 on request data and stack-frame arguments: Sentry, Bandit's error log through Exception.format/3, the JSON log formatter. inspect/1 is the Inspect protocol, so it runs the implementation of the module named in __struct__. The attacker chose Ecto.Query.DynamicExpr.
Step 4 — through Ecto. The pre-patch implementation opens like this (lib/ecto/query/inspect.ex:6):
# ecto 3.14.x (pre-patch) defimpl Inspect, for: Ecto.Query.DynamicExpr do def inspect(%DynamicExpr{binding: binding} = dynamic, opts) do binding = Enum.map(binding, fn {{:^, _, [as]}, bind} when is_atom(as) -> {as, bind} other -> other end) There is no guard that binding is a list. Enum.map/2 is itself a protocol call, so putting another struct in binding dispatches to that struct's Enumerable implementation.
Step 5 — through DBConnection. The struct placed in binding is a DBConnection.Stream. The implementation at lib/db_connection.ex:13 forwards to DBConnection.reduce/3, and reduce/3 (line 1298) pulls conn, query, params and opts out of the struct and calls declare/4.
Step 6 — the :log option becomes a function. declare/4 calls meter(opts) before encoding the query. The :log option is documented as accepting a function or an {module, function, args} tuple.
# lib/db_connection.ex (pre-patch meter/1) defp meter(opts) do case Keyword.get(opts, :log) do nil -> nil {mod, fun, args} -> {&apply(mod, fun, [&1 | args]), []} log -> {log, []} end end Query encoding fails before a connection is checked out, but the failure path still invokes the log hook. The closure above prepends the log entry as the first argument and calls apply(mod, fun, [entry | args]). All three values came from the request body.
Step 7 — execution. Because the first argument is pinned to the log entry, the attacker needs an OTP standard-library function that ignores it and applies the remaining three as module, function and arguments. The PoC printed in the Flop record uses exactly that shape:
# gadget from the flop CVE-2026-130411 PoC (harmless: prints :hi) {:proc_lib, :init_p, [[], IO, :inspect, [:hi]]} :proc_lib.init_p applies the trailing module, function and arguments, and the inner call runs IO.inspect(:hi). Replace the innermost position with something that spawns an OS command and the chain is complete. The hex.pm report describes step 7 as "OS command execution as the BEAM's user", a user that can read the database URL, storage credentials and the registry signing key from the environment.
3.1 Why the attacker got nothing back
The last link is quiet for a structural reason. The Inspect implementation runs inside a rescue in Inspect.Algebra, so a successful command produces no response body; the request ends with the ordinary 500 for the Plug.MethodOverride error. It is blind execution, which is why the attacker sent 69 requests. Whether a file actually appeared was knowable only from server-side artifacts — which is how the report matched request timestamps to created files and identified six hosts.
3.2 What a defender can see
The attacker IPs were not published; the report says only "two addresses". What remains is the shape of the request.
POST /<any-path> HTTP/1.1 Content-Type: application/vnd.hex+erlang <ETF binary: Erlang external term format, starting with byte 131> Hex clients use this media type on known paths, but no legitimate client sends a body containing a map with a __struct__ key. After the patch, such a request returns 400. Three detection signals follow:
- reverse proxy or WAF logs showing
application/vnd.hex+erlangPOSTs returning 500 (pre-patch) or 400 (post-patch) - an error tracker showing
UndefinedFunctionErrorforEcto.Query.DynamicExpr.fetch/2— step 2 guarantees it. Sentry's first exception at 18:16:00 was exactly this - the accompanying
DBConnection.ConnectionErrorandEcto.Query.CastErrornoise on the same request
The uncomfortable part for incident response: a successful command execution leaves nothing in the application log. Database reads, environment reads and shell output are unlogged, so "not in the logs" does not mean "did not happen". The hex.pm team went as far as full-table snapshot comparison, storage checksum sweeps and S3 access-log correlation precisely to fill the areas where logs are silent.
4. The patch: one decoder, and every link in the chain
4.1 hexpm commit 379b0a2
Two files, 32 insertions, 1 deletion. decode/1 walks the whole decoded term and returns an error if any map carries a :__struct__ key.
# lib/hexpm_web/erlang_format.ex (379b0a2) def decode(binary) do term = Plug.Crypto.non_executable_binary_to_term(binary, [:safe]) 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 check descends into keys, values, list tails and tuples rather than looking at the top-level map. The regression test pins all four shapes:
# test/hexpm_web/erlang_format_test.exs struct = %{__struct__: URI, host: "example.com"} assert {:error, _} = decode(:erlang.term_to_binary(struct)) # top level assert {:error, _} = decode(:erlang.term_to_binary(%{"params" => [{:ok, struct}]})) # in a value assert {:error, _} = decode(:erlang.term_to_binary(%{struct => "value"})) # as a key assert {:error, _} = decode(:erlang.term_to_binary([:a | struct])) # improper list The [:a | struct] case is the good one: hiding a struct in a list tail was closed before anyone used it. The test also asserts that an ordinary map still decodes, which is the check security patches most often skip.
The design judgment deserves a note. The check landed in the single decoder for this format, not in each route or endpoint. Duplicating validation at every call site means one site eventually gets missed — and this incident happened at the opposite failure, where validation disappeared entirely. One boundary, as far inside as possible.
4.2 A second fix nobody reported: release tarball metadata
Neither the incident report, the GHSA, nor the press mention this, but the repository history does. At 19:06 UTC the same day — 40 minutes after the request-body fix — commit 2d0be98a1d lands with the subject "Refuse structs in release tarball metadata".
A Hex package's metadata.config inside the .tar is parsed into Erlang terms. If that value contains a map with __struct__, publishing enumerates the requirements list and the same protocol dispatch occurs. The commit moves the check into a shared Hexpm.Utils.contains_struct?/1 and rejects such metadata with 422.
# lib/hexpm_web/controllers/api/release_controller.ex defp check_metadata_structs(metadata) do if Hexpm.Utils.contains_struct?(metadata), do: {:error, "metadata must not contain Elixir structs"}, else: :ok end So the same disease existed in the request body and in package metadata. The second door was not exploited because it requires authentication, but one account able to publish reaches the same command execution. Two fix commits rather than one says the response was "find and remove this pattern", not "patch a bug".
4.3 The ecosystem breaks the chain link by link
hex.pm published four follow-up hardening items; two were already in the repositories that night.
ecto — inspect verifies the list. Commit b6812d4 (2026-11-23 19:22 UTC) adds a guard:
def inspect(%DynamicExpr{fun: fun, binding: binding} = dynamic, opts) when is_function(fun, 1) and is_list(binding) do When the guard fails, the default Inspect implementation is used. There is a quiet, decisive detail here: a decoded term cannot contain a function. Plug.Crypto rejects funs, [:safe] rejects them too, so a forged %DynamicExpr{} can never satisfy is_function(fun, 1). is_list(binding) alone would be enough, but with the fun guard in place, a struct built from data is structurally identifiable as a forgery. A good guard does not just stop the attack; it explains why the attack is impossible.
db_connection — move normalization to construction. Commit 9a4230a (19:26 UTC) moves the conversion of :log MFA tuples into closures from declare/4 time to stream/3 and prepare_stream/3 construction time.
def stream(%DBConnection{} = conn, query, params, opts \\ []) do opts = normalize_log(opts) %DBConnection.Stream{conn: conn, query: query, params: params, opts: opts} end defp normalize_log(opts) do case Keyword.get(opts, :log) do {mod, fun, args} -> Keyword.put(opts, :log, &apply(mod, fun, [&1 | args])) _ -> opts end end A forged struct never passes through stream/3, so its :log stays a raw tuple; log(fun, entry) then calls fun.(entry) and raises BadFunctionError instead of applying anything. Moving normalization to the point where the object is built means an object that skipped that point has visibly not been normalized. Construction and validation in the same place is the whole value of the fix.
Outstanding. plug_crypto is documenting that the decoder is only safe for authenticated payloads and adding an option to reject structs; plug is preparing to reject structs as body params. As of 2026-11-26, non_executable_binary_to_term/2 in plug_crypto has no struct check yet. Check the docs and release notes when upgrading.
4.4 What to check now
1) Library versions. The four records have different preconditions but one version check.
mix deps | grep -E "ash|db_connection|flop|ecto|plug_crypto|plug " # thresholds: ash >= 3.38.0, db_connection >= 2.10.3, # flop >= 0.26.7 / 0.27.3 / 0.28.1 / 0.29.2 (per branch), # ecto: confirm a release carrying b6812d4 2) Ash cursor signing. Without keyset_signing_secret, forged cursors are accepted. On ash 3.37.0 or later, one line closes it:
config :ash, keyset_signing_secret: "…a long random string…" Previously issued cursors become invalid, so a user mid-infinite-scroll loses one page. The tradeoff is bounded: the condition is a sort field of type :ci_string, :map, :struct or :term.
3) Flop cursor pagination. The interim mitigation disables cursor pagination:
Flop.validate_and_run(Post, params, for: Post, repo: Repo, pagination_types: [:page, :offset]) Screens that never use after/before close the exposure with this option alone; the real fix is the upgrade.
4) Self-hosted hexpm. The source is public. Organizations running their own registry on hexpm code are exposed because the flaw is in server code, not the client, until they deploy the patch. Apply 379b0a2 and 2d0be98a, and check the private clients that authenticate with mix hex.user auth.
5) Verify the patch actually blocks. Use an isolated instance, not production. A harmless struct is enough.
# generate an inert test body (no command execution) payload = :erlang.term_to_binary(%{"name" => "x", "meta" => %{__struct__: URI}}) IO.puts(Base.encode...