Denial of service via unbounded response buffering and synchronous decompression ("decompression bomb")
Description
makeCkanRequest fetches upstream responses into memory with no size limit and then decompresses them synchronously with no output-size limit. A server_url/endpoint_url (caller-controlled, or reached via a redirect from any portal) that returns an oversized or highly-compressed body forces the server to allocate an attacker-chosen amount of memory and to block its event loop inside a single synchronous gunzipSync/brotliDecompressSync/inflateSync call — crashing or stalling the server.
Affected code
src/utils/http.ts — Node branch:
const response = await axios.get(url, {
params,
timeout: 30000,
responseType: "arraybuffer", // entire body buffered in memory
maxRedirects: 5,
// no maxContentLength / maxBodyLength -> axios default is unlimited (-1)
...
});
decodedData = await decodePossiblyCompressed(response.data, response.headers);decodePossiblyCompressed (same file):
if (encoding?.includes("gzip")) decodedBuffer = zlib.gunzipSync(buffer);
else if (encoding?.includes("br")) decodedBuffer = zlib.brotliDecompressSync(buffer);
else if (encoding?.includes("deflate")) decodedBuffer = zlib.inflateSync(buffer);
else if (buffer[0]===0x1f && buffer[1]===0x8b) decodedBuffer = zlib.gunzipSync(buffer);There is no cap on the compressed input size, the decompressed output size, or the compression ratio. The fetch branch (Cloudflare Workers, and the !isNode path) is equivalent: await response.arrayBuffer() buffers without a cap and DecompressionStream decompresses without a cap.
The client already advertises Accept-Encoding: gzip, deflate, br, so a hostile upstream can choose any of these encodings.
Impact
- Memory exhaustion / crash. The decompressed size is attacker-chosen. gzip reaches ~1000:1; brotli far higher. A few hundred KB on the wire expands to gigabytes in memory, OOM-killing a Node process or exceeding the Cloudflare Workers ~128 MB isolate limit (request failure / isolate recycling).
- Event-loop stall. Decompression is synchronous (
*Sync), so even sub-fatal payloads freeze the entire server for the duration — a single request degrades service for all concurrent clients. - Reachability. On the network-exposed HTTP transport (advisory #02, no auth) and on the shared Cloudflare demo instance, any unauthenticated client can trigger this by pointing a tool at a body they host. It is also reachable indirectly: a legitimate-looking portal (or a redirect, see advisory #01) can serve the bomb.
Proof of concept
poc/decompression-bomb-poc.mjs reproduces the exact decode step and confirms the missing cap. Observed:
compressed body on the wire : 63.7 KB
server would decompress to : 64 MB (ratio ~1028:1)
[decode] 63.7 KB input -> 64 MB output
[decode] RSS +~136 MB, event loop blocked ~1583 ms in ONE synchronous gunzipSync call.
[buffering] client read 40 MB response fully, no size errorScaling the (attacker-chosen) decompressed size to GBs exhausts memory; using brotli achieves the same with a far smaller wire payload.
Remediation
- Set explicit
maxContentLengthandmaxBodyLengthon the axios request (e.g. a few MB), and enforce a byte cap when readingresponse.arrayBuffer()on the fetch path. - Bound decompression output: check the
Content-Length/streamed byte count before decompressing, and use streaming decompression with a hard output-size ceiling instead of the*Syncone-shot calls; abort when the ceiling is exceeded. - Reject or truncate responses whose declared or observed size exceeds the limit, and prefer async decompression so a single request cannot block the event loop.