CVE-2022-32221
POST following PUT confusion
Project curl Security Advisory, October 26 2022 - Permalink
VULNERABILITY
When doing HTTP(S) transfers, libcurl might erroneously use the read
callback (CURLOPT_READFUNCTION
) to ask for data to send,
even when the CURLOPT_POSTFIELDS
option has been set, if
the same handle previously was used to issue a PUT
request
which used that callback.
This flaw may surprise the application and cause it to misbehave and
either send off the wrong data or use memory after free or similar in
the subsequent POST
request.
The problem exists in the logic for a reused handle when it is changed from a PUT to a POST.
INFO
The code actually sending wrong data or doing a use after free is not present in libcurl code but are only presumed scenarios that might become the outcome of libcurl surprisingly calling the read callback in a situation where it is not expected to.
This flaw cannot be triggered with the command line tool.
The Common Vulnerabilities and Exposures (CVE) project has assigned the name CVE-2022-32221 to this issue.
CWE-440: Expected Behavior Violation
Severity: medium
AFFECTED VERSIONS
- Affected versions: libcurl 7.7 to and including 7.85.0
- Not affected versions: libcurl < 7.7 and >= 7.86.0
- Introduced-in: https://github.com/curl/curl/commit/546572da0457f3
libcurl is used by many applications, but not always advertised as such!
SOLUTION
The fix for CVE-2022-32221 was committed to the curl git repository and made public before the security impact of this issue become clear to us. The security impact was not highlighted in the commit message nor surrounding messaging.
RECOMMENDATIONS
A - Upgrade curl to version 7.86.0
B - Apply the patch to your local version
C - Do not do mix using the read callback and
CURLOPT_POSTFIELDS
string on a reused easy handle
TIMELINE
This issue was reported to the curl project on September 19, 2022. We contacted distros@openwall on October 18, 2022.
libcurl 7.86.0 was released on October 26 2022, coordinated with the publication of this advisory.
CREDITS
- Reported-by: Robby Simpson
- Patched-by: Daniel Stenberg
Thanks a lot!