{"id":4458,"date":"2012-10-25T11:30:43","date_gmt":"2012-10-25T09:30:43","guid":{"rendered":"http:\/\/daniel.haxx.se\/blog\/?p=4458"},"modified":"2023-11-27T19:05:18","modified_gmt":"2023-11-27T18:05:18","slug":"libcurl-claimed-to-be-dangerous","status":"publish","type":"post","link":"https:\/\/daniel.haxx.se\/blog\/2012\/10\/25\/libcurl-claimed-to-be-dangerous\/","title":{"rendered":"libcurl claimed to be dangerous"},"content":{"rendered":"\n<p>On October 24th, my twitter feed suddenly got more activity than usual when suddenly there&#8217;s a mention of a newly(?) published paper:<\/p>\n\n\n\n<p><a href=\"https:\/\/crypto.stanford.edu\/~dabo\/pubs\/abstracts\/ssl-client-bugs.html\"><strong>The most dangerous code in the world: validating SSL certificates in non-browser software<\/strong><\/a><\/p>\n\n\n\n<p>Within the twelve page document they discuss flaws in various APIs and other certificate checking software, and for libcurl they say:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Internally, it uses OpenSSL to verify the chain of trust and verifies the hostname itself. This functionality is controlled by parameters <a href=\"http:\/\/curl.haxx.se\/libcurl\/c\/curl_easy_setopt.html#CURLOPTSSLVERIFYPEER\">CURLOPT_SSL_VERIFYPEER<\/a> (default value: true) and <a href=\"http:\/\/curl.haxx.se\/libcurl\/c\/curl_easy_setopt.html#CURLOPTSSLVERIFYHOST\">CURLOPT_SSL_VERIFYHOST<\/a> (default value: 2). This interface is almost perversely bad. The VERIFYPEER parameter is a boolean, while a similar-looking VERIFYHOST parameter is an integer.<\/p>\n<\/blockquote>\n\n\n\n<p>(The fact that libcurl supports no less than nine(!) different SSL library backends seems to have been ignored but is irrelevant.)<\/p>\n\n\n\n<p>The final part is their focus. It is an integer option but it looks like it could be similar to the <a href=\"http:\/\/curl.haxx.se\/libcurl\/c\/curl_easy_setopt.html#CURLOPTSSLVERIFYPEER\">VERIFYPEER<\/a> option which could be considered a boolean option &#8211; but note that there is no boolean options at all in libcurl, those are all &#8220;long&#8221; values. They go on to explain:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Well-intentioned developers not only routinely misunderstand these parameters, but often set <a href=\"http:\/\/curl.haxx.se\/libcurl\/c\/curl_easy_setopt.html#CURLOPTSSLVERIFYHOST\">CURLOPT_SSL_VERIFY HOST<\/a> to TRUE, thereby changing it to 1 and thus accidentally  disabling hostname verification with disastrous consequences<\/p>\n<\/blockquote>\n\n\n\n<p>They back up their claim with some snippets from PHP programs showing wrong use in chapter 7.<\/p>\n\n\n\n<p>What did the authors do to try to fix the problem before posting rude comments in a report? Nothing. At. All. They could&#8217;ve emailed, tweeted or posted a bug report or patch but none of that happened.<\/p>\n\n\n\n<p>They also only post examples of the bad use made by PHP code. The PHP code uses the <a href=\"http:\/\/curl.haxx.se\/libcurl\/php\/\">PHP\/CURL binding<\/a> and a change could easily be done in the PHP binding. I don&#8217;t know PHP internals, but perhaps the option could be made to not accept a boolean value instead of a numerical there.<\/p>\n\n\n\n<p>We&#8217;re now discussing this topic on the <a href=\"http:\/\/curl.haxx.se\/mail\/lib-2012-10\/0198.html\">libcurl mailing list<\/a>. If you have ideas or suggestions or just comments, feel free to join in!<\/p>\n\n\n\n<p>Oh, and I feel that my recent blog post on the <a href=\"http:\/\/daniel.haxx.se\/blog\/2012\/10\/04\/ssl-verification-still-often-disabled\/\">non-verifying users<\/a> seems related and relevant.<\/p>\n\n\n\n<p>I will also call the majority of all these suddenly appearing complainers on this API to be mostly\u00a0hypocrites\u00a0since the API has been established and working like this for over a 10 (ten!) years and not a single person has objected to it before. Joining up on the &#8220;bandwagon&#8221; now and calling the API stupid or silly is&#8230; well, I&#8217;d call it &#8220;non-intelligent behavior&#8221;. In libcurl we take a stable and solid API and ABI <em>very<\/em> seriously. We simply do not break API nor ABI unless forced brutally into a corner we can&#8217;t escape otherwise. Therefore\u00a0we have kept this API to keep existing applications functional.<\/p>\n\n\n\n<p><strong>Update: <\/strong>the <a href=\"http:\/\/comments.gmane.org\/gmane.comp.php.devel\/76531\">discussion thread on the topic from the PHP-DEV list<\/a>. Thanks to Jan Ehrhardt.<\/p>\n\n\n\n<p><strong>Second update:<\/strong> we shipped <a href=\"http:\/\/curl.haxx.se\/changes.html#7_28_1\">libcurl 7.28.1 <\/a>on November 20 2012, and it no longer accepts the value 1 to VERIFYHOST, but will instead cause curl_easy_setopt() return an error and use the default value (which is 2). This will prevent applications to accidentally be insecure due to use of 1.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>On October 24th, my twitter feed suddenly got more activity than usual when suddenly there&#8217;s a mention of a newly(?) published paper: The most dangerous code in the world: validating SSL certificates in non-browser software Within the twelve page document they discuss flaws in various APIs and other certificate checking software, and for libcurl they &hellip; <a href=\"https:\/\/daniel.haxx.se\/blog\/2012\/10\/25\/libcurl-claimed-to-be-dangerous\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">libcurl claimed to be dangerous<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,133],"tags":[33,193,186,428,43],"class_list":["post-4458","post","type-post","status-publish","format-standard","hentry","category-curl","category-security","tag-curl-and-libcurl","tag-openssl","tag-php","tag-security","tag-ssl"],"_links":{"self":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts\/4458","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/comments?post=4458"}],"version-history":[{"count":20,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts\/4458\/revisions"}],"predecessor-version":[{"id":23541,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts\/4458\/revisions\/23541"}],"wp:attachment":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/media?parent=4458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/categories?post=4458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/tags?post=4458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}