curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

[SECURITY ADVISORY] libcurl: FTP wildcard stack overflow

From: Daniel Stenberg via curl-users <>
Date: Wed, 9 Dec 2020 07:53:32 +0100 (CET)

FTP wildcard stack overflow

Project curl Security Advisory, December 9th 2020 -


libcurl offers a wildcard matching functionality, which allows a callback (set
with `CURLOPT_CHUNK_BGN_FUNCTION`) to return information back to libcurl on
how to handle a specific entry in a directory when libcurl iterates over a
list of all available entries.

When this callback returns `CURL_CHUNK_BGN_FUNC_SKIP`, to tell libcurl to not
deal with that file, the internal function in libcurl then calls itself
recursively to handle the next directory entry.

If there's a sufficient amount of file entries and if the callback returns
"skip" enough number of times, libcurl runs out of stack space. The exact
amount will of course vary with platforms, compilers and other environmental

The content of the remote directory is not kept on the stack, so it seems hard
for the attacker to control exactly what data that overwrites the stack -
however it remains a Denial-Of-Service vector as a malicious user who controls
a server that a libcurl-using application works with under these premises can
trigger a crash.

(There is also a few other ways the function can be made to call itself and
trigger this problem.)

We are not aware of any exploit of this flaw.

This issue was unfortunately reported publicly in the curl GitHub issue
tracker as [issue 6255](
This flaw has existed in curl since commit
[0825cd80a]( in curl 7.21.0.
This functionality is not used by the curl tool so it is not affected.
Further: it is not a very widely used feature.
The Common Vulnerabilities and Exposures (CVE) project has assigned the name
CVE-2020-8285 to this issue.
CWE-674: Uncontrolled Recursion
Severity: Medium
- Affected versions: libcurl 7.21.0 to and including 7.73.0
- Not affected versions: libcurl < 7.21.0 and libcurl >= 7.74.0
Also note that libcurl is used by many applications, and not always
advertised as such.
The internal function is rewritten to instead and more appropriately use an
ordinary loop instead of the recursive approach. This way, the stack use will
remain the same no matter how many files that are skipped.
A [fix for CVE-2020-8285](
We suggest you take one of the following actions immediately, in order of
  A - Upgrade curl to version 7.74.0
  B - Disable FTP wildcard use (`CURLOPT_WILDCARDMATCH`)
  C - Make sure your `CURLOPT_CHUNK_BGN_FUNCTION` callback doesn't do multiple skips.
This issue was first reported to the curl project on November 27, 2020.
This advisory was posted on December 9th 2020.
This issue was initially reported by xnynx on GitHub. Daniel took it to the
security team immediately. Patch by Daniel Stenberg.
Thanks a lot!
  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
Received on 2020-12-09