{"id":13011,"date":"2025-01-15T12:25:02","date_gmt":"2025-01-15T19:25:02","guid":{"rendered":"https:\/\/mattfife.com\/?p=13011"},"modified":"2025-01-01T12:32:26","modified_gmt":"2025-01-01T19:32:26","slug":"google-implements-spatial-memory-safety-in-c","status":"publish","type":"post","link":"https:\/\/mattfife.com\/?p=13011","title":{"rendered":"Google implements Spatial Memory Safety in C++"},"content":{"rendered":"\n<p>After analyzing nearly 10 years of CVEs, Google researchers calculated that at least 40% of\u00a0<a href=\"https:\/\/thenewstack.io\/out-with-c-and-c-in-with-memory-safety\/\">safety exploits<\/a>\u00a0in C++ were related to\u00a0<a href=\"https:\/\/thenewstack.io\/out-with-c-and-c-in-with-memory-safety\/\">spatial memory exploits<\/a>\u00a0like writing to an out-of-bounds memory location.<\/p>\n\n\n\n<p><a href=\"https:\/\/thenewstack.io\/google-spends-1-million-to-make-rust-c-interoperable\/\">Google researchers<\/a>\u00a0showed they were able to \u201cretrofit\u201d spatial safety onto their C++ codebases, and to do it with a surprisingly low impact on performance. They used straightforward strategies such as bounds checking buffers and data structures &#8211; as is done in other languages and released a new, safer <a href=\"https:\/\/libcxx.llvm.org\/Hardening.html\">Hardened libc++<\/a>.\u00a0<\/p>\n\n\n\n<p>The results show up in this chart of segfaults across the entire fleet of computers before and after using the improvements. Their internal red team testing results were also much improved, uncovered over 1000 bugs and likely prevent 1000-2000 new bugs each year based on current development rate.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"206\" data-attachment-id=\"13012\" data-permalink=\"https:\/\/mattfife.com\/?attachment_id=13012\" data-orig-file=\"https:\/\/i0.wp.com\/mattfife.com\/wp-content\/themes\/mattTheme\/headerimgs\/2025\/01\/image.png?fit=1600%2C516&amp;ssl=1\" data-orig-size=\"1600,516\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/mattfife.com\/wp-content\/themes\/mattTheme\/headerimgs\/2025\/01\/image.png?fit=300%2C97&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/mattfife.com\/wp-content\/themes\/mattTheme\/headerimgs\/2025\/01\/image.png?fit=640%2C206&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/mattfife.com\/wp-content\/themes\/mattTheme\/headerimgs\/2025\/01\/image.png?resize=640%2C206&#038;ssl=1\" alt=\"\" class=\"wp-image-13012\" srcset=\"https:\/\/i0.wp.com\/mattfife.com\/wp-content\/themes\/mattTheme\/headerimgs\/2025\/01\/image.png?resize=1024%2C330&amp;ssl=1 1024w, https:\/\/i0.wp.com\/mattfife.com\/wp-content\/themes\/mattTheme\/headerimgs\/2025\/01\/image.png?resize=300%2C97&amp;ssl=1 300w, https:\/\/i0.wp.com\/mattfife.com\/wp-content\/themes\/mattTheme\/headerimgs\/2025\/01\/image.png?resize=768%2C248&amp;ssl=1 768w, https:\/\/i0.wp.com\/mattfife.com\/wp-content\/themes\/mattTheme\/headerimgs\/2025\/01\/image.png?resize=1536%2C495&amp;ssl=1 1536w, https:\/\/i0.wp.com\/mattfife.com\/wp-content\/themes\/mattTheme\/headerimgs\/2025\/01\/image.png?resize=604%2C195&amp;ssl=1 604w, https:\/\/i0.wp.com\/mattfife.com\/wp-content\/themes\/mattTheme\/headerimgs\/2025\/01\/image.png?w=1600&amp;ssl=1 1600w, https:\/\/i0.wp.com\/mattfife.com\/wp-content\/themes\/mattTheme\/headerimgs\/2025\/01\/image.png?w=1280&amp;ssl=1 1280w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\n\n\n\n<p>Here&#8217;s a\u00a0<a href=\"https:\/\/security.googleblog.com\/2024\/11\/retrofitting-spatial-safety-to-hundreds.html#fn1\">blog post about their results<\/a>.<\/p>\n\n\n\n<p>Articles:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/thenewstack.io\/google-retrofits-spatial-memory-safety-onto-c\/\">https:\/\/thenewstack.io\/google-retrofits-spatial-memory-safety-onto-c\/<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/security.googleblog.com\/2024\/11\/retrofitting-spatial-safety-to-hundreds.html\">https:\/\/security.googleblog.com\/2024\/11\/retrofitting-spatial-safety-to-hundreds.html<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>After analyzing nearly 10 years of CVEs, Google researchers calculated that at least 40% of\u00a0safety exploits\u00a0in C++ were related to\u00a0spatial memory exploits\u00a0like writing to an out-of-bounds memory location. Google researchers\u00a0showed they were able to \u201cretrofit\u201d spatial safety onto their C++ codebases, and to do it with a surprisingly low impact on performance. They used straightforward strategies such as bounds checking buffers and data structures &#8211; as is done in other languages and released a new, safer Hardened libc++.\u00a0 The results&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/mattfife.com\/?p=13011\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[9,7,5],"tags":[],"class_list":["post-13011","post","type-post","status-publish","format-standard","hentry","category-cool","category-technicalprogramming","category-technical"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4WECr-3nR","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/posts\/13011","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mattfife.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13011"}],"version-history":[{"count":1,"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/posts\/13011\/revisions"}],"predecessor-version":[{"id":13013,"href":"https:\/\/mattfife.com\/index.php?rest_route=\/wp\/v2\/posts\/13011\/revisions\/13013"}],"wp:attachment":[{"href":"https:\/\/mattfife.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13011"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mattfife.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13011"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mattfife.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13011"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}