# HSEC-2023-0007: readFloat: memory exhaustion with large exponent

> Attackers can cause denial of service by providing input with large exponents to Numeric.readFloat, exhausting memory and CPU resources.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 14 Nov 2025

## What is HSEC-2023-0007?

HSEC-2023-0007 is a denial of service vulnerability in base, published on 14 Nov 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

# `readFloat`: memory exhaustion with large exponent

`Numeric.readFloat` takes time and memory linear in the size of the
number _denoted_ by the input string.  In particular, processing a
number expressed in scientific notation with a very large exponent
could cause a denial of service.  The slowdown is observable on a
modern machine running GHC 9.4.4:

```
ghci> import qualified Numeric
ghci> Numeric.readFloat "1e1000000"    -- near instantaneous
[(Infinity,"")]
ghci> Numeric.readFloat "1e10000000"   -- perceptible pause
[(Infinity,"")]
ghci> Numeric.readFloat "1e100000000"  -- ~ 3 seconds
[(Infinity,"")]
ghci> Numeric.readFloat "1e1000000000" -- ~ 35 seconds
[(Infinity,"")]
```

## In *base*

`Numeric.readFloat` is defined for all `RealFrac a => a`:

```haskell
readFloat :: RealFrac a => ReadS a
```

The `RealFrac` type class does not express any bounds on the size of
values representable in the types for which instances exist, so
bounds checking is not possible (in this *generic* function).
`readFloat` uses to `Text.Read.Lex.numberToRational` which, among
other things, calculates `10 ^ exponent`, which seems to take linear
time and memory.

**Mitigation:** use `read`.  The `Read` instances for `Float` and
`Double` perform bounds checks on the exponent, via
`Text.Read.Lex.numberToRangedRational`.

## In *toml-reader*

The issue was detected in *toml-reader* version 0.1.0.0, and
mitigated in version 0.2.0.0 by immediately returning `Infinity`
when the exponent is large enough that there's no reason to process
it.

## Which versions are affected by HSEC-2023-0007?

2 open source packages ship an affected version, including base and toml-reader.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `base` | Hackage | From 3.0.3.1 | None |
| `toml-reader` | Hackage | From 0.1.0.0 | 0.2.0.0 |

## How do I fix HSEC-2023-0007?

Upgrade to a fixed version.

## Is HSEC-2023-0007 being exploited?

There is no known exploitation of HSEC-2023-0007 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for HSEC-2023-0007 and fix it if it is affected.

What it is: HSEC-2023-0007 is a denial of service vulnerability in base, published on 14 Nov 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of HSEC-2023-0007 in the wild and no public exploit code.

Affected packages and fixed versions:
- base (Hackage): affected from 3.0.3.1; no fix listed
- toml-reader (Hackage): affected from 0.1.0.0; fixed in 0.2.0.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/HSEC-2023-0007/ (Markdown: https://insights.sbomify.com/HSEC-2023-0007/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/HSEC-2023-0007

---
From sbomify Insights: https://insights.sbomify.com/HSEC-2023-0007/
Summaries are generated and may contain mistakes; the official description above is the record.
