Skip to content
DoS Disclosed report Intermediate CVE-2024-22025

Denial of Service by resource exhaustion in fetch() brotli decoding

Node.js's fetch() function always decodes Brotli-compressed responses, so an attacker who controls a URL fetched by the application can send a small compressed response that expands hugely and exhausts memory. This could lead to process termination depending on the system configuration.

maple3142 Follow

Originally disclosed on HackerOne

Medium 6.5 View original
  • Triaged in 26 days
  • Fixed in 2 months
  • Disclosed after 3 months

Summary by the program

A vulnerability in Node.js has been identified, allowing for a Denial of Service (DoS) attack through resource exhaustion when using the fetch() function to retrieve content from an untrusted URL.

The vulnerability stems from the fact that the fetch() function in Node.js always decodes Brotli, making it possible for an attacker to cause resource exhaustion when fetching content from an untrusted URL.

An attacker controlling the URL passed into fetch() can exploit this vulnerability to exhaust memory, potentially leading to process termination, depending on the system configuration.

The original report as published on HackerOne, by maple3142. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 4 min read.

What the report shows

The target is Node.js, specifically the fetch() function, and the feature under scrutiny is how it handles content retrieved from a URL. The report is a short program summary rather than a long researcher narrative, so it describes the finding at a high level.

The core observation is that fetch() in Node.js always decodes Brotli. When the URL passed to fetch() is controlled by an attacker, that unconditional decoding becomes a lever for resource exhaustion. The program summarises the chain as follows:

  1. An application calls fetch() on a URL that an attacker can influence.
  2. The attacker serves content that is expensive to Brotli-decode.
  3. Node.js decodes that content regardless, consuming resources in the process.
  4. Depending on system configuration, the process can be terminated.

The report frames the result as a Denial of Service through memory exhaustion. It notes that the outcome depends on the system configuration, so termination is presented as a possibility rather than a certainty.

The platform records the report as medium severity with a CVSS score of 6.5, classified as Uncontrolled Resource Consumption, against the https://github.com/nodejs/node asset. It was disclosed on 2024-03-16. No bounty figure is given.

Root cause

The mistake the report points to is the unconditional Brotli decoding inside fetch(). A client that fetches from an untrusted URL cannot assume the response body is benign, yet the implementation always decodes Brotli.. Decoding is work proportional to the decompressed output, and a small compressed body can expand into a much larger buffer.

Impact

An attacker who controls the URL passed into fetch() can exhaust memory on the Node.js process. The report is careful here: the consequence is potential process termination, and whether that happens depends on the system configuration. The practical effect is memory exhaustion in the affected process. The report does not describe any confidentiality or integrity impact, and none should be inferred.

How this kind of bug works

Decompression is a multiplier. Formats such as Brotli, gzip and zstd encode repetitive data compactly, so a modest compressed payload can represent a very large decompressed one. A decoder that allocates output buffers based on the declared or implied decompressed size, without a ceiling, will happily allocate far more memory than the input suggests. This is the classic decompression bomb, and it belongs to the broader family of uncontrolled resource consumption.

The same pattern appears wherever a server or client processes attacker-supplied compressed data: HTTP response bodies, request bodies with Content-Encoding, archive uploads, WebSocket frames with compression negotiated, and cache or proxy layers that decompress before forwarding. The bug class also covers CPU exhaustion, where the cost is time rather than memory, and algorithmic complexity attacks where a crafted input drives superlinear work.

Defences are straightforward in principle. Cap the decompressed size and abort once the limit is crossed. Stream the decode rather than buffering the whole output. Make decoding opt-in for untrusted sources, or skip it when the caller has not asked for it. Apply timeouts and memory limits at the process level as a backstop, so a single request cannot take down the whole service.

How to test for it

Look for any code path where the application fetches or accepts content from a source the attacker can influence, and where compression is handled automatically. Client-side HTTP libraries that transparently decode responses are prime candidates, as are reverse proxies and API gateways that decompress before passing traffic on.

