Search This Blog

Powered by Blogger.

Blog Archive

Labels

Footer About

Footer About

Labels

Showing posts with label Commands. Show all posts

Attacker Ran Commands on Six Hex.pm Servers Through a Flaw Dating Back to 2016

 



An attacker executed operating system commands on six production servers of Hex.pm on Monday, November 23. Hex.pm is the registry where Elixir and Erlang developers download their dependencies. The maintainers had every server on a patched build about 15 minutes after the first malicious request. Their checks so far show no package was changed, but they cannot rule out that account data was read.

The flaw is tracked as CVE-2026-129514 and carries the maximum CVSS score of 10.0. It entered the codebase on February 23, 2016, when a safety check was removed. The security advisory lists hex.pm as affected from that date until Monday. The maintainers have not established that anyone exploited it before this week.


How the attack worked

The problem sat in the code that reads request bodies sent in an Erlang data format. That code ran before routing and authentication, so an anonymous POST request to any address on the site could reach it. The decoder was designed to be safe and did reject functions. It did not reject maps carrying a `__struct__` key, so a request could pass itself off as any Elixir struct the application had loaded.

The crafted struct did nothing by itself. It triggered an error, and the error-reporting code then inspected the struct. Through the Ecto and DBConnection database libraries, that inspection led the server to call a function chosen by the attacker, which ran commands with the permissions of the registry's service account. The fix makes the decoder refuse any term containing a map with a `__struct__` key.


Timeline

Load balancer logs show 69 exploit requests between 18:16 and 18:29 UTC, all from two addresses. Files created by the exploit appeared on six web servers, one of them 3 milliseconds after the request. Three of those servers joined mid-attack, when a restart brought up machines still running the vulnerable build. All servers ran the fix by 18:31 UTC.

A separate researcher report describing the same flaw reached the team by email at 19:07 UTC, after the attack had ended. On Monday night the team notified the Swedish data protection authority, CISA in the United States and ENISA in the European Union.


What the investigation found and missed

To check for tampering, the team compared every database table with a copy taken two minutes before the first exploit request and traced each difference to normal activity. The 23 releases published during the attack match the audit log. No older release was altered, and the package and registry files written that evening match database records. The team also found no leftover shells and no new accounts or cloud keys.

The gap is in what was never logged: database reads, shell commands, environment variables and direct reads from file storage. The database holds email addresses, password hashes, API key hashes, two-factor secrets and session data. Private packages could also have been read without a trace. The attacker's identity is unknown. Activity from the same two addresses going back to late last week suggests they built a local copy of hex.pm to practice on.


What users need to do

The maintainers replaced the keys that sign sessions and access tokens, which logged out every account holder. Users should change their password and set up a fresh authenticator entry to get a new 2FA secret and recovery codes. They should then log back in to the client with `mix hex.user auth`, or `rebar3 hex user auth` for Erlang projects. Because email addresses may be exposed, they should treat emails claiming to come from Hex with suspicion and check that links lead to hex.pm.

API keys do not need replacing. They are random 128-bit values stored only as HMAC-SHA256 hashes, which the team says cannot realistically be brute-forced. Passwords use bcrypt, which slows guessing but will not save a weak one.

Peter Ullrich, one of the report's authors, clarified on the Elixir Forum that developers who never made an account and only pull public packages have nothing to reset. People who signed up through GitHub should still log back in to their clients and reset 2FA if they enabled it.

One credential remains unreplaced: the registry signing key, which the attacker may have read. A client release with a new signing system is expected within days. Until then, the team advises fetching packages only from repo.hex.pm and avoiding third-party mirrors. Organizations running their own registry copy are exposed until they deploy the patch, since the fault is in the server code and not the Hex client.


Related fixes in the Elixir ecosystem

Maintainers of three libraries disclosed separate struct-related flaws and shipped fixes on Tuesday. These are not further attacks on Hex.pm.

- ash: CVE-2026-124283, fixed in 3.38.0.

- db_connection: CVE-2026-133555, fixed in 2.10.3.

- flop: CVE-2026-130411, fixed in 0.26.7, 0.27.3, 0.28.1 and 0.29.2.

Each needs specific conditions to be exploited. The Ash advisory describes a setup using keyset pagination with a client-supplied cursor and an unset signing secret. The DBConnection advisory says the flaw is not exploitable in that library alone, because another component must first decode untrusted data into structs.


Earlier warnings about the same class of bug

This is not the first time the project's handling of Erlang term data has drawn scrutiny. An April 2026 audit by Paraxial.io and zentrust partners, funded by OpenSSF and overseen by the Erlang Ecosystem Foundation, flagged unsafe decoding in the Hex client. That issue, CVE-2026-21619, was rated low at 2.0 out of 10 and was a different, client-side problem. On November 24, the foundation's security working group published guidance by Dan Janowski. It advises against using `binary_to_term` on data from outside a program's trust boundary and suggests a constrained format such as JSON with input validation.