CVE-2021-22926: CURLOPT_SSLCERT mixup with Secure Transport
The Secure Transport backend of libcurl does not check whether a file with the same name as a keychain certificate exists in the current directory, so a local file can override the keychain nickname. An attacker who can create a file with that name can cause a denial of service by preventing the application from loading the certificate.
- Triaged in 41 hours
- Fixed in 36 days
- Paid in 20 days
- Disclosed after 36 days
Summary:
libcurl Secure Transport SSL backend fails to secure the CURLOPT_SSLCERT against current directory file overriding the keychain nickname specified.
This leads to the possibility of locally created file overriding the CURLOPT_SSLCERT specified certificate and thus causing denial of service.
Steps To Reproduce:
- Configure and build curl against Secure Transport:
configure --with-secure-transport && make - Have keychain with client certificate called "testcert"
- Use testcert from keychain to authenticate:
./src/curl -E testcert https://testsite - In current directory execute
touch testcert - Try authenticating again
./src/curl -E testcert https://testsite
curl: (58) SSL: Can't load the certificate "testcert" and its private key: OSStatus -50
The issue stems from the fact that Secure Transport backend code doesn't seem to prefer the keychain over the local file. The documentation says that local file should be prefixed with "./" when used, but the code doesn't have any such checks. Interestingly NSS SSL backend does have the check: https://github.com/curl/curl/blob/master/lib/vtls/nss.c#L432
The impact of this vulnerability is rather limited: In practice it seems to be only usable in causing denial of service against applications using keychain client certificates. It could happen in practice for example if executing command in /tmp directory structure or home directory of another user. The user would be able to prevent the app from creating an authenticated connection by creating a file with matching name used for the keychain nickname used by the app.
Impact
Denial of service
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
Likely the Secure Transport backend does not check whether a local file with the same name exists before using the keychain nickname, unlike the NSS backend which has such a check.
Impact
The impact is limited to denial of service: an attacker who can create a file with the matching name in a directory where the application runs can prevent it from making an authenticated connection.
What the attacker needed
Local access to create a file; application uses keychain certificate by name; application runs in attacker-writable directory
How it was found
- Build curl with the Secure Transport backend.
- Have a keychain containing a client certificate named 'testcert'.
- Use that certificate to authenticate to a test site.
- Create a file with the same name in the current directory.
- Try to authenticate again and observe the error.
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 an application asks to use a certificate stored in the system keychain, it gives a name. The library should look in the keychain, but it also looks in the current folder and finds a file with the same name first. If someone can create that file, the application fails to load the certificate and cannot connect.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.