{"id":1488,"date":"2017-03-20T11:52:45","date_gmt":"2017-03-20T09:52:45","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=1488"},"modified":"2017-03-24T11:45:59","modified_gmt":"2017-03-24T09:45:59","slug":"libpcre-two-stack-based-buffer-overflow-write-in-pcre32_copy_substring-pcre_get-c","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/03\/20\/libpcre-two-stack-based-buffer-overflow-write-in-pcre32_copy_substring-pcre_get-c\/","title":{"rendered":"libpcre: two stack-based buffer overflow write in pcre32_copy_substring (pcre_get.c)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"http:\/\/www.pcre.org\">libpcre<\/a> is a perl-compatible regular expression library.<\/p>\n<p>A fuzz on libpcre1 through the pcretest utility revealed two stack overflow write. Upstream says that these bugs are fixed by one of the previous commit. However I&#8217;m providing as usual the stacktrace and the reproducer, so if you are not running the latest upstream release, like happen on debian\/rhel based distros, you may want to check better the status of this bug.<\/p>\n<p>The complete ASan output:<\/p>\n<pre><font size=\"2\"># pcretest -32 -d $FILE\r\n==29686==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7f58f32026a0 at pc 0x7f58f6f90a24 bp 0x7ffea3aa3b30 sp 0x7ffea3aa3b28\r\nWRITE of size 4 at 0x7f58f32026a0 thread T0\r\n    #0 0x7f58f6f90a23 in pcre32_copy_substring \/tmp\/portage\/dev-libs\/libpcre-8.40\/work\/pcre-8.40\/pcre_get.c:358:15\r\n    #1 0x528220 in main \/tmp\/portage\/dev-libs\/libpcre-8.40\/work\/pcre-8.40\/pcretest.c:5333:13\r\n    #2 0x7f58f5ea778f in __libc_start_main \/tmp\/portage\/sys-libs\/glibc-2.23-r3\/work\/glibc-2.23\/csu\/..\/csu\/libc-start.c:289\r\n    #3 0x41b438 in _init (\/usr\/bin\/pcretest+0x41b438)\r\n<\/font><\/pre>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00207-pcre-stackoverflow-pcre32_copy_substring\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00207-pcre-stackoverflow-pcre32_copy_substring<\/a><br \/>\n<strong>CVE:<\/strong><br \/>\nCVE-2017-7245<\/p>\n<pre><font size=\"2\"># pcretest -32 -d $FILE\r\n==21399==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7f83734026a0 at pc 0x0000004bd2ac bp 0x7ffdda673b30 sp 0x7ffdda6732e0\r\nWRITE of size 268 at 0x7f83734026a0 thread T0\r\n    #0 0x4bd2ab in __asan_memcpy \/tmp\/portage\/sys-devel\/llvm-3.9.1-r1\/work\/llvm-3.9.1.src\/projects\/compiler-rt\/lib\/asan\/asan_interceptors.cc:413\r\n    #1 0x7f8377118925 in pcre32_copy_substring \/tmp\/portage\/dev-libs\/libpcre-8.40\/work\/pcre-8.40\/pcre_get.c:357:1\r\n    #2 0x528220 in main \/tmp\/portage\/dev-libs\/libpcre-8.40\/work\/pcre-8.40\/pcretest.c:5333:13\r\n    #3 0x7f837602f78f in __libc_start_main \/tmp\/portage\/sys-libs\/glibc-2.23-r3\/work\/glibc-2.23\/csu\/..\/csu\/libc-start.c:289\r\n    #4 0x41b438 in _init (\/usr\/bin\/pcretest+0x41b438)\r\n<\/font><\/pre>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00209-pcre-stackoverflow2-read_capture_name32\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00209-pcre-stackoverflow2-read_capture_name32<\/a><br \/>\n<strong>CVE:<\/strong><br \/>\nCVE-2017-7246<\/p>\n<p><strong>Affected version:<\/strong><br \/>\n8.40<\/p>\n<p><strong>Fixed version:<\/strong><br \/>\n8.41 (not released atm)<\/p>\n<p><strong>Commit fix:<\/strong><br \/>\nN\/A<\/p>\n<p><strong>Credit:<\/strong><br \/>\nThis bug was discovered by Agostino Sarubbo of Gentoo.<\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2017-02-24: bug discovered and reported to upstream<br \/>\n2017-03-20: blog post about the issue<\/p>\n<p><strong>Note:<\/strong><br \/>\nThis bug was found with <a href=\"http:\/\/lcamtuf.coredump.cx\/afl\">American Fuzzy Lop<\/a>.<\/p>\n<p><strong>Permalink:<\/strong><\/p>\n<blockquote data-secret=\"SwHp9WCo7m\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/03\/20\/libpcre-two-stack-based-buffer-overflow-write-in-pcre32_copy_substring-pcre_get-c\/\">libpcre: two stack-based buffer overflow write in pcre32_copy_substring (pcre_get.c)<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"http:\/\/blogs.gentoo.org\/ago\/2017\/03\/20\/libpcre-two-stack-based-buffer-overflow-write-in-pcre32_copy_substring-pcre_get-c\/embed\/#?secret=SwHp9WCo7m\" data-secret=\"SwHp9WCo7m\" width=\"600\" height=\"338\" title=\"&#8220;libpcre: two stack-based buffer overflow write in pcre32_copy_substring (pcre_get.c)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: libpcre is a perl-compatible regular expression library. A fuzz on libpcre1 through the pcretest utility revealed two stack overflow write. Upstream says that these bugs are fixed by one of the previous commit. However I&#8217;m providing as usual the &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2017\/03\/20\/libpcre-two-stack-based-buffer-overflow-write-in-pcre32_copy_substring-pcre_get-c\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":140,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[12,10],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2EaBc-o0","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1488"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/users\/140"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/comments?post=1488"}],"version-history":[{"count":6,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1488\/revisions"}],"predecessor-version":[{"id":1514,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1488\/revisions\/1514"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=1488"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=1488"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=1488"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}