{"id":83,"date":"2014-12-08T16:37:00","date_gmt":"2014-12-08T16:37:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2014\/12\/08\/visual-studio-2015-preview-work-in-progress-security-feature\/"},"modified":"2019-02-18T18:05:09","modified_gmt":"2019-02-18T18:05:09","slug":"visual-studio-2015-preview-work-in-progress-security-feature","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/visual-studio-2015-preview-work-in-progress-security-feature\/","title":{"rendered":"Visual Studio 2015 Preview: Work-in-Progress Security Feature"},"content":{"rendered":"<h2><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: medium\">Background<\/span><\/p>\n<p style=\"text-align: left\"><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">The Preview for Visual Studio 2015 was announced on November 12, 2014.&nbsp; It includes a new, work-in-progress feature, called <strong>Control Flow Guard<\/strong>.&nbsp; By simply adding a new option to your Project, the Visual C++ compiler will inject extra security checks into your binaries.&nbsp; These will detect attempts to hijack your code.&nbsp; The check will stop execution of your code, before the hijacker can do damage to your data or PC.<\/span><\/p>\n<p style=\"text-align: left\"><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">This blog explains how you can experiment with <strong>Control Flow Guard <\/strong>in the Preview. &nbsp;Your feedback will determine how we move forward in our release planning.<\/span><\/p>\n<p style=\"text-align: left\"><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">For the rest of this post, I&rsquo;ll abbreviate Control Flow Guard to <strong>CFG<\/strong>.<\/span><\/p>\n<h2><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: medium\">How to Enable CFG<\/span><\/h2>\n<p><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">If you are building your project <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">from the command-line, as in: <span style=\"color: #0000ff\">cl test.cpp<\/span> then tell both compiler (via <span style=\"color: #0000ff\">\/d2guard4<\/span>) and linker (via <span style=\"color: #0000ff\">\/guard:cf<\/span>) <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">to add CFG instrumentation, as follows:&nbsp; <span style=\"color: #0000ff\">cl \/d2guard4&nbsp; test.cpp &nbsp;\/link \/guard:cf<\/span><\/span>\n<span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">(Yes, <span style=\"color: #0000ff\">\/d2guard4<\/span> is a strange name.&nbsp; Going forward, we will change it &ndash; likely to <span style=\"color: #0000ff\">\/guard:cf<\/span>, where &ldquo;cf&rdquo; stands for &ldquo;Control Flow&rdquo;.&nbsp; But that is for the future)<\/span>\n<span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">If you are building your project within Visual Studio, just make the corresponding changes in your Project&rsquo;s Property Pages:<\/span>\n<span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">So, for the compiler, click through the sequence: <span style=\"color: #0000ff\">PROJECT|Properties|Configuration Properties|C\/C++|Command Line|Additional Options<\/span>.&nbsp; In the resulting window, add <span style=\"color: #0000ff\">\/d2guard4<\/span><\/span>\n<span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">Similarly, for the linker, click through the sequence: <span style=\"color: #0000ff\">PROJECT|Properties|Configuration Properties|Linker|Command Line|Additional Options<\/span>.&nbsp; In the resulting window, add <span style=\"color: #0000ff\">\/guard:cf<\/span><\/span>\n<span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">That&rsquo;s all there is to it.&nbsp; You don&rsquo;t need to change any source code &ndash; no restructuring, no annotations, nothing.&nbsp;The compiler and linker do all of the heavy lifting required &ndash; you simply direct them to do so with these new switches.<\/span><\/p>\n<h2><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: medium\">How to Tell If a Binary Is CFG&rsquo;d?<\/span><\/h2>\n<p><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">Run the <span style=\"color: #0000ff\">dumpbin <\/span><\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">tool, and specify the <span style=\"color: #0000ff\">\/headers<\/span> and <span style=\"color: #0000ff\">\/loadconfig<\/span> options.&nbsp; <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">With our running example, we would say:&nbsp;<\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\"><span style=\"color: #0000ff\">dumpbin \/headers \/loadconfig test.exe<\/span>.&nbsp; <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">I have extracted the relevant sections of output and highlighted&nbsp;the 3 flags <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">to check-for in <span style=\"color: #0000ff\">blue<\/span>, below:<\/span>\n<span style=\"font-family: courier new,courier;font-size: small\">OPTIONAL HEADER VALUES<br \/><\/span><span style=\"font-family: courier new,courier;font-size: small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10B magic # (PE32)<br \/><\/span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style=\"font-family: courier new,courier;font-size: small\">\/\/ skipped fields here<br \/><\/span><span style=\"font-family: courier new,courier;font-size: small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; C140 DLL characteristics<br \/><\/span><span style=\"font-family: courier new,courier;font-size: small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dynamic base<br \/><\/span><span style=\"font-family: courier new,courier;font-size: small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NX compatible<br \/><\/span><span style=\"color: #0000ff;font-family: courier new,courier;font-size: small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Guard<\/span>\n&nbsp;<span style=\"font-family: courier new,courier;font-size: small\">Section contains the following load config:<br \/><\/span><span style=\"font-family: courier new,courier;font-size: small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0000005C <\/span><span style=\"font-family: courier new,courier;font-size: small\">size<br \/><\/span><span style=\"font-family: courier new,courier;font-size: small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 004271C0 <\/span><span style=\"font-family: courier new,courier;font-size: small\">Security Cookie<br \/><\/span><span style=\"font-family: courier new,courier;font-size: small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 00425120 <\/span><span style=\"font-family: courier new,courier;font-size: small\">Safe Exception Handler Table<br \/><\/span><span style=\"font-family: courier new,courier;font-size: small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 19 <\/span><span style=\"font-family: courier new,courier;font-size: small\">Safe Exception Handler Count<br \/><\/span><span style=\"font-family: courier new,courier;font-size: small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0041D128 <\/span><span style=\"font-family: courier new,courier;font-size: small\">Guard CF address of check-function pointer<br \/><\/span><span style=\"font-family: courier new,courier;font-size: small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 00000000 <\/span><span style=\"font-family: courier new,courier;font-size: small\">Reserved<br \/><\/span><span style=\"font-family: courier new,courier;font-size: small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0041D1A8 <\/span><span style=\"font-family: courier new,courier;font-size: small\">Guard CF function table<br \/><\/span><span style=\"font-family: courier new,courier;font-size: small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A8 <\/span><span style=\"font-family: courier new,courier;font-size: small\">Guard CF function count<br \/><\/span><span style=\"font-family: courier new,courier;font-size: small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 00003500 <\/span><span style=\"font-family: courier new,courier;font-size: small\">Guard Flags<br \/><\/span><span style=\"font-family: courier new,courier;font-size: small\"><span style=\"color: #0000ff\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CF Instrumented<\/span><br \/><\/span><span style=\"color: #0000ff;font-family: courier new,courier;font-size: small\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FID table present<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"font-family: courier new,courier;font-size: small\">Protect delayload IAT<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><span style=\"font-family: courier new,courier;font-size: small\">Delayload IAT in its own section<\/span>&nbsp;<\/p>\n<h2><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: medium\">Feedback Please!<\/span><\/h2>\n<p><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">We would like you to try out this <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">feature, and give us feedback on what you find:<\/span><\/p>\n<ul>\n<li><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">Is CFG easy to use?<\/span><\/li>\n<li><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">Is CFG easy to understand?<\/span><\/li>\n<li><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">What&rsquo;s the impact?&nbsp; Larger binaries?&nbsp; Slight <em>hit <\/em><\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">on runtime speed?&nbsp; Did it trap any <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">attacks?<\/span><\/li>\n<li><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">How can we improve CFG?<\/span><\/li>\n<\/ul>\n<h2><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: medium\">How Does CFG Work?<\/span><\/h2>\n<p><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">By supplying <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">unlikely\/unusual\/extreme data to a running program, an attacker attempts to <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">make it do something that was never intended.&nbsp; <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">For example, providing more input than expected, an attacker may <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">over-run the area reserved by a program to hold the response.&nbsp; (This is an attack called &ldquo;buffer overrun&rdquo;, <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">or &ldquo;buffer overflow&rdquo;).&nbsp; Thereafter, the <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">program might execute an indirect-call instruction &ndash; but instead of jumping to <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">the location originally intended, it now jumps to a different location whose <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">code is controlled by the attacker.<\/span>\n<span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">Note that such an attack exploits a <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">vulnerability &ndash; a bug &ndash; in the original program.&nbsp; This vulnerability is not the computer&rsquo;s <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">fault; it&rsquo;s a fault on the part of the team who wrote the code.&nbsp; That said, spotting and closing such <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">vulnerabilities can be very difficult and time-consuming.<\/span>\n<span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">CFG<strong> <\/strong>comes to our rescue in these situations, as follows.&nbsp; Whilst compiling and linking code, it analyzes <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">and discovers every location that any indirect-call instruction can reach.&nbsp; It builds that knowledge into the binaries <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">(in extra data structures &ndash; the ones mentioned in a <span style=\"color: #0000ff\">dumpbin <\/span><\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\"><span style=\"color: #0000ff\">\/loadconfig<\/span> display).&nbsp; It also <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">injects a check, before every indirect-call in your code, that ensures the <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">target is one of those expected, safe, locations.&nbsp; If that check fails at runtime, the Operating <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">System closes the program.<\/span>\n<span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">So, even though the original code <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">contained a bug that was exploitable by an attacker; and even though the <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">authors of the code were not aware of that bug, and had not fixed it; and even <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">though an attacker succeeded in his first steps to exploit the security hole; <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">nonetheless, CFG will stop the attack going on to cause subsequent damage.<\/span><\/p>\n<h2><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: medium\">Must I <em>CFG<\/em> Everything?<\/span><\/h2>\n<p><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">You don&rsquo;t need to <em>CFG<\/em> every part of your code.&nbsp; A mixture of CFG&rsquo;d and non-CFG&rsquo;d code will <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">execute just fine, but the non-CFG&rsquo;d parts won&rsquo;t, of course, include any <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">injected checks &ndash; so won&rsquo;t stop attack vectors through their indirect-calls.<\/span>\n<span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">Remember the adage: &ldquo;a chain is <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">only as strong as its weakest link&rdquo;.&nbsp; So <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">try to CFG as much of your code as you have access to.<\/span><\/p>\n<h2><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: medium\">What Versions of Windows Do I Need?<\/span><\/h2>\n<p><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">CFG operation depends upon it <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">running on a &ldquo;CFG-Aware&rdquo; version of the Windows Operating System.&nbsp; At the current time, CFG is present in the <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">x86 and x64 versions, for Desktop and Server, of the following releases:<\/span><\/p>\n<ul>\n<li><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">Windows 10 Technical Preview<\/span><\/li>\n<li><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">Windows 8.1 Update<\/span><\/li>\n<\/ul>\n<h2><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: medium\">What If I Run on a CFG-Unaware Version of Windows?<\/span><\/h2>\n<p><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">Your guarded code will execute <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">ok.&nbsp; But of course it won&rsquo;t benefit from CFG <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">security &ndash; you need to be running on a CFG-Aware version of the Windows <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">Operating System for that.&nbsp; In fact, the <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">extra checks in your guarded code will burn a few cycles before automatically being <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">turned around as successful, so you might even detect a small dip in <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">performance in these scenarios.<\/span><\/p>\n<h2><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: medium\">Are Libraries CFG&rsquo;d?<\/span><\/h2>\n<p><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">For this experimental release of <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">CFG, we have not provided CFG&rsquo;d versions of the C or C++ libraries.&nbsp; These will be included into future releases.<\/span><\/p>\n<h2><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: medium\">History<\/span><\/h2>\n<p><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">The technology that supports CFG is <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">conceptually simple: ensure that all indirect-calls result in a jump to legal <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">targets.&nbsp; Similar techniques have been <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">prototyped, analyzed and reported over the past few years.&nbsp; For example, the team from Microsoft&rsquo;s <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">Cambridge Research center described <a href=\"http:\/\/research.microsoft.com\/apps\/pubs\/default.aspx?id=101332\">an early variant of their work<\/a>, which later became CFG.<\/span>\n<span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">Minimising the runtime impact of <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">CFG checks, while ensuring backwards compatibility, is a major <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">software-engineering challenge.&nbsp; Not only <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">do we hand-craft the very best sequence of instructions for each check, we also <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">invoke the compiler&rsquo;s analysis to elide (ie, <em>optimize-away) <\/em>any checks where it can prove that a specific indirect-call <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">is inherently safe.<\/span>\n<span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">In addition, the Operating System &ndash; <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">both Memory Manager and Runtime Loader &ndash; play a crucial role in guaranteeing <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">the correctness of CFG.&nbsp; Any bug in CFG itself <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">would of course defeat the entire feature!&nbsp; <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">We have lost count of how many dozens, or hundreds, of researchers and <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">engineers within Microsoft have been impacted by CFG.&nbsp; We hope you like the outcome of all this hard <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">work, carried on in secret, over the past several years!<\/span><\/p>\n<h2><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: medium\">And More<\/span><\/h2>\n<p><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">CFG monitors and checks certain <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">aspects of a program&rsquo;s &ldquo;Control Flow&rdquo;&nbsp; &#8211; <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">ie, where execution changes from straight sequential, one-after-another instruction.&nbsp; That explains the &ldquo;CF&rdquo; abbreviation you may <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">have noticed in the notes above.&nbsp;<\/span>\n<span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">CFG can be viewed as an <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">exploit-mitigation technology, extending previous steps with <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/8dbf701c.aspx\">\/GS<\/a>, <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\"><a href=\"http:\/\/windows.microsoft.com\/en-us\/windows-vista\/what-is-data-execution-prevention\">DEP<\/a>&nbsp;<\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">and <a href=\"http:\/\/www.microsoft.com\/security\/sir\/strategy\/default.aspx#!section_3_3\">ASLR<\/a>.<\/span>\n<span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">We are hopeful that this technology <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">will raise the bar of difficulty faced by hackers trying to attack your PCs and <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">code.<\/span>\n<span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">In future, we may extend the <\/span><span style=\"font-family: tahoma,arial,helvetica,sans-serif;font-size: small\">technique to provide even stronger runtime checking.<\/span><\/p>\n<p>&nbsp;<\/p>\n<\/h2>\n","protected":false},"excerpt":{"rendered":"<p>Background The Preview for Visual Studio 2015 was announced on November 12, 2014.&nbsp; It includes a new, work-in-progress feature, called Control Flow Guard.&nbsp; By simply adding a new option to your Project, the Visual C++ compiler will inject extra security checks into your binaries.&nbsp; These will detect attempts to hijack your code.&nbsp; The check will [&hellip;]<\/p>\n","protected":false},"author":271,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-83","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus"],"acf":[],"blog_post_summary":"<p>Background The Preview for Visual Studio 2015 was announced on November 12, 2014.&nbsp; It includes a new, work-in-progress feature, called Control Flow Guard.&nbsp; By simply adding a new option to your Project, the Visual C++ compiler will inject extra security checks into your binaries.&nbsp; These will detect attempts to hijack your code.&nbsp; The check will [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/83","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/271"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=83"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/83\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=83"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=83"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=83"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}