Skip to content
DoS Disclosed report Intermediate

Unbounded memory consumption via compressed HTTP responses (gzip/brotli/zstd)

curl does not limit the total size of data produced when decompressing compressed HTTP responses, so a small compressed reply can expand into a very large amount of memory. A malicious server could therefore cause excessive memory use.

gaurav0212 Follow

Originally disclosed on HackerOne

  • Disclosed after 42 hours

During a review of curl's handling of response decompression, it was noticed that no limit exists on the final uncompressed data volume from compressed HTTP replies. Instead of setting constraints, the current design allows indefinite expansion during processing. This absence of limits could lead to excessive memory use under certain conditions. Rather than imposing caps by default, the system trusts input without internal safeguards. As a result, malicious payloads might trigger uncontrolled growth in output size.

In lib/content_encoding.c, decompression functions like inflate_stream run in loops using a fixed buffer yet fail to monitor total output size. Consequently, one tiny compressed input may expand into excessive memory usage. Although designed for efficiency, these routines lack limits on expanded data volume. Therefore, malicious servers could trigger disproportionate resource consumption during processing.

This behavior appears using standard curl settings, without needing extra configurations.

Proof of Concept:

I’ve included a PDF with a complete, repeatable proof of concept curl version along with its setup a basic gzip compression trap host curl run using standard setup noticed rise in RSS while unpacking data important parts of the code in lib/content_encoding.c

The proof demonstrates a ~48 KB compressed reply grows to around 50 MB in memory prior to disposal.

Impact

A bad server might make curl use excessive memory by sending a compressed file that expands drastically, which could fill up system RAM and stop normal operations. This happens because the --max-filesize flag only limits downloaded data size but doesn't control how big files become after unpacking.

Suggested Fix (high level):

Set a changeable or fixed maximum for the uncompressed data size, then stop unpacking if that cap is passed.

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

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The decompression routines in lib/content_encoding.c loop over a fixed buffer without tracking the total number of bytes produced, so there is no cap on the expanded output size.

Impact

A malicious server could make curl consume excessive memory, potentially filling system RAM and disrupting normal operations; the --max-filesize flag does not prevent this because it only limits the downloaded size, not the unpacked size.

What the attacker needed

Victim connects to a malicious server; server sends a highly compressible response

The fix

A configurable or fixed maximum for the uncompressed data size should be set, and decompression should stop once that cap is exceeded.

How it was found

  1. Set up a host that serves a small gzip-compressed response which expands to a very large size.
  2. Run curl with its standard settings against that host.
  3. Observe the resident memory (RSS) rising while curl unpacks the response.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a server sends a compressed response, curl unpacks it in memory. This report says curl never checks how big the unpacked result becomes, so a tiny compressed file can turn into a huge one and use up lots of memory. A hostile server could use that to cause excessive memory use.

What is DoS?

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

More by gaurav0212

View all

1 more disclosed report, best first.

More from curl

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.