cURL buffer overflow

Wed 06 February 2013

Volema found remotely exploitable buffer overflow vulnerability in libcurl POP3, SMTP protocol handlers which lead to code execution (RCE). When negotiating SASL DIGEST-MD5 authentication, the function Curl_sasl_create_digest_md5_message() uses the data provided from the server without doing the proper length checks and that data is then appended to a local fixed-size buffer on the stack.

Vendor notified, CVE-2013-0249 released.

Attack Concept Outline

We have the permissions to send custom HTTP requests with curl. We send request to our

GET / HTTP/1.0

server answers with

HTTP/1.0 302 Found
Location: pop3://

"smart" curl interpretes redirect and connects to port 110/TCP using POP3 proto. Server answers

+OK POP3 server ready

curl sends


servers answers with DIGEST-MD5 only

+OK List of capabilities follows
IMPLEMENTATION dumbydumb POP3 server

so, libcurl has to send


then server sends the payload


and overflow happens because of fixed "uri" buffer size (128) and "realm" which is also 128 bytes


how it looks in gdb

Program received signal SIGSEGV, Segmentation fault.
0x00007fd2b238298d in ?? () from /lib/x86_64-linux-gnu/
(gdb) bt
#0  0x00007fd2b238298d in ?? () from /lib/x86_64-linux-gnu/
#1  0x00007fd2b2a5cc07 in Curl_sasl_create_digest_md5_message ()
   from /home/kyprizel/test/curl-7.28.1/lib/.libs/
#2  0x4141414141414141 in ?? ()
#1469 0x4141414141414141 in ?? ()
#1470 0x656d616e72657375 in ?? ()
Cannot access memory at address 0x7fff63b8b000

Original exploit:


We recommend to disable protocols other than HTTP(S) in your application using options CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS. libcurl version should be updated.

Comments !