Skip to main content

NCalc EUVDEUVD-2026-45304

| CVE-2026-55254 MEDIUM
Integer Overflow or Wraparound (CWE-190)
2026-06-18 https://github.com/ncalc/ncalc GHSA-3w5p-95mh-gq75
6.5
CVSS 3.1 · NVD
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Identify application accepting NCalc expressions
  2. Delivery
    Craft expression with oversized factorial operand (e.g., 9223372036854775807!)
  3. Exploit
    Submit via exposed API or input field
  4. Execution
    NCalc evaluator dispatches to unbounded CalculateFactorial loop
  5. Persist
    Integer overflow causes non-termination
  6. Impact
    CPU exhaustion degrades or halts service

Vulnerability Assessment

Weakness
CWE
ASVS 5.0
V15 - Secure Coding and Architecture Integer overflow checks
MITRE ATT&CK

1 technique across 1 tactic: Execution

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

The application must pass attacker-controlled or untrusted string input directly to NCalc's expression evaluator (e.g., Expression.Evaluate()) without pre-validating or sanitizing factorial operands. No authentication, session, or special privilege is required at the NCalc library level; exploitation is limited only by whatever access controls the consuming application imposes before calling the library. The factorial operator must be reachable - applications that restrict allowed operators or expression syntax through NCalc's built-in extension points are not exposed. Non-default configurations that sandbox or restrict the expression grammar would limit exploitability. The CVSS UI:R metric in the vendor vector implies some user interaction is required, though the advisory description does not identify a specific interaction step - this metric choice is unconfirmed and may reflect the need for an application user to trigger evaluation.

Impact

The vendor-assigned CVSS 4.8 (AV:A/AC:H/PR:N/UI:R) reflects a conservative scope: adjacent-network attack vector and user-interaction required imply constrained exploitation conditions, keeping the score in the medium range despite A:H. However, this assessment may understate real-world risk for applications that expose NCalc expression evaluation over the network to untrusted users - a common use case for formula engines, reporting tools, and configuration DSLs - where AV:N/AC:L/PR:N/UI:N would apply, potentially raising severity to High (7.5). The AC:H and UI:R metrics in the vendor vector are not clearly justified by the description or advisory; the triggering expressions are trivially simple (a single integer followed by '!'). No EPSS score was provided in the input data. No KEV listing exists, and no standalone POC repository is referenced; however, the GHSA advisory itself documents three working proof-of-concept expressions, making exploitation knowledge effectively public. Real-world impact is bounded by deployment context: applications that never pass untrusted input to NCalc are not exposed, while those that do - especially without request timeouts - face genuine service disruption risk.

Exploit ScenarioDerived

An attacker submits the expression '9223372036854775807!' through any application endpoint that passes user-controlled strings to NCalc for evaluation - for example, a reporting engine, spreadsheet formula API, or configuration DSL. NCalc's MathHelper.Factorial() dispatches the Int64.MaxValue operand to the unbounded calculation loop, which overflows and enters a non-terminating state, consuming 100% of a CPU core. If the application processes requests synchronously or with a large thread pool, repeated submissions can saturate all available threads and render the service unresponsive.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.2% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Jun 18, 2026

Denial-of-service via unbounded factorial evaluation affects NCalc (NCalc.Core and NCalcSync NuGet packages) prior to v6.1.1, allowing remote attackers to exhaust CPU resources or trigger non-terminating computation loops by submitting expressions with extremely large factorial operands such as 9223372036854775807! (Int64.MaxValue). The root cause is CWE-190 integer overflow in MathHelper.cs's factorial calculation logic, which previously lacked bounds validation, allowing operands well beyond any representable result to be passed directly to the computation loop. No public exploit or CISA KEV listing has been identified at time of analysis, though the triggering expressions are trivially constructable and documented in the advisory itself.

RemediationAI

Upgrade NCalc.Core and NCalcSync to v6.1.1 or later, which contains the bounds-validation fix from PR #575 (https://github.com/ncalc/ncalc/pull/575). The fix introduces a hard cap of 170 on factorial operands, rejecting larger values with ArgumentOutOfRangeException before any computation occurs. If immediate upgrade is not feasible, three compensating controls are documented in the advisory: first, restrict expression evaluation exclusively to trusted, internal sources - this fully eliminates the attack surface but requires application-level input provenance controls. Second, add an expression pre-validation layer that detects and rejects factorial tokens (e.g., regex matching on large numeric literals followed by '!') before passing expressions to NCalc; this adds latency and maintenance burden and may reject legitimate large-but-safe operands if thresholds are set conservatively. Third, wrap all NCalc evaluation calls in execution time limits or CancellationToken-based timeouts (e.g., Task.Run with a 1-5 second timeout); this bounds the DoS window but does not prevent resource consumption from concurrent attacks, and introduces complexity around partial-evaluation cleanup. None of the workarounds fully address the root cause - patching to v6.1.1 is the only complete fix.

Affected VersionsENISA

ncalc < 6.1.1

Affected Packages

nuget ncalc.core fix: 6.1.1
nuget ncalcsync fix: 6.1.1
euvd ncalc fix: 6.1.1

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 3 packages in nuget, euvd

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

NCalc is a .NET mathematical expression evaluation library distributed as NuGet packages (pkg:nuget/ncalc.core and pkg:nuget/ncalcsync). The vulnerability resides in NCalc.Core/Helpers/MathHelper.cs within the Factorial() dispatch method, which prior to v6.1.1 passed all numeric types (int, long, float, double, decimal, BigInteger) directly to CalculateFactorial<T>() without bounds checking. CWE-190 (Integer Overflow or Wraparound) applies because computing 9223372036854775807! (Int64.MaxValue) overflows the loop counter or intermediate accumulator, causing the evaluation to enter a non-terminating or runaway computation state rather than returning a bounded error. The fix in PR #575 introduces a MaxFactorialInput constant capped at 170 (the largest integer whose factorial fits in a double) and a ValidateFactorialInput<T>() gate that rejects negative values, NaN, infinity, and any operand exceeding 170 before the computation begins. Tests were added to assert ArgumentOutOfRangeException for all formerly dangerous inputs.

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

NVD PRIMARY 6.5 MEDIUM
AV:A/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
vuln.today AI 7.5 HIGH

Network vector and no-privilege access apply when NCalc evaluates untrusted input via an API; only availability is impacted - no confidentiality or integrity effect.

3.1 AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
4.0 AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N

Primary rating from NVD.

CVSS VectorNVD

Attack Vector
Adjacent
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High

Lifecycle Timeline

1
CVSS changed
Aug 18, 2026 - 15:52 NVD
4.8 (MEDIUM) 6.5 (MEDIUM)

DescriptionNVD

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:

text
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.

Threat Intelligence Overview

EPSS Score
0.2%
Top 91% exploitable
Threat Intel
1
1 source
Data Quality
5 sources
Confidence: Medium

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.2%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Controlled
Automatable· derived
No
Human Impact· derived
Medium

Priority Score

32
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +32
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Integer overflow occurs when an arithmetic operation produces a result that exceeds the maximum value a given integer type can store.

Denial of Service attacks render applications or systems unavailable by overwhelming resources or triggering failure conditions.

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy