{"id":19925,"date":"2022-08-16T20:34:34","date_gmt":"2022-08-16T16:34:34","guid":{"rendered":"https:\/\/me-en.kaspersky.com\/blog\/retbleed-vulnerability\/19925\/"},"modified":"2022-08-16T20:34:47","modified_gmt":"2022-08-16T16:34:47","slug":"retbleed-vulnerability","status":"publish","type":"post","link":"https:\/\/me-en.kaspersky.com\/blog\/retbleed-vulnerability\/19925\/","title":{"rendered":"Retbleed attack, or Spectre strikes back"},"content":{"rendered":"<p>In mid-July, researchers at the Swiss Federal Institute of Technology, Zurich, <a href=\"https:\/\/comsec.ethz.ch\/research\/microarch\/retbleed\/\" target=\"_blank\" rel=\"nofollow noopener\">published<\/a> a study describing a new attack that exploits vulnerabilities (or, if you prefer, features) in modern processors. The attack was dubbed Retbleed, and it derived from <a href=\"https:\/\/support.google.com\/faqs\/answer\/7625886\" target=\"_blank\" rel=\"nofollow noopener\">Retpoline<\/a> \u2013 a defense method against a certain type of Spectre attack. Essentially, the authors showed that its program-compilation technique \u2013 previously thought to be effective protection against a so-called Spectre Variant 2 attack \u2013 either works only occasionally or not at all. The research, like all previous work on hardware vulnerabilities in processors, is rather complex. In this article, we will, as usual, try not to dive deep into the maze of relevant scientific papers, but to describe the results in simple words. Let\u2019s start with some background information.\n<\/p>\n<h2>What is Spectre v2? Let\u2019s talk about branch prediction<\/h2>\n<p>\nMore than four years ago, in early 2018, two research papers <a href=\"https:\/\/meltdownattack.com\/\" target=\"_blank\" rel=\"nofollow noopener\">describing<\/a> the Spectre and Meltdown vulnerabilities were published. These are hardware vulnerabilities: a potential data theft attack is made possible by the way processors work. Since then, <a href=\"https:\/\/www.kaspersky.com\/blog\/spectre-meltdown-in-practice\/43525\/\" target=\"_blank\" rel=\"noopener nofollow\">several<\/a> more variants of Spectre have been discovered. Researchers have found more ways to attack a common class of vulnerabilities; that is, to use the processor\u2019s default functionality called \u201cbranch prediction\u201d for the attack.<\/p>\n<p>Branch prediction and speculative execution of instructions help improve processor performance significantly. In any program, execution of further steps often depends on the result of previous calculations. The simplest example is when a user enters a password to access some secret data. If the password is correct, the data is shown to the user. If the password is wrong, the user is prompted to try again. At the level of simple instructions for the CPU, this translates roughly into checking access rights to certain data in the RAM: if the necessary rights are confirmed, access to the data is granted; if not \u2013 denied.<\/p>\n<p>The processor can perform billions of such operations per second, and while a certain condition is being checked, it\u2019s often idle (loosely speaking \u2013 waiting for a user to enter a password, or for access rights to be checked). But what if we have it use this idle time to perform the calculations that happen after the most probable result of the check in advance? By the time our hypothetical user enters their hypothetical password, the calculation result will be ready, and the user will see their secret data a little faster.<\/p>\n<p>But how do you know which part of your code is most likely to be executed? From statistics related to previous executions of similar instructions, of course. If our user (please note, this is a highly theoretical and extremely simplified example) enters the correct password nine times out of 10, we can prepare their secret data in advance. If the password is incorrect, we just discard the results and take a little more time to display an error message.<\/p>\n<p>The authors of the 2018 paper described two variants of the Spectre attack, and Variant 2 (also known as Branch Target Injection) trains a branch predictor so that it performs the instructions we need, as in reading data that the attacker shouldn\u2019t have access to. Yes, these calculations are then discarded, but their result (the highly sensitive data) is temporarily stored in the cache \u2013 from where it can be stolen.<\/p>\n<p>This is an extremely complex attack. Firstly, the attacker has to be able to execute code on the system under attack, albeit without the desired privileges, i.e., without access to sensitive data. For example, a user could be persuaded to open a web page containing a malicious script in their browser. Secondly, the attacker needs software on the target system that includes code suitable for the attack. In the researchers\u2019 jargon, this is known as a \u201cgadget\u201d. The attack code trains the branch prediction system to speculatively execute this gadget. This causes it to access an area of memory inaccessible to the attacker. The secret data is placed in the CPU cache, from where it can be extracted very slowly \u2013 no more than tens of bits per second \u2013 by side-channel reading.<\/p>\n<p>Let\u2019s try to put it even simpler. The processor\u2019s built-in branch prediction system doesn\u2019t separate instructions from different programs, and a single program can be used to make the processor speculatively execute an instruction it\u2019s not supposed to run. Previously, this didn\u2019t appear to be a problem, as software cannot directly access data in the processor\u2019s cache in any case. But, as it turns out, by reading side-channels (which is a very complex mechanism: reconstructing data based only on information about the speed of responses to read requests), the data can be extracted.<\/p>\n<h2>Hang on. Spectre was discovered in 2018. Surely they\u2019ve patched it by now?<\/h2>\n<p>\nIt\u2019s not that easy with hardware vulnerabilities. First and foremost, even from this simplified description, it\u2019s clear that the vulnerability, though definitely hardware-based, requires certain conditions in the software to coincide for it to be exploited. If that\u2019s the case, why not just patch the software? That\u2019s much easier to do than upgrading hardware. It\u2019s also possible to partially fix the vulnerability in the processors through microcode updates. But a definitive solution to the problem can only be found in the release of new processors with modified hardware. Old ones in the meantime remain fully or partially vulnerable.<\/p>\n<p>There\u2019s another question that\u2019s extremely important in the context of Retbleed research. What would be the cost of a software or hardware patch? Every single method of \u201cclosing\u201d Spectre reduces performance. For example, the fairly obvious Indirect Branch Restricted Speculation (IBRS) system introduces additional permission checks during speculative code execution and prevents low-privilege programs from accessing highly sensitive data, making a Spectre attack impossible. But with hundreds of thousands or millions of such checks, CPU performance is bound to dip. How far? There\u2019s research <a href=\"https:\/\/www.phoronix.com\/scan.php?page=article&amp;item=3-years-specmelt&amp;num=1\" target=\"_blank\" rel=\"nofollow noopener\">showing<\/a> that a diverse set of patches for Spectre in a system led to a performance decrease of up to 25%.<\/p>\n<p>And here comes <a href=\"https:\/\/support.google.com\/faqs\/answer\/7625886\" target=\"_blank\" rel=\"nofollow noopener\">Retpoline<\/a>, a relatively simple protection method against Spectre proposed by Google engineers and used during software compilation. As suggested by the authors of the method, replacing some instructions in typical branching situations with others doesn\u2019t affect software operability, while it does make a Spectre attack impossible. An important advantage of Retpoline over IBRS and other protection methods is just a slight degradation of no more than 5% of performance.<\/p>\n<h2>What did the Retbleed study show?<\/h2>\n<p>\nBasically, this fresh research has shown that Retpoline\u2026 doesn\u2019t work! The return instructions that the Retpoline method relied on could also be exploited in a slightly modified scheme to trick (or maliciously train) the branch predictor. The authors have even recorded a video demonstrating the attack:<\/p>\n<p style=\"margin-bottom: 0\">\n<span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe class=\"youtube-player\" type=\"text\/html\" width=\"640\" height=\"390\" src=\"https:\/\/www.youtube.com\/embed\/dmSPvJxPm80?version=3&amp;rel=1&amp;fs=1&amp;showsearch=0&amp;showinfo=1&amp;iv_load_policy=1&amp;wmode=transparent\" frameborder=\"0\" allowfullscreen=\"true\"><\/iframe><\/span>\n<\/p>\n<p style=\"text-align: center\">A Retbleed attack demo on a Linux-based system.<\/p>\n<p>The video shows how a hashed super-user password is stolen by a program that doesn\u2019t have access to such data. Note that the video is highly accelerated: in real-time, the password theft on an Intel-based system takes a good hour-and-a-half! The results are summarized in the following table:<\/p>\n<div id=\"attachment_45156\" style=\"width: 1921px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/37\/2022\/08\/16203440\/retbleed-vulnerability-table.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-45156\" src=\"https:\/\/media.kasperskydaily.com\/wp-content\/uploads\/sites\/37\/2022\/08\/16203440\/retbleed-vulnerability-table.jpg\" alt=\"Summary list of processors tested for Retbleed attack possibility with Retpoline protection activated.\" width=\"1911\" height=\"480\" class=\"size-full wp-image-45156\"><\/a><p id=\"caption-attachment-45156\" class=\"wp-caption-text\">Summary list of processors tested for Retbleed attack possibility with Retpoline protection activated. <a href=\"https:\/\/comsec.ethz.ch\/wp-content\/files\/retbleed_sec22.pdf\" target=\"_blank\" rel=\"noopener nofollow\">Source<\/a>.<\/p><\/div>\n<p>As the table shows, not entirely new, but rather up-to-date AMD Zen 1 and Zen 2 (2017\u20132019) and Intel\u2019s Kaby Lake and Coffee Lake (2016\u20132017) processors are prone to a Retbleed attack. On the more modern AMD Zen 3 processors, as well as Intel Alder Lake and the earlier 9<sup>th<\/sup> generation processors, a Retbleed attack doesn\u2019t work. This is also due to implementation of Enhanced IBRS hardware protection in Intel processors.<\/p>\n<h2>Cost of protection<\/h2>\n<p>\nIf a Spectre attack is so difficult to perform, why defend against it at all? Indeed, in order to tailor Spectre to a real-world case (with real damage to the victim), many conditions need to be met: being able to execute code on the attacked system, having attack-prone software installed, and reliably pulling data from the cache (with a certain chance of reading with errors). We previously <a href=\"https:\/\/www.kaspersky.com\/blog\/spectre-meltdown-in-practice\/43525\/\" target=\"_blank\" rel=\"noopener nofollow\">wrote<\/a> that the most realistic attack was simulated in a Chrome browser where a potential attacker could, for example, extract saved passwords from the RAM. But this was resolved with a simple protection enhancement in the browser itself, just as with any other trivial bug.<\/p>\n<p>There\u2019s a probability that incremental progress in researching Spectre-like vulnerabilities someday will unexpectedly lead to the possibility of a mass attack on users\u2019 computers and servers. But when it comes to truly sensitive data, Spectre must be taken into consideration now.<\/p>\n<p>The most obvious scenario is an attack through hosting and distributed computing providers. A typical virtual server that you can rent for a reasonable sum from a random provider is essentially a program that runs beside other customers\u2019 virtual OSs on the same high-powered server. A virtual server subscriber can, by definition, run programs on it, but has no privileges to access its neighbors or the host, i.e., the controlling operating system. The separation of virtual environments and the inability to escape from your virtual space is a key security requirement for such service providers.<\/p>\n<p>At the same time, service providers are interested in having as many virtual systems running on the same server as possible without them causing problems for each other. This is the key to the earliest payback on expensive hardware. That said, all Spectre patches (that <em>actually work<\/em>) reduce performance, and therefore reduce ISP revenue. But providers can\u2019t ignore the problem either, because successfully stealing sensitive data doesn\u2019t even leave a trace!<\/p>\n<p>So when Retpoline was proposed, many grabbed at it like a lifeline to fight the new scourge. But, by January 2018, there were doubts about how reliable this method of defense was. <a href=\"https:\/\/lkml.org\/lkml\/2018\/1\/22\/598\" target=\"_blank\" rel=\"nofollow noopener\">A discussion<\/a> on a Linux kernel developers\u2019 mailing list shows a number of complaints about Retpoline (the author is unflattering about other methods as well). At the same time, Linus Torvalds, the creator and main custodian of Linux, <a href=\"https:\/\/lkml.org\/lkml\/2018\/1\/21\/192\" target=\"_blank\" rel=\"nofollow noopener\">made clear<\/a> (in his typical sharp manner) that Retpoline is generally sufficient.<\/p>\n<p>The authors of Retbleed highlight Torvalds on his being judgmental by placing his categorical quote at the beginning of the paper. They also calculated the \u201ccost\u201d of real-world protection for vulnerable processors that cannot be fixed at the hardware level. Patches in the Linux kernel have resulted in performance drops of up to 39% for Intel processors and 14% for AMD processors.<\/p>\n<p>AMD processors turned out to be vulnerable in their own way, and the researchers discovered a phenomenon they called \u201cPhantom JMPs\u201d. It turned out that, under certain conditions, it\u2019s possible to make a branch prediction system execute an arbitrary instruction even if it\u2019s not there in the code under attack. Because of this, the authors had to release a brief one-page <a href=\"https:\/\/comsec.ethz.ch\/wp-content\/files\/retbleed_addendum_sec22.pdf\" target=\"_blank\" rel=\"nofollow noopener\">addendum<\/a> to the study. They stipulate, however, that exploiting this vulnerability to do real damage is even more difficult than with traditional Spectre V2.<\/p>\n<h2>What now?<\/h2>\n<p>\nFor ordinary users, the threat of Spectre attacks remains entirely virtual. Preventive patches from operating-system developers will suffice. In Windows, by the way, effective IBRS protection is enabled by default. New Linux kernel patches will possibly lead to performance degradation, which may be most noticeable in business solutions where computer hardware is squeezed to the limits.<\/p>\n<p>The problem is compounded by the fact that there are many Spectre variants. Retbleed could also be considered a separate variant, which works differently on processors from different manufacturers. AMD and Intel have acknowledged Retbleed as a separate vulnerability and will possibly come up with some hardware solution for it. Corporations will move to new hardware where protective measures are implemented, finding a balance between performance and security. Unfortunately, all software patches have the biggest impact on the performance of relatively old processors. Not only does software become more demanding over time, but there\u2019s also this \u201cpenalty\u201d on speculative execution.<\/p>\n<p>If you look at the problem from a bird\u2019s-eye view, this is nothing new. Developers offer a performance-enhancing solution without thinking about security. Sooner or later (later in this case: speculative execution started in the mid-1990s), it comes back to haunt everyone, and security measures have their cost, but eventually new solutions are found, and the hi-tech industry moves on.<\/p>\n<p>The surprise was the discovery of the problem in the hardware: it\u2019s not as easy to fix as in software. And this isn\u2019t a simple bug, but rather a poor (from the security perspective) approach adopted by the industry many years ago. Let\u2019s hope that processor developers come up with new methods for safe and powerful computing before the black swan of an extremely dangerous hardware attack flies over us \u2014 one that threatens everyone, is widely known about, and can only be solved by replacing hardware completely.<\/p>\n<input type=\"hidden\" class=\"category_for_banner\" value=\"mdr\">\n","protected":false},"excerpt":{"rendered":"<p>Using a recent study on hardware vulnerabilities in processors as an example, we contemplate the cost of security.<\/p>\n","protected":false},"author":665,"featured_media":19928,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1318,1916],"tags":[1616,268],"class_list":{"0":"post-19925","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-business","8":"category-enterprise","9":"tag-spectre","10":"tag-vulnerabilities"},"hreflang":[{"hreflang":"en-ae","url":"https:\/\/me-en.kaspersky.com\/blog\/retbleed-vulnerability\/19925\/"},{"hreflang":"en-in","url":"https:\/\/www.kaspersky.co.in\/blog\/retbleed-vulnerability\/24459\/"},{"hreflang":"en-us","url":"https:\/\/usa.kaspersky.com\/blog\/retbleed-vulnerability\/26903\/"},{"hreflang":"en-gb","url":"https:\/\/www.kaspersky.co.uk\/blog\/retbleed-vulnerability\/24808\/"},{"hreflang":"es","url":"https:\/\/www.kaspersky.es\/blog\/retbleed-vulnerability\/27515\/"},{"hreflang":"ru","url":"https:\/\/www.kaspersky.ru\/blog\/retbleed-vulnerability\/33847\/"},{"hreflang":"tr","url":"https:\/\/www.kaspersky.com.tr\/blog\/retbleed-vulnerability\/10936\/"},{"hreflang":"x-default","url":"https:\/\/www.kaspersky.com\/blog\/retbleed-vulnerability\/45155\/"},{"hreflang":"fr","url":"https:\/\/www.kaspersky.fr\/blog\/retbleed-vulnerability\/19298\/"},{"hreflang":"de","url":"https:\/\/www.kaspersky.de\/blog\/retbleed-vulnerability\/29163\/"},{"hreflang":"ru-kz","url":"https:\/\/blog.kaspersky.kz\/retbleed-vulnerability\/25346\/"},{"hreflang":"en-au","url":"https:\/\/www.kaspersky.com.au\/blog\/retbleed-vulnerability\/30864\/"},{"hreflang":"en-za","url":"https:\/\/www.kaspersky.co.za\/blog\/retbleed-vulnerability\/30572\/"}],"acf":[],"banners":"","maintag":{"url":"https:\/\/me-en.kaspersky.com\/blog\/tag\/vulnerabilities\/","name":"vulnerabilities"},"_links":{"self":[{"href":"https:\/\/me-en.kaspersky.com\/blog\/wp-json\/wp\/v2\/posts\/19925","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/me-en.kaspersky.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/me-en.kaspersky.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/me-en.kaspersky.com\/blog\/wp-json\/wp\/v2\/users\/665"}],"replies":[{"embeddable":true,"href":"https:\/\/me-en.kaspersky.com\/blog\/wp-json\/wp\/v2\/comments?post=19925"}],"version-history":[{"count":1,"href":"https:\/\/me-en.kaspersky.com\/blog\/wp-json\/wp\/v2\/posts\/19925\/revisions"}],"predecessor-version":[{"id":19927,"href":"https:\/\/me-en.kaspersky.com\/blog\/wp-json\/wp\/v2\/posts\/19925\/revisions\/19927"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/me-en.kaspersky.com\/blog\/wp-json\/wp\/v2\/media\/19928"}],"wp:attachment":[{"href":"https:\/\/me-en.kaspersky.com\/blog\/wp-json\/wp\/v2\/media?parent=19925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/me-en.kaspersky.com\/blog\/wp-json\/wp\/v2\/categories?post=19925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/me-en.kaspersky.com\/blog\/wp-json\/wp\/v2\/tags?post=19925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}