Axios versions 1.0.0 through 1.20.0 contain an event-loop starvation condition in the Node.js HTTP adapter’s bandwidth-limiting transform. When a positive upload or download maxRate below 2 bytes per second is configured, processing a source chunk of at least 101 bytes can repeatedly schedule the same unconsumed chunk through process.nextTick().
For downloads, a malicious server controlling the response body can trigger process-wide denial of service. Uploads are also affected when an application accepts attacker-influenced data and forwards it through Axios with the affected rate configuration.
Successful exploitation prevents the Node.js process from servicing timers, cancellation callbacks, signal handlers, unrelated requests, and other event-loop work. Recovery requires externally terminating or restarting the affected process.
The issue has no identified confidentiality or integrity impact. Exposure is limited to runtime use of the Node.js HTTP adapter with a positive maxRate below 2 B/s. Such rates are unusual, reducing practical likelihood.
Browser adapters, the fetch adapter, requests without rate limiting, and rates of at least 2 B/s are not affected by this condition.
Affected Functionality
Affected configuration forms include:
maxRate: [1, downloadRate]
maxRate: [uploadRate, 1]
Any other positive component below 2
The vulnerable paths are:
lib/helpers/AxiosTransformStream.js
For download throttling in versions before 1.7.3, onDownloadProgress must also be configured. From 1.7.3 onward, a positive download rate installs the transform without a progress callback.
With the default 500 ms accounting window, the allowed bytes per window are calculated as maxRate / 2. A rate of 1 B/s therefore produces a fractional threshold of 0.5.
When a 101-byte chunk is split, Buffer.subarray() converts that fractional boundary to zero:
The remainder is the unchanged 101-byte buffer.
No bytes are accounted as consumed.
The unchanged remainder is scheduled again with process.nextTick().
The -tick queue therefore remains continuously populated and prevents the event loop from reaching timers or I/O phases.
Proof of Concept of Attack
Run this from a v1.20.0 checkout with dependencies installed. The vulnerable request runs in a child process so the parent can terminate it safely.
request-started event loop starved
Changing the download rate from 1 to 2 allows the timer to run.
Configure every nonzero upload and download rate to at least 2 B/s, or use 0 to disable throttling:
Axios timeouts and cancellation cannot reliably recover the process after starvation begins because their callbacks also depend on the event loop.
Axios's Node.js HTTP adapter can enter a non-terminating process.nextTick loop when download throttling is configured with a positive maxRate below 2 bytes per second. Once an attacker-controlled response supplies a chunk larger than 100 bytes, the affected process stops servicing timers, cancellation, signals handled by the event loop, and unrelated requests.
The HTTP adapter inserts AxiosTransformStream into the response pipeline when a download rate limit is configured. lib/helpers/AxiosTransformStream.js uses a 500 ms accounting window and computes the number of bytes allowed per window as:
With the default timeWindow of 500 ms and maxRate of 1 byte per second, bytesThreshold is 0.5 . When a response chunk is more than 100 bytes larger than this threshold, the transform splits it with Buffer.subarray() :
Buffer.subarray() converts the fractional boundary to integer zero. As a result:
_chunk.subarray(0, 0.5) produces an empty buffer.
_chunk.subarray(0.5) produces the original, unchanged buffer.
The empty prefix is pushed.
The unchanged remainder is scheduled again with process.nextTick .
The transform therefore never consumes any bytes. Because every iteration schedules another -tick callback, the -tick queue remains continuously populated and starves the rest of the Node.js event loop.
The public API reaches this path through maxRate: [uploadRate, downloadRate] ; maxRate: [0, 1] is sufficient. The rate is application-controlled. An attacker only needs to supply a response body from a destination the application is permitted to request.
lib/adapters/http.js , which constructs AxiosTransformStream for limited downloads.
lib/helpers/AxiosTransformStream.js , which calculates a fractional threshold and recursively reprocesses the unchanged chunk.
Run the following from the Axios repository root. It embeds the JavaScript through standard input and creates no PoC file:
Ensure Docker is running.
Change into the root of the Axios checkout at commit 84a9f3b or release 1.20.0.
Run the command in the POC script section.
Observe that request-started is printed.
Wait at least three seconds and observe that neither timer-fired , request-completed , nor request-rejected is printed.
From a second terminal, stop only the disposable PoC container with docker kill axios-rate-dos-poc . The first command then exits non-zero. Ordinary SIGTERM -based timeouts may not complete because Node services the signal through the starved event loop.
As a control, change the download rate from 1 to 2 . The 300 ms timer is then serviced normally because the per-window threshold is the integer value 1 .
A single malicious response can indefinitely starve a Node.js process that uses a positive download maxRate below 2 bytes per second. In a shared server process, this prevents unrelated HTTP handlers, timers, cancellation callbacks, and other asynchronous work from running. The result is process-wide denial of service until restart. A sub-2 B/s rate is unusual, which reduces likelihood, but the failure is deterministic and a 101-byte response is sufficient. No confidentiality or integrity impact was identified.
Reported by depthfirst (Pranjali Thakur - pranjali@depthfirst.com )
