{"id":1483,"date":"2017-03-14T16:47:57","date_gmt":"2017-03-14T14:47:57","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=1483"},"modified":"2017-03-20T11:16:35","modified_gmt":"2017-03-20T09:16:35","slug":"libpcre-invalid-memory-read-in-match-pcre_exec-c","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/03\/14\/libpcre-invalid-memory-read-in-match-pcre_exec-c\/","title":{"rendered":"libpcre: invalid memory read in match (pcre_exec.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 an invalid read in the library. For who is interested in a detailed description of the bug, will follow a feedback from upstream:<\/p>\n<blockquote><p>This was a genuine bug in the 32-bit library. Thanks for finding it. The crash was caused by trying to find a Unicode property for a code value greater than 0x10ffff, the Unicode maximum, when running in non-UTF mode (where character values can be up to 0xffffffff). The bug was in both PCRE1 and PCRE2. I have fixed both of them.<\/p><\/blockquote>\n<p>The complete ASan output:<\/p>\n<pre><font size=\"2\"># pcretest -32 -d $FILE\r\n==14788==ERROR: AddressSanitizer: SEGV on unknown address 0x7f1bbffed4df (pc 0x7f1bbee3fe6b bp 0x7fff8b50d8c0 sp 0x7fff8b50d3a0 T0)\r\n==14788==The signal is caused by a READ memory access.\r\n    #0 0x7f1bbee3fe6a in match \/tmp\/portage\/dev-libs\/libpcre-8.40\/work\/pcre-8.40\/pcre_exec.c:5473:18\r\n    #1 0x7f1bbee09226 in pcre32_exec \/tmp\/portage\/dev-libs\/libpcre-8.40\/work\/pcre-8.40\/pcre_exec.c:6936:8\r\n    #2 0x527d6c in main \/tmp\/portage\/dev-libs\/libpcre-8.40\/work\/pcre-8.40\/pcretest.c:5218:9\r\n    #3 0x7f1bbddd678f 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\r\nAddressSanitizer can not provide additional info.\r\nSUMMARY: AddressSanitizer: SEGV \/tmp\/portage\/dev-libs\/libpcre-8.40\/work\/pcre-8.40\/pcre_exec.c:5473:18 in match\r\n==14788==ABORTING<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n8.40 and 10.23<\/p>\n<p><strong>Fixed version:<\/strong><br \/>\n8.41 and 10.24 (not released atm)<\/p>\n<p><strong>Commit fix for libpcre1:<\/strong><br \/>\n<a href=\"https:\/\/vcs.pcre.org\/pcre\/code\/trunk\/pcre_internal.h?r1=1649&amp;r2=1688&amp;sortby=date\">https:\/\/vcs.pcre.org\/pcre\/code\/trunk\/pcre_internal.h?r1=1649&amp;r2=1688&amp;sortby=date<\/a><br \/>\n<a href=\"https:\/\/vcs.pcre.org\/pcre\/code\/trunk\/pcre_ucd.c?r1=1490&amp;r2=1688&amp;sortby=date\">https:\/\/vcs.pcre.org\/pcre\/code\/trunk\/pcre_ucd.c?r1=1490&amp;r2=1688&amp;sortby=date<\/a><\/p>\n<p><strong>Commit fix for libpcre2:<\/strong><br \/>\n<a href=\"https:\/\/vcs.pcre.org\/pcre2\/code\/trunk\/src\/pcre2_ucd.c?r1=316&amp;r2=670&amp;sortby=date\">https:\/\/vcs.pcre.org\/pcre2\/code\/trunk\/src\/pcre2_ucd.c?r1=316&amp;r2=670&amp;sortby=date<\/a><br \/>\n<a href=\"https:\/\/vcs.pcre.org\/pcre2\/code\/trunk\/src\/pcre2_internal.h?r1=600&amp;r2=670&amp;sortby=date\">https:\/\/vcs.pcre.org\/pcre2\/code\/trunk\/src\/pcre2_internal.h?r1=600&amp;r2=670&amp;sortby=date<\/a><\/p>\n<p><strong>Credit:<\/strong><br \/>\nThis bug was discovered by Agostino Sarubbo of Gentoo.<\/p>\n<p><strong>CVE:<\/strong><br \/>\nCVE-2017-7186<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00204-pcre-invalidread1-pcre_exec\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00204-pcre-invalidread1-pcre_exec<\/a><\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2017-02-23: bug discovered and reported to upstream<br \/>\n2017-02-24: upstream released a patch<br \/>\n2017-03-14: blog post about the issue<br \/>\n2017-03-19: CVE assigned<\/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=\"HCBeCmIY8T\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/03\/14\/libpcre-invalid-memory-read-in-match-pcre_exec-c\/\">libpcre: invalid memory read in match (pcre_exec.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\/14\/libpcre-invalid-memory-read-in-match-pcre_exec-c\/embed\/#?secret=HCBeCmIY8T\" data-secret=\"HCBeCmIY8T\" width=\"600\" height=\"338\" title=\"&#8220;libpcre: invalid memory read in match (pcre_exec.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 an invalid read in the library. For who is interested in a detailed description of the bug, will follow a feedback from upstream: &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2017\/03\/14\/libpcre-invalid-memory-read-in-match-pcre_exec-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-nV","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1483"}],"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=1483"}],"version-history":[{"count":4,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1483\/revisions"}],"predecessor-version":[{"id":1487,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/1483\/revisions\/1487"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=1483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=1483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=1483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}