SEVERITY NOT PROVIDED

HSEC-2026-0011: Superlinear encoding of numbers with large coefficients

Published 2026-11-03 · Updated 2026-11-03

Summary

The scientific package suffers from a superlinear time complexity flaw when encoding numbers with very large coefficients due to inefficient repeated division. Applications that decode untrusted numbers and re-encode them, such as API gateways and JSON proxies using aeson, are at risk of denial of service.

Who is affected

Applications using affected versions of the scientific package can experience severe performance degradation or denial of service when processing numbers with large coefficients. For example, a number with one million digits previously took about a minute to encode. The conditions required are processing untrusted input containing numbers with massive coefficients that trigger the quadratic digit-extraction code path.

Exploitability

The CVSS vector, base score, and EPSS are not provided in the vulnerability record. CISA Known Exploited Vulnerabilities status is no, meaning active exploitation in the wild is not documented.

Remediation

How to check your project

Automated analysis of the published advisory data, generated 2026-11-20. Not human-reviewed; verify against the official advisory. How this works.

Affected packages

EcosystemPackageAffected versionsFixed inUpgrade
Hackage scientific >= 0, < 0.3.9.0 0.3.9.0 -

FAQ

What causes the superlinear encoding vulnerability?

The flaw is caused by decimal digits being extracted through repeated division of the entire coefficient by 10 once per digit, resulting in quadratic time complexity relative to the number of digits.

Which libraries and tools are indirectly affected?

The Show instance, Data.Text.Lazy.Builder.Scientific, Data.ByteString.Builder.Scientific, and applications like aeson that rely on this code path are affected.

Should I upgrade to version 0.3.9.0?

No, you should upgrade directly to version 0.3.10.0 or later because version 0.3.9.0 introduced its own regression.

Original advisory description
# Superlinear encoding of numbers with large coefficients Encoding (pretty-printing) a `Scientific` number whose coefficient has many digits took time quadratic in the number of digits: the decimal digits were extracted by repeatedly dividing the whole coefficient by 10, once per digit. The `Show` instance, `Data.Text.Lazy.Builder.Scientific` and `Data.ByteString.Builder.Scientific` - which `aeson` uses to encode JSON numbers - all share this code path. A number with one million digits took about a minute to show, and about a tenth of a second after the fix. This is a denial-of-service risk for applications that decode numbers from an untrusted source and encode them again, e.g. JSON proxies, loggers or API gateways built on `aeson`. ## Resolution `scientific-0.3.9.0` reimplemented `normalize` and `toDecimalDigits` (the digit-extraction primitive) to be practically linear in the coefficient size. Note that `scientific-0.3.9.0` introduced a regression of its own; see HSEC-2026-0012. Upgrade directly to `scientific-0.3.10.0` or later, which fixes both issues. ## Credits Reported by Andrzej Rybczak (@arybczak); fixed by Oleg Grenrus (@phadej).

References

Source records: HSEC-2026-0011 (OSV.dev).