HexBrain

curl · Report #2819666

Exploitable Format String Vulnerability in curl_mfprintf Function

N/Astatus
highseverity
23upvotes
6 Nov 2024disclosed

How it was found

Summary:

The curl_mfprintf function in the curl_printf.h file contains a format string vulnerability that allows an attacker to inject arbitrary format specifiers. This can lead to unauthorized access to memory content, potential application crashes, or leakage of sensitive data.

Steps To Reproduce:

Prepare the Test Code: Create a new file named test_printf.c with the following content:

#include <stdio.h> #include "curl_printf.h"

int main() { char* user_input = "%x %x %x %x"; // Attempt to read memory content curl_mfprintf(stdout, user_input); // Passing user-controlled input to the vulnerable function return 0; }

Compile the Code: Compile the test program with the following command:

bash

gcc -o test_printf test_printf.c -I./lib -I./include -L./lib/.libs -lcurl

Execute the Code: Run the compiled program:

bash

./test_printf

Observe the Output: The output should display memory content, which confirms that the vulnerability is exploitable.

Impact

This vulnerability allows an attacker to use format string specifiers to access arbitrary memory locations. By exploiting this issue, an attacker could potentially:

Leak sensitive information from the process memory.
Cause a denial-of-service by crashing the application.
Further exploit the application depending on the context of the memory exposure.

This report was disclosed publicly on HackerOne and belongs to its author and the program. See the original