4.8medium
NCalc: Denial of Service via Unbounded and Non-Terminating Factorial Evaluation
- Severity
- 4.8medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.19% (higher than 9% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-3w5p-95mh-gq75
Description
NCalc is a fast, lightweight expression evaluator for .NET. Prior to 6.1.1, the factorial operator implementation in src/NCalc.Core/Helpers/MathHelper.cs permits specially crafted expressions with extremely large factorial operands, causing excessive CPU consumption or a non-terminating loop due to integer overflow in the factorial calculation logic when applications evaluate untrusted expressions. This issue is fixed in version 6.1.1.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| ncalc ncalc | < 6.1.1, before 6.1.1 | CVE List, NVD |
| NCalc.Core (NuGet) | before 6.1.1 | GitHub Advisory Database |
| NCalcSync (NuGet) | before 6.1.1 | GitHub Advisory Database |
All scores
| GitHub_M | 4.8medium CVSS:3.1 | CVSS:3.1/AV:A/AC:H/PR:N/UI:R/S:U/C:N/I:N/A:H |
| GitHub | 4.8medium CVSS:3.1 | CVSS:3.1/AV:A/AC:H/PR:N/UI:R/S:U/C:N/I:N/A:H |
| NVD | 6.5medium CVSS:3.1 | CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
Classification
What each source says
CVE List
NCalc is a fast, lightweight expression evaluator for .NET. Prior to 6.1.1, the factorial operator implementation in src/NCalc.Core/Helpers/MathHelper.cs permits specially crafted expressions with extremely large factorial operands, causing excessive CPU consumption or a non-terminating loop due to integer overflow in the factorial calculation logic when applications evaluate untrusted expressions. This issue is fixed in version 6.1.1.
GitHub Advisory Database
Impact
A denial-of-service (DoS) vulnerability exists in the factorial operator implementation of NCalc. Specially crafted expressions containing extremely large factorial operands can trigger excessive CPU consumption or cause evaluation to enter a non-terminating loop due to integer overflow in the factorial calculation logic.
Applications that evaluate untrusted expressions using affected versions of NCalc may be vulnerable to resource exhaustion, potentially resulting in service disruption or application unresponsiveness.
This issue can be triggered with expressions such as:
99999999999999!
9223372036854775807!
1.5e16!
Patches
The vulnerability has been fixed by adding bounds validation for factorial operands and rejecting unsupported values before evaluation.
Users should upgrade to the first release containing the fix from pull request #575. (v6.1.1+)
Workarounds
If upgrading is not immediately possible:
- Do not evaluate expressions originating from untrusted users.
- Validate or sanitize expressions before evaluation and reject factorial operations on large values.
- Implement execution time limits, request timeouts, or cancellation mechanisms around expression evaluation.
These mitigations may reduce exposure but do not fully address the underlying vulnerability.
References
| https://github.com/ncalc/ncalc/security/advisories/GHSA-3w5p-95mh-gq75 | patch, vendor-advisory, web | |
| https://github.com/ncalc/ncalc/pull/575 | issue-tracking, patch, web | |
| https://github.com/ncalc/ncalc/commit/eeb6155ee1899b1fdf2cda3da35a4f0ca93ffd6a | patch | |
| https://github.com/ncalc/ncalc/releases/tag/v6.1.1 | product, release-notes | |
| https://github.com/ncalc/ncalc | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-55254 changed 2026-07-20 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-3w5p-95mh-gq75 changed 2026-06-18 | CC-BY-4.0 |
| NVD | CVE-2026-55254 changed 2026-08-18 | Public domain |