{"id":2443,"date":"2020-04-19T16:54:53","date_gmt":"2020-04-19T14:54:53","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=2443"},"modified":"2020-04-21T09:34:03","modified_gmt":"2020-04-21T07:34:03","slug":"re2c-heap-overflow-in-scannerfill-scanner-cc","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2020\/04\/19\/re2c-heap-overflow-in-scannerfill-scanner-cc\/","title":{"rendered":"re2c: heap overflow in Scanner::fill (scanner.cc)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"http:\/\/re2c.org\/\">re2c<\/a> is a tool for generating C-based recognizers from regular expressions.<\/p>\n<p>There is an heap overflow reproducible with a crafted file.<\/p>\n<pre><font size=\"2\">~ $ re2c -o \/tmp\/out $FILE\r\n=================================================================\r\n==43995==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x629000004212 at pc 0x00000049937f bp 0x7ffc0521bc00 sp 0x7ffc0521b3c8\r\nWRITE of size 18 at 0x629000004212 thread T0\r\n    #0 0x49937e in __asan_memset \/var\/tmp\/portage\/sys-libs\/compiler-rt-sanitizers-9.0.0\/work\/compiler-rt-9.0.0.src\/lib\/asan\/asan_interceptors_memintrinsics.cc:26:3\r\n    #1 0x67a291 in re2c::Scanner::fill(unsigned long) \/var\/tmp\/portage\/dev-util\/re2c-1.3\/work\/re2c-1.3\/src\/parse\/scanner.cc:167:9\r\n    #2 0x682a51 in re2c::Scanner::echo(re2c::Output&amp;) \/var\/tmp\/portage\/dev-util\/re2c-1.3\/work\/re2c-1.3\/src\/parse\/lex.cc:94:33\r\n    #3 0x61d5f4 in re2c::compile(re2c::Scanner&amp;, re2c::Output&amp;, re2c::Opt&amp;) \/var\/tmp\/portage\/dev-util\/re2c-1.3\/work\/re2c-1.3\/src\/compile.cc:148:41\r\n    #4 0x4cc668 in main \/var\/tmp\/portage\/dev-util\/re2c-1.3\/work\/re2c-1.3\/src\/main.cc:33:5\r\n    #5 0x7f26392c9dca in __libc_start_main \/var\/tmp\/portage\/sys-libs\/glibc-2.29-r2\/work\/glibc-2.29\/csu\/..\/csu\/libc-start.c:308:16\r\n    #6 0x421d39  (\/usr\/bin\/re2c+0x421d39)\r\n\r\n0x629000004212 is located 0 bytes to the right of 16402-byte region [0x629000000200,0x629000004212)\r\nallocated by thread T0 here:\r\n    #0 0x4c949d in operator new[](unsigned long) \/var\/tmp\/portage\/sys-libs\/compiler-rt-sanitizers-9.0.0\/work\/compiler-rt-9.0.0.src\/lib\/asan\/asan_new_delete.cc:102:3\r\n    #1 0x67a0f2 in re2c::Scanner::fill(unsigned long) \/var\/tmp\/portage\/dev-util\/re2c-1.3\/work\/re2c-1.3\/src\/parse\/scanner.cc:154:22\r\n    #2 0x682a51 in re2c::Scanner::echo(re2c::Output&amp;) \/var\/tmp\/portage\/dev-util\/re2c-1.3\/work\/re2c-1.3\/src\/parse\/lex.cc:94:33\r\n    #3 0x61d5f4 in re2c::compile(re2c::Scanner&amp;, re2c::Output&amp;, re2c::Opt&amp;) \/var\/tmp\/portage\/dev-util\/re2c-1.3\/work\/re2c-1.3\/src\/compile.cc:148:41\r\n    #4 0x4cc668 in main \/var\/tmp\/portage\/dev-util\/re2c-1.3\/work\/re2c-1.3\/src\/main.cc:33:5\r\n    #5 0x7f26392c9dca in __libc_start_main \/var\/tmp\/portage\/sys-libs\/glibc-2.29-r2\/work\/glibc-2.29\/csu\/..\/csu\/libc-start.c:308:16\r\n\r\nSUMMARY: AddressSanitizer: heap-buffer-overflow \/var\/tmp\/portage\/sys-libs\/compiler-rt-sanitizers-9.0.0\/work\/compiler-rt-9.0.0.src\/lib\/asan\/asan_interceptors_memintrinsics.cc:26:3 in __asan_memset<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n1.3<\/p>\n<p><strong>Fixed version:<\/strong><br \/>\nWill be 2.0<\/p>\n<p><strong>Commit fix:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/skvadrik\/re2c\/commit\/c4603ba5ce229db83a2a4fb93e6d4b4e3ec3776a\">https:\/\/github.com\/skvadrik\/re2c\/commit\/c4603ba5ce229db83a2a4fb93e6d4b4e3ec3776a<\/a><\/p>\n<p><strong>Credit:<\/strong><br \/>\nThis bug was discovered by Agostino Sarubbo.<\/p>\n<p><strong>CVE:<\/strong><br \/>\nCVE-2020-11958<\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2020-04-17: bug discovered and reported to upstream<br \/>\n2020-04-17: upstream fixed the issue<br \/>\n2020-04-19: blog post about the issue<br \/>\n2020-04-21: 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>.<br \/>\nThis bug was identified with bare metal servers donated by <a href=\"https:\/\/www.packet.net\/\">Packet<\/a>. This work is also supported by the <a href=\"https:\/\/www.coreinfrastructure.org\">Core Infrastructure Initiative<\/a>.<\/p>\n<p><strong>Permalink:<\/strong><\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"cOlko4R259\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2020\/04\/19\/re2c-heap-overflow-in-scannerfill-scanner-cc\/\">re2c: heap overflow in Scanner::fill (scanner.cc)<\/a><\/p><\/blockquote>\n<p><iframe title=\"&#8220;re2c: heap overflow in Scanner::fill (scanner.cc)&#8221; &#8212; agostino&#039;s blog\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"http:\/\/blogs.gentoo.org\/ago\/2020\/04\/19\/re2c-heap-overflow-in-scannerfill-scanner-cc\/embed\/#?secret=cOlko4R259\" data-secret=\"cOlko4R259\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: re2c is a tool for generating C-based recognizers from regular expressions. There is an heap overflow reproducible with a crafted file. ~ $ re2c -o \/tmp\/out $FILE ================================================================= ==43995==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x629000004212 at pc 0x00000049937f bp 0x7ffc0521bc00 &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2020\/04\/19\/re2c-heap-overflow-in-scannerfill-scanner-cc\/\">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-Dp","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/2443"}],"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=2443"}],"version-history":[{"count":6,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/2443\/revisions"}],"predecessor-version":[{"id":2450,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/2443\/revisions\/2450"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=2443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=2443"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=2443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}