CVE-2021-22926

7.5 HIGH

📋 TL;DR

This vulnerability allows attackers to trick libcurl applications into using a malicious client certificate instead of the intended one when running in writable directories like /tmp. It affects applications using libcurl with Secure Transport on macOS that specify client certificates by name rather than file path. This can lead to authentication bypass or impersonation in TLS connections.

💻 Affected Systems

Products:
  • libcurl
  • Applications using libcurl with Secure Transport backend
Versions: libcurl versions prior to 7.77.0
Operating Systems: macOS
Default Config Vulnerable: ✅ No
Notes: Only affects libcurl built with Secure Transport backend on macOS. Requires application to use CURLOPT_SSLCERT with certificate name (not file path) and run in a writable directory.

📦 What is this software?

Curl by Haxx

curl is a command-line tool and library for transferring data with URLs. It supports numerous protocols including HTTP, HTTPS, FTP, and more, making it essential for API testing, web scraping, and automated data transfers.

Learn more about Curl →

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete authentication bypass allowing attackers to impersonate legitimate users or services in TLS connections, potentially leading to data theft or unauthorized access.

🟠

Likely Case

Authentication failures or incorrect client certificate usage in TLS handshakes, potentially causing service disruptions or limited unauthorized access.

🟢

If Mitigated

No impact if applications don't use client certificates by name or run in secure directories with proper permissions.

🌐 Internet-Facing: MEDIUM - Requires specific conditions (writable directory, certificate by name usage) but could affect internet-facing services using client certificate authentication.
🏢 Internal Only: LOW - Internal systems typically have more controlled directory permissions and certificate management.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: LOW

Exploitation requires local access to create files in the application's working directory. The vulnerability is well-documented with public proof-of-concept available.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: libcurl 7.77.0 and later

Vendor Advisory: https://curl.se/docs/CVE-2021-22926.html

Restart Required: Yes

Instructions:

1. Update libcurl to version 7.77.0 or later. 2. Rebuild applications using libcurl. 3. Restart affected services. 4. Verify the fix by checking libcurl version and testing certificate functionality.

🔧 Temporary Workarounds

Use absolute file paths for certificates

all

Specify client certificates using absolute file paths instead of names to prevent directory traversal attacks.

Replace CURLOPT_SSLCERT "certname" with CURLOPT_SSLCERT "/absolute/path/to/cert.pem"

Secure working directory permissions

linux

Ensure applications run in directories with proper permissions that prevent other users from creating files.

chmod 700 /application/working/directory
chown appuser:appgroup /application/working/directory

🧯 If You Can't Patch

  • Ensure applications run in secure directories with proper permissions (not world-writable like /tmp)
  • Use absolute file paths for all certificate specifications instead of certificate names

🔍 How to Verify

Check if Vulnerable:

Check libcurl version: curl --version. If version is earlier than 7.77.0 and application uses Secure Transport on macOS with certificate names, it's vulnerable.

Check Version:

curl --version | head -1

Verify Fix Applied:

Verify libcurl version is 7.77.0 or later: curl --version. Test client certificate functionality with both name and file specifications.

📡 Detection & Monitoring

Log Indicators:

  • Failed TLS handshakes
  • Certificate validation errors
  • Unexpected certificate usage in authentication logs

Network Indicators:

  • TLS connection failures with certificate errors
  • Unexpected client certificate presentations

SIEM Query:

source="*tls*" AND ("certificate error" OR "handshake failure") AND process="*curl*" OR process="*application*"

🔗 References

📤 Share & Export