Skip to main content
Vulnerability Database/CVE-2026-97058

CVE-2026-97058: sprintf-js DOS Vulnerability

CVE-2026-97058 is a denial of service vulnerability in sprintf-js that allows attackers to crash applications by injecting malicious format strings. This post explains its impact, affected versions, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-97058 Overview

CVE-2026-97058 affects the sprintf-js JavaScript library through version 1.1.3. The library passes unbounded precision specifiers directly to the ECMAScript toFixed, toExponential, and toPrecision methods without validating input ranges. An attacker who controls a format string can supply a precision value exceeding ECMAScript limits, triggering an uncaught RangeError exception that aborts the calling operation. The flaw is classified under [CWE-1284: Improper Validation of Specified Quantity in Input] and enables denial-of-service conditions with a minimal payload.

Critical Impact

Attacker-controlled format strings can crash Node.js request handlers or browser components that invoke sprintf-js, degrading availability of applications that depend on the library.

Affected Products

  • sprintf-js npm package versions through 1.1.3
  • Node.js applications bundling vulnerable sprintf-js as a direct or transitive dependency
  • Browser-based JavaScript applications that pass untrusted input to sprintf-js format strings

Discovery Timeline

  • 2026-09-24 - CVE-2026-97058 published to the National Vulnerability Database (NVD)
  • 2026-09-24 - NVD record last modified

Technical Details for CVE-2026-97058

Vulnerability Analysis

sprintf-js implements C-style string formatting for JavaScript. When a format token includes a precision specifier (for example %.5f), the library forwards the parsed precision value to the corresponding numeric conversion method on the Number prototype. ECMAScript restricts the precision argument of Number.prototype.toFixed, toExponential, and toPrecision to a bounded integer range. Values outside this range cause the runtime to throw a RangeError.

Because sprintf-js performs no range check before invoking these methods, a format string containing an oversized precision token propagates the exception to the caller. If the caller does not wrap the sprintf invocation in a try/catch block, the exception bubbles up and can terminate the active request, event handler, or worker. For server-side Node.js code paths that process attacker-supplied format strings, this behavior yields a reliable denial-of-service primitive. See the VulnCheck Denial of Service Advisory for additional analysis.

Root Cause

The parser accepts arbitrary numeric precision tokens from the format string without clamping or validation. The formatter then passes the raw value into methods whose specification mandates a bounded range, producing an unhandled runtime exception. Relevant source lines are referenced in the sprintf.js source code.

Attack Vector

Exploitation requires the attacker to control, in whole or in part, the format string argument passed to sprintf or vsprintf. Common exposure patterns include logging frameworks, templating helpers, and API handlers that interpolate user-supplied data into format strings. The attack is network-reachable, requires no authentication, and no user interaction. See the GitHub sprintf.js Issue Tracker for the public report.

Detection Methods for CVE-2026-97058

Indicators of Compromise

  • Unhandled RangeError exceptions originating from toFixed, toExponential, or toPrecision within sprintf-js stack frames
  • Repeated request-handler crashes correlated with format tokens containing unusually large precision digits (for example %.999999f)
  • Elevated Node.js process restart counts or worker thread terminations following crafted HTTP requests

Detection Strategies

  • Enumerate direct and transitive dependencies with npm ls sprintf-js or yarn why sprintf-js across all projects
  • Instrument application logs to capture stack traces for RangeError events and alert on sprintf-js frames
  • Add runtime input validation that rejects format strings containing precision specifiers above a safe threshold

Monitoring Recommendations

  • Monitor web application firewall telemetry for request bodies and query parameters containing format tokens with large precision digits
  • Track Node.js process uptime and crash metrics to identify DoS patterns against vulnerable services
  • Correlate exception telemetry from Application Performance Monitoring (APM) tools with inbound request payloads

How to Mitigate CVE-2026-97058

Immediate Actions Required

  • Inventory applications that depend on sprintf-js through 1.1.3, including transitive dependencies
  • Audit code paths that pass user-controlled input into sprintf, vsprintf, or compatible formatting helpers
  • Wrap existing sprintf-js invocations in try/catch blocks until a patched release is adopted

Patch Information

At the time of publication, no fixed version is identified in the NVD record. Monitor the sprintf.js GitHub repository and the referenced issue tracker for a patched release. Update dependency manifests to the fixed version once published and rebuild downstream artifacts.

Workarounds

  • Never pass untrusted input as the format string argument; treat user data as formatting values only
  • Pre-validate format strings with a regular expression that rejects precision specifiers above a bounded integer (for example, 20)
  • Wrap sprintf calls in exception handlers to prevent RangeError propagation into request lifecycles
  • Consider substituting an alternative, actively maintained formatting library where feasible
bash
# Identify vulnerable sprintf-js installations across a workspace
npm ls sprintf-js

# Example defensive wrapper in Node.js
function safeSprintf(fmt, ...args) {
  if (/%\.[0-9]{3,}[feg]/i.test(fmt)) {
    throw new Error('Rejected format string with oversized precision');
  }
  try {
    return require('sprintf-js').sprintf(fmt, ...args);
  } catch (err) {
    if (err instanceof RangeError) return '';
    throw err;
  }
}

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.