HSEC-2026-0012

Vulnerability from osv_haskell – Published: 2026-11-03 22:32 – Updated: 2026-11-03 22:32 – Source website
VLAI
Summary
Out-of-bounds read in Eq and Ord on numbers with extreme exponents
Details

Out-of-bounds read in Eq and Ord on numbers with extreme exponents

scientific-0.3.9.0 reimplemented Eq and Ord without normalising their arguments. The new implementation short-circuits on integerLog10' c + e computed in Int, which overflows when the base-10 exponent is close to maxBound :: Int. The overflowed comparison then falls through to magnitude (e1 - e2), where the exponent difference overflows to a negative Int as well. magnitude indexed its cached power-of-ten array without a bounds check, so the negative index performed an out-of-bounds read and the process died with SIGSEGV.

With scientific-0.3.9.0 (GHC 9.10.3, x86_64-linux), as reported in basvandijk/scientific#120:

import Data.Scientific

main :: IO ()
main = print (scientific 10 maxBound == scientific 1 minBound)
$ ./repro; echo "exit=$?"
exit=139

The issue was discovered when Stackage nightly test suites (genvalidity-hspec-aeson, genvalidity-sydtest-aeson) started segfaulting after upgrading to scientific-0.3.9.0: their property tests round-trip aeson Values, which produces Scientifics with extreme exponents.

Versions before 0.3.9.0 did not crash, but Eq/Ord returned invalid results there instead (the normalisation-based implementation overflows the exponent, reporting scientific 10 maxBound == scientific 1 minBound as True). The same unchecked read was also reachable through (+) and (-) on older versions, guarded only by the documented warning about the potential 10^e blowup — reading outside the cache is not.

Resolution

scientific-0.3.10.0 computes the logarithms using Integer, fixing both the crash and the invalid comparison results, and bounds-checks magnitude, so a negative exponent now raises an error instead of reading out of bounds. All entry points (Eq, Ord, (+), (-)) are covered; upgrade to scientific-0.3.10.0 or later.

Note that printing values with exponents close to maxBound :: Int remains unreliable due to the inherent Int exponent overflow in normalize; this limitation is documented upstream and postponed to the next major release.

Credits

Reported by Tom Sydney Kerckhove (@NorfairKing); fixed by Oleg Grenrus (@phadej).


{
  "affected": [
    {
      "database_specific": {
        "human_link": "https://github.com/haskell/security-advisories/tree/main/advisories/published/2026/HSEC-2026-0012.md",
        "osv": "https://raw.githubusercontent.com/haskell/security-advisories/refs/heads/generated/osv-export/2026/HSEC-2026-0012.json"
      },
      "package": {
        "ecosystem": "Hackage",
        "name": "scientific"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0.3.9.0"
            },
            {
              "fixed": "0.3.10.0"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ],
      "severity": [
        {
          "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:H",
          "type": "CVSS_V3"
        }
      ]
    }
  ],
  "database_specific": {
    "home": "https://github.com/haskell/security-advisories",
    "osvs": "https://raw.githubusercontent.com/haskell/security-advisories/refs/heads/generated/osv-export",
    "repository": "https://github.com/haskell/security-advisories"
  },
  "details": "# Out-of-bounds read in Eq and Ord on numbers with extreme exponents\n\n`scientific-0.3.9.0` reimplemented `Eq` and `Ord` without normalising their\narguments. The new implementation short-circuits on\n`integerLog10\u0027 c + e` computed in `Int`, which overflows when the base-10\nexponent is close to `maxBound :: Int`. The overflowed comparison then falls\nthrough to `magnitude (e1 - e2)`, where the exponent difference overflows to a\nnegative `Int` as well. `magnitude` indexed its cached power-of-ten array\nwithout a bounds check, so the negative index performed an out-of-bounds read\nand the process died with `SIGSEGV`.\n\nWith `scientific-0.3.9.0` (GHC 9.10.3, x86_64-linux), as reported in\n[basvandijk/scientific#120](https://github.com/basvandijk/scientific/issues/120):\n\n```haskell\nimport Data.Scientific\n\nmain :: IO ()\nmain = print (scientific 10 maxBound == scientific 1 minBound)\n```\n\n```\n$ ./repro; echo \"exit=$?\"\nexit=139\n```\n\nThe issue was discovered when Stackage nightly test suites\n(`genvalidity-hspec-aeson`, `genvalidity-sydtest-aeson`) started segfaulting\nafter upgrading to `scientific-0.3.9.0`: their property tests round-trip\n`aeson` `Value`s, which produces `Scientific`s with extreme exponents.\n\nVersions before `0.3.9.0` did not crash, but `Eq`/`Ord` returned invalid\nresults there instead (the normalisation-based implementation overflows the\nexponent, reporting `scientific 10 maxBound == scientific 1 minBound` as\n`True`). The same unchecked read was also reachable through `(+)` and `(-)` on\nolder versions, guarded only by the documented warning about the potential\n`10^e` blowup \u2014 reading outside the cache is not.\n\n## Resolution\n\n`scientific-0.3.10.0` computes the logarithms using `Integer`, fixing both the\ncrash and the invalid comparison results, and bounds-checks `magnitude`, so a\nnegative exponent now raises an error instead of reading out of bounds. All\nentry points (`Eq`, `Ord`, `(+)`, `(-)`) are covered; upgrade to\n`scientific-0.3.10.0` or later.\n\nNote that printing values with exponents close to `maxBound :: Int` remains\nunreliable due to the inherent `Int` exponent overflow in `normalize`; this\nlimitation is documented upstream and postponed to the next major release.\n\n## Credits\n\nReported by Tom Sydney Kerckhove (@NorfairKing); fixed by Oleg Grenrus\n(@phadej).\n",
  "id": "HSEC-2026-0012",
  "modified": "2026-11-03T22:32:58Z",
  "published": "2026-11-03T22:32:58Z",
  "references": [
    {
      "type": "REPORT",
      "url": "https://github.com/basvandijk/scientific/issues/120"
    },
    {
      "type": "REPORT",
      "url": "https://github.com/NorfairKing/validity/issues/121"
    },
    {
      "type": "FIX",
      "url": "https://github.com/basvandijk/scientific/pull/121"
    },
    {
      "type": "DISCUSSION",
      "url": "https://www.reddit.com/r/haskell/comments/1xbj59g/dont_use_scientific_for_calculations_it_can/"
    }
  ],
  "related": [
    "HSEC-2026-0011"
  ],
  "schema_version": "1.5.0",
  "summary": "Out-of-bounds read in Eq and Ord on numbers with extreme exponents"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline

Sightings and recorded dates, grouped by day · UTC

JSON
How durations are calculated

Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation.

Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.

Events included in the timeline

Loading timeline…


    Loading…

    Loading…

    Loading…

    Related by attack behaviour

    Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.