CVE-2026-32686: Decimal Denial of Service Vulnerability

MODERATE
Advisory Identifier: GHSA-rhv4-8758-jx7v
CWE-400
Published
Advisory Summary

CVE-2026-32686 is a MODERATE denial of service vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Decimal libraries in the Hex ecosystem. The issue involves unbounded exponent in `decimal.new` enables unauthenticated dos. Remediation is available by upgrading affected packages to version 3.0.0.

CVE-2026-32686 at a Glance

CVE Identifier CVE-2026-32686
GHSA Identifier GHSA-rhv4-8758-jx7v
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Decimal
Package Ecosystem Hex
Published Date
Last Updated

How to Fix CVE-2026-32686

To remediate this vulnerability, upgrade all affected Decimal dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

decimal fixed: 3.0.0
Upgrade decimal to 3.0.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for decimal

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-32686, inspect your project dependencies for Decimal:

inspect dependencies for decimal

Analyze the terminal output to locate any version of Decimal in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.0.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In Decimal, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Summary `decimal` doesn't bound the exponent on parsed input, so something like `"1e10000000"` is parsed fine but then explodes the memory to more than 7GB if you run e.g. `Decimal.add(Decimal.parse("1e10000000"), 1)` because for positive `exp`, the function tail-recurses with `coef * 10` and `exp - 1` per iteration, growing the bignum coefficient by one digit each step. In the worst case, one request is enough to OOM the BEAM. ### Details `Decimal.new/parse/cast` happily store huge exponents. After that, a bunch of core paths allocate proportional to `exp`: - `add/sub/div` go through `add_align`, which calls `pow10(exp1 - exp2)` and builds a giant bignum (lib/decimal.ex:1734-1738, 1827). - `to_string/2` with `:normal` (also `:xsd` and the `String.Chars` impl) does `:lists.duplicate(exp, ?0)` (lib/decimal.ex:1506, 1513). - `to_integer/1` recurses `coef * 10`, `exp - 1` once per unit of `exp` (lib/decimal.ex:1603-1605). - `round/3` does the same `:lists.duplicate` trick on the exp difference (lib/decimal.ex:1850, 1874). - `compare/3` with a threshold argument loops back into `add`/`sub`, so it's vulnerable too (lib/decimal.ex:331-332). ### PoC Any of these will hang or OOM the BEAM: ```elixir Decimal.add(Decimal.new("1"), Decimal.new("1e1000000000")) Decimal.to_string(Decimal.new("1e1000000000"), :normal) Decimal.to_integer(Decimal.new("1e1000000000")) Decimal.round(Decimal.new("1e1000000000")) ``` ### Impact Unauthenticated remote DoS. Anything that takes a user-supplied decimal (JSON, form field, Ecto `:decimal` field — basically everywhere) and then does arithmetic, rounding, `to_integer`, or `to_string` on it is exposed. One request can kill the node with a Out-of-Memory exception. ### Note on the security fixes done in version 2.4.0 While `2.4.0` has the changes to mitigate this issue it's not considered as a patched version because it doesn't have them enabled by default.

CVE-2026-32686 Affected Decimal Versions

1 component(s)
Fixed Versions:
3.0.0
Product / Package Ecosystem Affected Versions Fixed Version
decimal
Hex
≥ 0.1.0
< 3.0.0
3.0.0

References

Frequently Asked Questions

What is CVE-2026-32686?
CVE-2026-32686 is a security vulnerability in Decimal involving Unbounded exponent in `Decimal.new` enables unauthenticated DoS under CWE-400: Uncontrolled Resource Consumption.
Which Decimal versions are affected?
Affected versions include releases prior to 3.0.0 across affected packages: decimal.
What version fixes CVE-2026-32686?
Upgrading to 3.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is decimal affected?
Yes, decimal is affected in releases prior to 3.0.0. Upgrade your dependency to 3.0.0 or later.
What CWE is associated with CVE-2026-32686?
CVE-2026-32686 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check Hex dependencies for CVE-2026-32686?
Run the dependency tree command: 'inspect dependencies for decimal'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-rhv4-8758-jx7v",
  "modified" : "2026-08-05T12:40:51Z",
  "published" : "2026-05-12T15:09:20Z",
  "aliases" : [ "CVE-2026-32686" ],
  "summary" : "Decimal: Unbounded exponent in `Decimal.new` enables unauthenticated DoS",
  "details" : "Summary\n`decimal` doesn't bound the exponent on parsed input, so something like `\"1e10000000\"` is parsed fine but then explodes the memory to more than 7GB if you run e.g. `Decimal.add(Decimal.parse(\"1e10000000\"), 1)` because for positive `exp`, the function tail-recurses with `coef * 10` and `exp - 1` per iteration, growing the bignum coefficient by one digit each step. In the worst case, one request is enough to OOM the BEAM.\n\n### Details\n`Decimal.new/parse/cast` happily store huge exponents. After that, a bunch of core paths allocate proportional to `exp`:\n- `add/sub/div` go through `add_align`, which calls `pow10(exp1 - exp2)` and builds a giant bignum (lib/decimal.ex:1734-1738, 1827).\n- `to_string/2` with `:normal` (also `:xsd` and the `String.Chars` impl) does `:lists.duplicate(exp, ?0)` (lib/decimal.ex:1506, 1513).\n- `to_integer/1` recurses `coef * 10`, `exp - 1` once per unit of `exp` (lib/decimal.ex:1603-1605).\n- `round/3` does the same `:lists.duplicate` trick on the exp difference (lib/decimal.ex:1850, 1874).\n- `compare/3` with a threshold argument loops back into `add`/`sub`, so it's vulnerable too (lib/decimal.ex:331-332).\n\n### PoC\nAny of these will hang or OOM the BEAM:\n```elixir\nDecimal.add(Decimal.new(\"1\"), Decimal.new(\"1e1000000000\"))\nDecimal.to_string(Decimal.new(\"1e1000000000\"), :normal)\nDecimal.to_integer(Decimal.new(\"1e1000000000\"))\nDecimal.round(Decimal.new(\"1e1000000000\"))\n```\n\n### Impact\nUnauthenticated remote DoS. Anything that takes a user-supplied decimal (JSON, form field, Ecto `:decimal` field — basically everywhere) and then does arithmetic, rounding, `to_integer`, or `to_string` on it is exposed. One request can kill the node with a Out-of-Memory exception.\n\n### Note on the security fixes done in version 2.4.0\nWhile `2.4.0` has the changes to mitigate this issue it's not considered as a patched version because it doesn't have them enabled by default.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Hex",
      "name" : "decimal"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.1.0"
      }, {
        "fixed" : "3.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ericmj/decimal/security/advisories/GHSA-rhv4-8758-jx7v"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-32686"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ericmj/decimal/commit/6a523f3a73b8c9974540e21c7aa88f1258bb35ae"
  }, {
    "type" : "WEB",
    "url" : "https://cna.erlef.org/cves/CVE-2026-32686.html"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ericmj/decimal"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ericmj/decimal/releases/tag/v2.4.0"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ericmj/decimal/releases/tag/v3.0.0"
  }, {
    "type" : "WEB",
    "url" : "https://osv.dev/vulnerability/EEF-CVE-2026-32686"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-400" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-05-12T15:09:20Z",
    "nvd_published_at" : "2026-05-07T15:16:05Z"
  }
}