Unrestricted Resource Consumption

Unrestricted Resource Consumption in Node.js (Express) [GHSA-c73c-x77g-854r]

[Updated May 2026] Updated GHSA-c73c-x77g-854r

Overview

Unrestricted Resource Consumption vulnerabilities occur when a Node.js (Express) application accepts input or performs work without proper safeguards, allowing memory, CPU, or I/O to be consumed excessively. In production, this can cause service slowdowns, outages, higher hosting costs, or degraded performance for legitimate users. Attackers can exploit unbounded computations, large payloads, or streaming patterns to exhaust resources quickly. This guide describes how these issues manifest in Node.js/Express and how to remediate them. In Express apps, common patterns include accepting large JSON bodies without a size limit, building large in-memory structures from user input, or streaming data without backpressure. If the event loop is tied up with CPU-heavy tasks or memory usage grows unchecked, concurrent requests suffer and latency spikes occur. Frameworks and middleware can inadvertently amplify risk if not configured securely. Remediation combines input validation, resource caps, and architectural safeguards. Enable strict body size limits, bound inputs that influence allocations, apply rate limiting, offload heavy work to queues, and stream large outputs instead of buffering. Monitor memory and provide meaningful error handling and alerts to detect anomalies early. Note: No CVE IDs are provided in this guide; focus is on general, repeatable mitigation patterns for Unrestricted Resource Consumption in Node.js (Express).

Code Fix Example

Node.js (Express) API Security Remediation
const express = require('express');
const app = express();

// Vulnerable endpoint (no limits, may allocate large memory)
app.post('/compute-vuln', express.json(), (req, res) => {
  const n = parseInt(req.body?.n, 10) || 0;
  const data = new Array(n).fill(0);
  for (let i = 0; i < n; i++) data[i] = i;
  res.json({ sum: data.reduce((a,b)=>a+b, 0) });
});

// Fixed endpoint with limits and bounded work
app.post('/compute', express.json({ limit: '100kb' }), (req, res) => {
  const n = Math.max(0, Math.min(parseInt(req.body?.n, 10) || 0, 100000));
  let sum = 0;
  for (let i = 0; i < n; i++) sum += i;
  res.json({ sum });
});

app.listen(3000, () => console.log('Server listening on 3000'));

CVE References

Choose which optional cookies to allow. You can change this any time.