Where
-Infinity
0
Severity
10
AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H/E:A

Summary

Deserialization of Untrusted Data vulnerability in the application/vnd.hex+erlang request body parser in hexpm hexpm allows an unauthenticated remote attacker to execute operating system commands via a crafted Erlang external term format request body. This vulnerability was actively exploited against the hex.pm service on 2026-11-23.

HexpmWeb.ErlangFormat.decode/1 in lib/hexpmweb/erlangformat.ex decodes the body with Plug.Crypto.nonexecutablebinarytoterm/2, which accepts maps that have a struct key. HexpmWeb.PlugParser.parse/5 returns the decoded term as the request params. The parser runs in the endpoint before routing and authentication, so a POST to any route reaches it. Elixir dispatches protocols on the struct key, so the client selects which Inspect and Enumerable implementations run when error reporting inspects the params. A chain through Ecto.Query.DynamicExpr and DBConnection.Stream reaches an apply/3 call on a {module, function, args} tuple taken from the request body.

This issue affects hex.pm: from 2016-02-23 before 2026-11-23; hexpm/hexpm: from ab1bbcef7cc8395d1056d3b1aa6a174353492d59 before 379b0a29bcc95164249f38ad7d772a37a8ff9533.

Details

1. Decoding. HexpmWeb.Endpoint runs Plug.Parsers with HexpmWeb.PlugParser ahead of the router, so the parser handles every route before any authentication plug. For the content type application/vnd.hex+erlang, HexpmWeb.PlugParser.parse/5 passes the body to HexpmWeb.ErlangFormat.decode/1, which calls Plug.Crypto.nonexecutablebinarytoterm/2 with [:safe]. That function refuses functions and new atoms. It places no restriction on maps, so a map with a struct key passes. In a release every module and function name is an existing atom. When the decoded term is a map, the parser returns it as the body params, and Plug.Parsers merges it into conn.params.

2. The error. An Elixir struct is a map whose struct key names a module, and protocol dispatch tests only that key. Plug.MethodOverride evaluates bodyparams["method"] on every POST. For a struct, Access.get/3 calls fetch/2 on the named module. Ecto.Query.DynamicExpr does not define fetch/2, so the call raises UndefinedFunctionError, and the top stack frame holds the decoded struct as an argument.

3. Inspect dispatch. Error reporting calls inspect/1 on the request data and on the stack frame arguments (Sentry, the Bandit error log through Exception.format/3, and the JSON log formatter). inspect/1 selects Inspect.Ecto.Query.DynamicExpr, which calls Enum.map/2 on the binding field without a check that the field is a list.

4. Enumerable dispatch. The binding field holds a DBConnection.Stream struct. Its Enumerable implementation calls DBConnection.reduce/3, which takes conn, query, params and opts from the struct and calls declare/4.

5. Function call. declare/4 reads the :log option from opts. Query encoding fails before a connection is checked out, and the error path still calls the log hook. For a {module, function, args} tuple the hook is apply(mod, fun, [entry | args]). All three values come from the request body. The log entry takes the first argument position, so the request names an OTP standard library function that applies a trailing module, function and argument list. The inner call runs an operating system command as the user of the BEAM process.

The Inspect implementation of a struct runs inside a rescue in Inspect.Algebra, so the request ends with the ordinary 500 response for the Plug.MethodOverride error.

The fix makes HexpmWeb.ErlangFormat.decode/1 return an error when any map in the decoded term has a struct key. The parser turns that error into a 400 response.

Impact

An unauthenticated attacker can run operating system commands as the user of the BEAM process. That user can read the environment of the application, which holds the database URL, the storage credentials and the registry signing key.

1 / 2
Source: OSV
First published (updated )
Severity
7
AV:N/AC:L/AT:P/PR:L/UI:N/VC:N/VI:H/VA:L/SC:N/SI:H/SA:N

Summary

Incorrect Authorization vulnerability in hexpm hexpm/hexpm (HexpmWeb.API.OAuthController module) allows Privilege Escalation.

An API key created with read-only permissions (domain: "api", resource: "read") can be escalated to full write access under specific conditions.

When exchanging a read-only API key via the OAuth clientcredentials grant, the resource qualifier is ignored. The resulting JWT receives the broad "api" scope instead of the expected "api:read" scope. This token is therefore treated as having full API access.

If an attacker is able to obtain a victim's read-only API key and a valid 2FA (TOTP) code for the victim account, they can use the incorrectly scoped JWT to create a new full-access API key with unrestricted API permissions that does not expire by default and can perform write operations such as publishing, retiring, or modifying packages.

This vulnerability is associated with program files lib/hexpmweb/controllers/api/oauthcontroller.ex and program routines HexpmWeb.API.OAuthController.validatescopesagainstkey/2.

This issue affects hex.pm: from 2025-08-18 before 2026-03-05; hexpm/hexpm: from 71829cb6f6559bcceb1ef4e43a2fb8cdd3af654b before 71c127afebb7ed7cc637eb231b98feb802d62999.

Workarounds

Revoke and reissue exposed API keys immediately if compromise is suspected. Avoid relying on read-only API keys as a strict security boundary in high-risk environments. Closely monitor audit logs for unexpected API key creation events. Enforce strong 2FA hygiene and protect TOTP seeds carefully.

There is no complete mitigation without upgrading, as the issue exists in server-side scope validation logic.

1 / 2
Source: OSV
First published (updated )
Severity
6.9
Path Traversal
AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N

Summary

Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') vulnerability in hexpm hexpm/hexpm (Hexpm.Store.Local module) allows Relative Path Traversal.

This vulnerability is associated with program files lib/hexpm/store/local.ex and program routines Hexpm.Store.Local.get/3, Hexpm.Store.Local.put/4, Hexpm.Store.Local.delete/2, Hexpm.Store.Local.deletemany/2.

This issue does NOT affect hex.pm the service. Only self-hosted deployments using the Local Storage backend are affected.

This issue affects hexpm/hexpm: from 931ee0ed46fa89218e0400a4f6e6d15f96406050 before 5d2ccd2f14f45a63225a73fb5b1c937baf36fdc0.

Workarounds

Avoid the local file store backend in any exposed environment. Restrict network access to the registry when using the local backend. Production deployments should use object storage (e.g., S3-compatible backends) instead of the local filesystem store.

Configurations

Only self-hosted hexpm deployments using the Hexpm.Store.Local storage backend are affected. The hex.pm service and deployments using S3-compatible object storage backends are not affected.

1 / 2
Source: OSV
First published (updated )
Severity
6.9
Path Traversal
AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N

Summary

Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') vulnerability in hexpm hexpm/hexpm (Hexpm.Store.Local module) allows Relative Path Traversal.

This vulnerability is associated with program files lib/hexpm/store/local.ex and program routines Hexpm.Store.Local.get/3, Hexpm.Store.Local.put/4, Hexpm.Store.Local.delete/2, Hexpm.Store.Local.deletemany/2.

This issue does NOT affect hex.pm the service. Only self-hosted deployments using the Local Storage backend are affected.

This issue affects hexpm/hexpm: from 931ee0ed46fa89218e0400a4f6e6d15f96406050 before 5d2ccd2f14f45a63225a73fb5b1c937baf36fdc0.

Workarounds

Avoid the local file store backend in any exposed environment. Restrict network access to the registry when using the local backend. Production deployments should use object storage (e.g., S3-compatible backends) instead of the local filesystem store.

Configurations

Only self-hosted hexpm deployments using the Hexpm.Store.Local storage backend are affected. The hex.pm service and deployments using S3-compatible object storage backends are not affected.

1 / 2
Source: OSV
First published (updated )

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203