# GHSA-7C4R-CGF9-9JMQ: hex\_core decompresses registry and Erlang term API responses without size limits

- Database: GitHub
- Severity: CVSS 2.1 (Low)
- Published: 2026-10-12
- Modified: 2026-10-12

## Tracked as

- [CVE-2026-105274](https://cve.now/CVE-2026-105274.md): hex\_core decompresses registry and Erlang term API responses without size limits

## Affected versions

- hex\_core (Hex): fixed in 0.20.0

## Description

## Summary

Improper Handling of Highly Compressed Data (Data Amplification) vulnerability in hexpm hex_core allows an untrusted repository mirror, or a server answering hex_core's API requests, to exhaust the memory of the Erlang VM running hex_core. The same code is vendored in Hex (`mix_hex_repo`, `mix_hex_api`) and rebar3 (`r3_hex_repo`, `r3_hex_api`).

`hex_repo:get_names/1`, `hex_repo:get_versions/1`, `hex_repo:get_package/2` and `hex_repo:get_policy/2` decompress the registry response with `zlib:gunzip/1` and decode the signed envelope before verifying its signature. A mirror doesn't have the repository's private key, but it chooses the compressed bytes, so a small response decompresses into an envelope of any size before the signature check rejects it.

`hex_api` decodes responses with the `application/vnd.hex+erlang` content type through `hex_safe_binary_to_term:safe_binary_to_term/1`, which calls `binary_to_term(Binary, [safe])`. The `safe` option prevents atom creation, but it accepts compressed terms and doesn't limit the size of the decoded term, and the check that rejects functions and ports runs after the term has been built. The fix for CVE-2026-21619 added the `safe` option and that check without bounding the decoded size.

## Impact

A mirror can make every registry fetch allocate memory far beyond the size of its response: in a test against Hex main 851b938, which vendors this code, a 65 KB registry response decompressed into a 64 MiB envelope before the signature check failed. The API server, or an attacker who can alter its responses, can do the same with API responses: 8 KB of compressed Erlang term format decoded into a list of 4.2 million elements. Large enough responses stop the Erlang VM, which fails the build tool command or the program using hex_core. No package code has to run.

## Configurations

Registry decoding is affected when a repository's URL points at a mirror or another server the user doesn't trust with the availability of their builds, for example Hex's `HEX_MIRROR_URL` or `mirror_url` and rebar3's `HEX_MIRROR_URL`. API decoding is affected when the API URL points at such a server or an attacker can alter API responses. Requests to repo.hex.pm and hex.pm over verified HTTPS aren't affected.

## Patches

Fixed in hex_core 0.20.0:

* https://github.com/hexpm/hex_core/commit/ebe25d110717f6a3addba5232cd4a7dc1c76b628

Fixed in Hex 2.5.2, which vendors hex_core 0.20.0:

* https://github.com/hexpm/hex/commit/d8b60eee97abb119d525306f048969a217d793a5

## Workarounds

Point repository URLs at repo.hex.pm or a mirror you operate, and the API URL at hex.pm.

## References

* Introducing commit (registry decoding): https://github.com/hexpm/hex_core/commit/fbb6d9de472e5edb8d6fb6b32a91cb266137892e
* Introducing commit (API decoding): https://github.com/hexpm/hex_core/commit/eb327f8edfe45507351e38cc0805aa12fa647f0b
* Related advisory CVE-2026-21619: https://github.com/hexpm/hex_core/security/advisories/GHSA-hx9w-f2w9-9g96

## References

- https://github.com/hexpm/hex_core/security/advisories/GHSA-7c4r-cgf9-9jmq

Page: https://cve.now/GHSA-7C4R-CGF9-9JMQ

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