The method is to serve a response that is small on the wire but enormous once decoded, then observe the resource profile of the target. In words: point the application at a URL you control, respond with a body encoded using the compression scheme in question, and make the decompressed output far larger than any legitimate response. Watch memory and CPU on the target process, and watch for errors, restarts or dropped connections. A positive result is a measurable spike in memory or CPU that correlates with your request, ideally followed by a crash or a timeout that you can reproduce.

Common false positives matter here. A single slow response may reflect network latency rather than decoding cost. A memory spike may come from your own test harness rather than the target. Rate limits or upstream caching can mask the effect entirely, and a target that already caps response size will look immune even if the underlying decoder is unbounded. Confirm by varying only the compression ratio while keeping the wire size constant, and by checking that the effect disappears when you serve the same content uncompressed.

How it is fixed

The standard fixes are to bound the decompressed size and stop decoding once the limit is reached, to stream the decode so memory use stays proportional to what is actually consumed, and to make automatic decoding configurable so callers can disable it for untrusted sources. Process-level memory limits and timeouts provide defence in depth. The report itself does not describe the fix that was applied.

Hunting notes

This bug class hides in the seams between components: a library that decodes by default, a proxy that decompresses to inspect traffic, a worker that parses uploaded archives. Recon signals include dependencies known for transparent decompression, endpoints that accept Content-Encoding on request bodies, file upload features that accept archives, and any feature that fetches a user-supplied URL, such as webhooks, link previews, importers and image proxies.

To get a report accepted, show a reproducible measurement rather than a theoretical claim. Record the wire size and the decompressed size, show the resource curve on the target, and demonstrate the user-visible consequence, whether that is a crash, a timeout or degraded service for other requests. Keep the payload minimal and the steps exact so the triager can repeat them.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 6 min read.

What happened, in plain words

Node.js is a program that lets developers run JavaScript outside a web browser, most often on a server. One of its built-in tools is fetch(), a function that goes out to a URL and brings back whatever is there, much like your browser does when you type an address. This report is about a weakness in how fetch() handles the content it brings back.

Websites often send their content squeezed down to save bandwidth, using a compression format called Brotli. Your browser unsqueezes it automatically so you see the normal page. Node.js's fetch() always decodes Brotli, without asking the developer first.

The problem is what happens when the URL is not trustworthy. If an attacker can influence which address an application fetches, the attacker can serve content that is expensive to Brotli-decode. Think of a small envelope that, when opened, releases a room full of packing foam. Node.js decodes the content regardless, consuming resources in the process. The program summary describes the chain like this:

  1. An application calls fetch() on a URL that an attacker can influence.
  2. The attacker serves content that is expensive to Brotli-decode.
  3. Node.js decodes that content regardless, consuming resources in the process.
  4. Depending on system configuration, the process can be terminated.

The result is a Denial of Service: the service stops being available to its real users. The report is careful to say that termination is a possibility, not a certainty, because it depends on how the system is configured. It describes no theft of data and no tampering with data, only the service being knocked out of action.

The platform records this as medium severity, with a CVSS score of 6.5, in the category Uncontrolled Resource Consumption, affecting the Node.js source code hosted at https://github.com/nodejs/node. It was disclosed on 2024-03-16. No bounty amount is given.

In general, how this kind of bug works

Compression is a multiplier. Formats like Brotli, gzip and zstd store repetitive data compactly, so a modest compressed payload can stand for a very large decompressed one. A decoder that allocates memory based on how big the decompressed result will be, with no ceiling, will happily use far more memory than the incoming file suggests. This is the classic decompression bomb, and it belongs to the wider family of uncontrolled resource consumption bugs.

The same pattern appears wherever a program processes compressed data supplied by an attacker: web response bodies, request bodies marked with Content-Encoding, uploaded archives, compressed WebSocket frames, and proxies or caches that decompress traffic before passing it on. The family also covers CPU exhaustion, where the cost is time rather than memory, and cases where a cleverly crafted input forces far more work than its size implies.

