SWAPGS Attack — New Speculative Execution Flaw Affects All Modern Intel CPUs A new variant of the Spectre (Variant 1) side-channel vulnerability has been discovered that affects all modern Intel CPUs, and probably some AMD processors as well, which leverage speculative execution for high performance, Microsoft and Red Hat warned. Identified as CVE-2019-1125, the vulnerability could allow unprivileged local attackers to access sensitive information stored in the operating system privileged kernel memory, including passwords, tokens, and encryption keys, that would otherwise be inaccessible. Speculative execution is a core component of modern microprocessor design that speculatively executes instructions based on assumptions that are considered likely to be true. If the assumptions come out to be valid, the execution continues, otherwise discarded. Such speculative executions also have side effects that are not restored when the CPU state is unwound, leading to information disclosure, which can then be accessed using side-channel attacks. Microsoft silently issued patches for the new speculative execution vulnerability in its July 2019 Patch Tuesday security update which was discovered and responsibly disclosed by researchers at security firm Bitdefender. According to a security advisory released today by Red Hat, the attack relies on speculatively executing unexpected SWAPGS instructions after a branch gets mispredicted. SWAPGS instruction is a privileged system instruction that swaps the values in the GS register with the MSR values and is only available on devices with x86-64 architecture. "This is achieved by abusing the fact that SWAPGS instruction can be executed speculatively. An attacker can force arbitrary memory dereferences in kernel, which leaves traces within the data caches. These signals can be picked-up by the attacker to infer the value located at the given kernel address." researchers at Bitdefender say. The SWAPGS attack breaks the Kernel Page-Table Isolation (KPTI) provided by modern CPUs and can be used to leak sensitive kernel memory from unprivileged user mode, Intel acknowledged. "It is possible that these conditional branches in the Linux kernel entry code may mis-speculate into code that will not perform the SWAPGS, resulting in a window of speculative execution during which the wrong GS is used for dependent memory operations," RedHat says in its advisory. According to Bitdefender researchers, the new attack bypasses all known mitigations implemented after the discovery of Spectre and Meltdown vulnerabilities in early 2018 that put practically every computer in the world at risk. Though the Linux kernel also contains a gadget which may be exploited to target Linux systems in an attack, researchers believe exploiting Linux operating systems could slightly be tougher than Windows computers. Since the attack can not be launched remotely, it is unlikely to cause mass malware infections, like EternalBlue was used for WannaCry; instead, it can be exploited as part of an extremely targeted attack. Affected users can address this issue through a software update for their operating systems that would mitigate how the CPU speculatively accesses memory. Meanwhile, Google has also prepared a patch to fix this vulnerability in its ChromeOS 4.19 with a soon-to-be-released update, describing the flaw as: "An attacker can train the branch predictor to speculatively skip the swapgs path for an interrupt or exception. If they initialize the GS register to a user-space value, if the swapgs is speculatively skipped, subsequent GS-related percpu accesses in the speculation window will be done with the attacker-controlled GS value. This could cause privileged memory to be accessed and leaked." In a statement AMD said: "Based on external and internal analysis, AMD believes it is not vulnerable to the SWAPGS variant attacks because AMD products are designed not to speculate on the new GS value following a speculative SWAPGS. For the attack that is not a SWAPGS variant, the mitigation is to implement our existing recommendations for Spectre variant 1."