{"id":2222,"date":"2017-09-14T12:37:37","date_gmt":"2017-09-14T10:37:37","guid":{"rendered":"http:\/\/blogs.gentoo.org\/ago\/?p=2222"},"modified":"2017-09-22T09:11:09","modified_gmt":"2017-09-22T07:11:09","slug":"bento4-null-pointer-dereference-in-ap4_stdcfilebytestreamreadpartial-ap4stdcfilebytestream-cpp","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/ago\/2017\/09\/14\/bento4-null-pointer-dereference-in-ap4_stdcfilebytestreamreadpartial-ap4stdcfilebytestream-cpp\/","title":{"rendered":"bento4: NULL pointer dereference in AP4_StdcFileByteStream::ReadPartial (Ap4StdCFileByteStream.cpp)"},"content":{"rendered":"<p><strong>Description<\/strong>:<br \/>\n<a href=\"https:\/\/www.bento4.com\/\">bento4<\/a> is a fast, modern, open source C++ toolkit for all your MP4 and MPEG DASH media format needs.<\/p>\n<p>The complete ASan output of the issue:<\/p>\n<pre><font size=\"2\"># mp42aac $FILE out.aac\r\nASAN:DEADLYSIGNAL\r\n=================================================================\r\n==18215==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f23fa12110e bp 0x000000000017 sp 0x7fff671b9178 T0)\r\n==18215==The signal is caused by a WRITE memory access.\r\n==18215==Hint: address points to the zero page.\r\n    #0 0x7f23fa12110d  \/var\/tmp\/portage\/sys-libs\/glibc-2.23-r4\/work\/glibc-2.23\/string\/..\/sysdeps\/x86_64\/memcpy.S:71\r\n    #1 0x7f23fa10febd in __GI__IO_file_xsgetn \/var\/tmp\/portage\/sys-libs\/glibc-2.23-r4\/work\/glibc-2.23\/libio\/fileops.c:1392\r\n    #2 0x7f23fa10520f in fread \/var\/tmp\/portage\/sys-libs\/glibc-2.23-r4\/work\/glibc-2.23\/libio\/iofread.c:38\r\n    #3 0x5b6557 in AP4_StdcFileByteStream::ReadPartial(void*, unsigned int, unsigned int&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/System\/StdC\/Ap4StdCFileByteStream.cpp:237:14\r\n    #4 0x544473 in AP4_ByteStream::Read(void*, unsigned int) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ByteStream.cpp:55:29\r\n    #5 0x622427 in AP4_HdlrAtom::AP4_HdlrAtom(unsigned int, unsigned char, unsigned int, AP4_ByteStream&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4HdlrAtom.cpp:86:12\r\n    #6 0x621f4e in AP4_HdlrAtom::Create(unsigned int, AP4_ByteStream&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4HdlrAtom.cpp:51:16\r\n    #7 0x5cae91 in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned int, unsigned int, unsigned long long, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:387:20\r\n    #8 0x5c7fbd in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned long long&amp;, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:220:14\r\n    #9 0x617c17 in AP4_DrefAtom::AP4_DrefAtom(unsigned int, unsigned char, unsigned int, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4DrefAtom.cpp:83:16\r\n    #10 0x617329 in AP4_DrefAtom::Create(unsigned int, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4DrefAtom.cpp:49:16\r\n    #11 0x5c90ae in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned int, unsigned int, unsigned long long, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:529:20\r\n    #12 0x5c7fbd in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned long long&amp;, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:220:14\r\n    #13 0x60c29f in AP4_ContainerAtom::ReadChildren(AP4_AtomFactory&amp;, AP4_ByteStream&amp;, unsigned long long) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ContainerAtom.cpp:193:12\r\n    #14 0x60b1d2 in AP4_ContainerAtom::AP4_ContainerAtom(unsigned int, unsigned long long, bool, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ContainerAtom.cpp:138:5\r\n    #15 0x60b1d2 in AP4_ContainerAtom::Create(unsigned int, unsigned long long, bool, bool, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ContainerAtom.cpp:87\r\n    #16 0x5ca44c in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned int, unsigned int, unsigned long long, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:751:20\r\n    #17 0x5c7fbd in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned long long&amp;, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:220:14\r\n    #18 0x617c17 in AP4_DrefAtom::AP4_DrefAtom(unsigned int, unsigned char, unsigned int, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4DrefAtom.cpp:83:16\r\n    #19 0x617329 in AP4_DrefAtom::Create(unsigned int, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4DrefAtom.cpp:49:16\r\n    #20 0x5c90ae in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned int, unsigned int, unsigned long long, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:529:20\r\n    #21 0x5c7fbd in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned long long&amp;, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:220:14\r\n    #22 0x60c29f in AP4_ContainerAtom::ReadChildren(AP4_AtomFactory&amp;, AP4_ByteStream&amp;, unsigned long long) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ContainerAtom.cpp:193:12\r\n    #23 0x60b1d2 in AP4_ContainerAtom::AP4_ContainerAtom(unsigned int, unsigned long long, bool, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ContainerAtom.cpp:138:5\r\n    #24 0x60b1d2 in AP4_ContainerAtom::Create(unsigned int, unsigned long long, bool, bool, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ContainerAtom.cpp:87\r\n    #25 0x5ca44c in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned int, unsigned int, unsigned long long, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:751:20\r\n    #26 0x5c7fbd in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned long long&amp;, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:220:14\r\n    #27 0x60c561 in AP4_ContainerAtom::ReadChildren(AP4_AtomFactory&amp;, AP4_ByteStream&amp;, unsigned long long) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ContainerAtom.cpp:193:12\r\n    #28 0x60b1d2 in AP4_ContainerAtom::AP4_ContainerAtom(unsigned int, unsigned long long, bool, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ContainerAtom.cpp:138:5\r\n    #29 0x60b1d2 in AP4_ContainerAtom::Create(unsigned int, unsigned long long, bool, bool, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ContainerAtom.cpp:87\r\n    #30 0x5ca44c in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned int, unsigned int, unsigned long long, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:751:20\r\n    #31 0x5c7fbd in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned long long&amp;, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:220:14\r\n    #32 0x60c561 in AP4_ContainerAtom::ReadChildren(AP4_AtomFactory&amp;, AP4_ByteStream&amp;, unsigned long long) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ContainerAtom.cpp:193:12\r\n    #33 0x60b1d2 in AP4_ContainerAtom::AP4_ContainerAtom(unsigned int, unsigned long long, bool, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ContainerAtom.cpp:138:5\r\n    #34 0x60b1d2 in AP4_ContainerAtom::Create(unsigned int, unsigned long long, bool, bool, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ContainerAtom.cpp:87\r\n    #35 0x5ca44c in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned int, unsigned int, unsigned long long, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:751:20\r\n    #36 0x5c7fbd in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned long long&amp;, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:220:14\r\n    #37 0x60c561 in AP4_ContainerAtom::ReadChildren(AP4_AtomFactory&amp;, AP4_ByteStream&amp;, unsigned long long) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ContainerAtom.cpp:193:12\r\n    #38 0x60c099 in AP4_ContainerAtom::AP4_ContainerAtom(unsigned int, unsigned long long, bool, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ContainerAtom.cpp:138:5\r\n    #39 0x58e6ed in AP4_TrakAtom::AP4_TrakAtom(unsigned int, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4TrakAtom.cpp:165:5\r\n    #40 0x5c8e3b in AP4_TrakAtom::Create(unsigned int, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4TrakAtom.h:58:20\r\n    #41 0x5c8e3b in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned int, unsigned int, unsigned long long, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:377\r\n    #42 0x5c7fbd in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned long long&amp;, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:220:14\r\n    #43 0x60c561 in AP4_ContainerAtom::ReadChildren(AP4_AtomFactory&amp;, AP4_ByteStream&amp;, unsigned long long) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ContainerAtom.cpp:193:12\r\n    #44 0x60c099 in AP4_ContainerAtom::AP4_ContainerAtom(unsigned int, unsigned long long, bool, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4ContainerAtom.cpp:138:5\r\n    #45 0x5521b0 in AP4_MoovAtom::AP4_MoovAtom(unsigned int, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4MoovAtom.cpp:79:5\r\n    #46 0x5cad1d in AP4_MoovAtom::Create(unsigned int, AP4_ByteStream&amp;, AP4_AtomFactory&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4MoovAtom.h:56:20\r\n    #47 0x5cad1d in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned int, unsigned int, unsigned long long, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:357\r\n    #48 0x5c7fbd in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, unsigned long long&amp;, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:220:14\r\n    #49 0x5c75c0 in AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream&amp;, AP4_Atom*&amp;) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4AtomFactory.cpp:150:12\r\n    #50 0x54ea2c in AP4_File::ParseStream(AP4_ByteStream&amp;, AP4_AtomFactory&amp;, bool) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4File.cpp:104:12\r\n    #51 0x54f0fa in AP4_File::AP4_File(AP4_ByteStream&amp;, bool) \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Core\/Ap4File.cpp:78:5\r\n    #52 0x542552 in main \/tmp\/Bento4-1.5.0-617\/Source\/C++\/Apps\/Mp42Aac\/Mp42Aac.cpp:242:32\r\n    #53 0x7f23fa0bf680 in __libc_start_main \/var\/tmp\/portage\/sys-libs\/glibc-2.23-r4\/work\/glibc-2.23\/csu\/..\/csu\/libc-start.c:289\r\n    #54 0x44f3f8 in _start (\/usr\/bin\/mp42aac+0x44f3f8)\r\n\r\nAddressSanitizer can not provide additional info.\r\nSUMMARY: AddressSanitizer: SEGV \/var\/tmp\/portage\/sys-libs\/glibc-2.23-r4\/work\/glibc-2.23\/string\/..\/sysdeps\/x86_64\/memcpy.S:71 \r\n==18215==ABORTING\r\n<\/font><\/pre>\n<p><strong>Affected version:<\/strong><br \/>\n1.5.0-617<\/p>\n<p><strong>Fixed version:<\/strong><br \/>\nN\/A<\/p>\n<p><strong>Commit fix:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/axiomatic-systems\/Bento4\/commit\/22192de5367fa0cee985917f092be4060b7c00b0\">https:\/\/github.com\/axiomatic-systems\/Bento4\/commit\/22192de5367fa0cee985917f092be4060b7c00b0<\/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-14642<\/p>\n<p><strong>Reproducer:<\/strong><br \/>\n<a href=\"https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00339-bento4-NULLptr-AP4_StdcFileByteStream_ReadPartial\">https:\/\/github.com\/asarubbo\/poc\/blob\/master\/00339-bento4-NULLptr-AP4_StdcFileByteStream_ReadPartial<\/a><\/p>\n<p><strong>Timeline:<\/strong><br \/>\n2017-09-08: bug discovered and reported to upstream<br \/>\n2017-09-14: blog post about the issue<br \/>\n2017-09-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 data-secret=\"1pEzjojxeO\" class=\"wp-embedded-content\"><p><a href=\"http:\/\/blogs.gentoo.org\/ago\/2017\/09\/14\/bento4-null-pointer-dereference-in-ap4_stdcfilebytestreamreadpartial-ap4stdcfilebytestream-cpp\/\">bento4: NULL pointer dereference in AP4_StdcFileByteStream::ReadPartial (Ap4StdCFileByteStream.cpp)<\/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\/09\/14\/bento4-null-pointer-dereference-in-ap4_stdcfilebytestreamreadpartial-ap4stdcfilebytestream-cpp\/embed\/#?secret=1pEzjojxeO\" data-secret=\"1pEzjojxeO\" width=\"600\" height=\"338\" title=\"&#8220;bento4: NULL pointer dereference in AP4_StdcFileByteStream::ReadPartial (Ap4StdCFileByteStream.cpp)&#8221; &#8212; agostino&#039;s blog\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: bento4 is a fast, modern, open source C++ toolkit for all your MP4 and MPEG DASH media format needs. The complete ASan output of the issue: # mp42aac $FILE out.aac ASAN:DEADLYSIGNAL ================================================================= ==18215==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 &hellip; <a href=\"https:\/\/blogs.gentoo.org\/ago\/2017\/09\/14\/bento4-null-pointer-dereference-in-ap4_stdcfilebytestreamreadpartial-ap4stdcfilebytestream-cpp\/\">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-zQ","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/2222"}],"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=2222"}],"version-history":[{"count":4,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/2222\/revisions"}],"predecessor-version":[{"id":2291,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/posts\/2222\/revisions\/2291"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/media?parent=2222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/categories?post=2222"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/ago\/wp-json\/wp\/v2\/tags?post=2222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}