Defences are simple in principle. Put a cap on the decompressed size and stop once it is crossed. Decode as a stream rather than holding the whole output in memory. Make decoding opt-in for untrusted sources, or skip it when the caller did not ask for it. Add timeouts and memory limits at the process level as a backstop, so one request cannot take down the whole service.

How to test for it

Look for any code path where the application fetches or accepts content from a source the attacker can influence, and where compression is handled automatically. Client-side HTTP libraries that transparently decode responses are prime candidates, as are reverse proxies and API gateways that decompress before passing traffic on.

The method is to serve a response that is small on the wire but enormous once decoded, then watch the resource profile of the target. In words: point the application at a URL you control, respond with a body encoded using the compression scheme in question, and make the decompressed output far larger than any legitimate response. Watch memory and CPU on the target process, and watch for errors, restarts or dropped connections. A positive result is a measurable spike in memory or CPU that lines up with your request, ideally followed by a crash or a timeout you can reproduce.

False positives matter here. A single slow response may reflect network latency rather than decoding cost. A memory spike may come from your own test setup rather than the target. Rate limits or upstream caching can hide the effect entirely, and a target that already caps response size will look immune even if the underlying decoder is unbounded. Confirm by varying only the compression ratio while keeping the wire size constant, and by checking that the effect disappears when you serve the same content uncompressed.

How it is fixed

The standard fixes are to bound the decompressed size and stop decoding once the limit is reached, to stream the decode so memory use stays proportional to what is actually consumed, and to make automatic decoding configurable so callers can disable it for untrusted sources. Process-level memory limits and timeouts provide defence in depth. The report itself does not describe the fix that was applied.

Where to look while hunting

This bug class hides in the seams between components: a library that decodes by default, a proxy that decompresses to inspect traffic, a worker that parses uploaded archives. Useful signals include dependencies known for transparent decompression, endpoints that accept Content-Encoding on request bodies, file upload features that accept archives, and any feature that fetches a user-supplied URL, such as webhooks, link previews, importers and image proxies.

To get a report accepted, show a reproducible measurement rather than a theoretical claim. Record the wire size and the decompressed size, show the resource curve on the target, and demonstrate the user-visible consequence, whether that is a crash, a timeout or degraded service for other requests. Keep the payload minimal and the steps exact so the triager can repeat them.

Glossary

  • Node.js: a program that runs JavaScript outside a browser, commonly used to build servers.
  • fetch(): a function that requests a URL and returns the response content.
  • Brotli: a compression format that shrinks data for transfer and is expanded again on arrival.
  • Compression: encoding data in fewer bytes by exploiting repetition.
  • Decompression: turning compressed data back into its original, larger form.
  • Decompression bomb: a small compressed input that expands into a very large output.
  • Resource exhaustion: using up a limited resource such as memory or CPU until normal work cannot continue.
  • Denial of Service (DoS): making a service unavailable to its legitimate users.
  • Memory: the working space a running program uses to hold data.
  • CPU: the processor that performs a program's calculations; heavy decoding consumes its time.
  • Process: a running instance of a program on a computer.
  • URL: a web address identifying where content lives.
  • Untrusted URL: an address an attacker can choose or influence.
  • Content-Encoding: an HTTP header that tells the receiver how a body has been compressed.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • Response body: the actual content returned by a server, as opposed to its headers.
  • Streaming: processing data piece by piece as it arrives instead of holding it all at once.
  • Timeout: a limit on how long an operation may run before it is stopped.
  • CVSS: a standard scoring system for rating the severity of a vulnerability.
  • Uncontrolled Resource Consumption: the weakness category for bugs where input drives unbounded use of memory, CPU or similar.
  • False positive: a test result that looks like a finding but is caused by something else.
  • Triager: the person who reviews a submitted report and decides whether it is valid.

More from Node.js

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.