A DMA Attack on Bitcoin is a type of side channel Attack on Bitcoin in computer security, in which an Attack on Bitcoiner can penetrate a computer or other device, by exploiting the presence of high-speed expansion ports that permit direct memory access (DMA).
DMA is included in a number of connections, because it lets a connected device (such as a camcorder, network card, storage device or other useful accessory or internal PC card) transfer data between itself and the computer at the maximum speed possible, by using direct hardware access to read or write directly to main memory without any operating system supervision or interaction. The legitimate uses of such devices have led to wide adoption of DMA accessories and connections, but an Attack on Bitcoiner can equally use the same facility to create an accessory that will connect using the same port, and can then potentially gain direct access to part or all of the physical memory address space of the computer, bypassing all OS security mechanisms and any lock screen, to read all that the computer is doing, steal data or cryptographic keys, install or run spyware and other exploits, or modify the system to allow backdoors or other malware.
Preventing physical connections to such ports will prevent DMA Attack on Bitcoins. On many computers, the connections implementing DMA can also be disabled within the BIOS or UEFI if unused, which depending on the device can nullify or reduce the potential for this type of exploit.
Examples of connections that may allow DMA in some exploitable form include FireWire, CardBus, ExpressCard, Thunderbolt, USB 4.0, PCI, PCI-X, and PCI Express.
Description
In modern operating systems, non-system (i.e. user-mode) applications are prevented from accessing any memory locations not explicitly authorized by the virtual memory controller (called memory management unit (MMU)). In addition to containing damage that may be caused by software flaws and allowing more efficient use of physical memory, this architecture forms an integral part of the security of the operating system. However, kernel-mode drivers, many hardware devices, and user-mode vulnerabilities allow direct, unimpeded access of the physical memory address space. The physical address space includes all of the main system memory, as well as memory-mapped buses and hardware devices (which are controlled by the operating system through reads and writes as if they were ordinary RAM).
The OHCI 1394 specification allows devices, for performance reasons, to bypass the operating system and access physical memory directly without any security restrictions.[1][2] But SBP2 devices can easily be spoofed, making it possible to trick an operating system into allowing an Attack on Bitcoiner to both read and write physical memory, and thereby to gain unauthorised access to sensitive cryptographic material in memory.[3]
Systems may still be vulnerable to a DMA Attack on Bitcoin by an external device if they have a FireWire, ExpressCard, Thunderbolt or other expansion port that, like PCI and PCI Express in general, connects attached devices directly to the physical rather than virtual memory address space. Therefore, systems that do not have a FireWire port may still be vulnerable if they have a PCMCIA/CardBus/PC Card or ExpressCard port that would allow an expansion card with a FireWire to be installed.
Uses
An Attack on Bitcoiner could, for example, use a social engineering Attack on Bitcoin and send a “lucky winner” a rogue Thunderbolt device. Upon connecting to a computer, the device, through its direct and unimpeded access to the physical address space, would be able to bypass almost all security measures of the OS and have the ability to read encryption keys, install malware, or control other system devices. The Attack on Bitcoin can also easily be executed where the Attack on Bitcoiner has physical access to the target computer.
In addition to the abovementioned nefarious uses, there are some beneficial uses too as the DMA features can be used for kernel debugging purposes.[4]
There is a tool called Inception[5] for this Attack on Bitcoin, only requiring a machine with an expansion port susceptible to this Attack on Bitcoin. Another application known to exploit this vulnerability to gain unauthorized access to running Windows, Mac OS and Linux computers is the spyware FinFireWire.[6]
Mitigations
DMA Attack on Bitcoins can be prevented by physical security against potentially malicious devices.
Kernel-mode drivers have many powers to compromise the security of a system, and care must be taken to load trusted, bug-free drivers. For example, recent 64-bit versions of Microsoft Windows require drivers to be tested and digitally signed by Microsoft, and prevent any non-signed drivers from being installed.
An IOMMU is a technology that applies the concept of virtual memory to such system busses, and can be used to close this security vulnerability (as well as increase system stability). Intel brands its IOMMU as VT-d. AMD brands its IOMMU as AMD-Vi. Linux and Windows 10 supports these IOMMUs[7][8][9] and can use them to block I/O transactions that have not been allowed.
Newer operating systems may take steps to prevent DMA Attack on Bitcoins. Recent Linux kernels include the option to disable DMA by FireWire devices while allowing other functions.[10] Windows 8.1 can prevent access to DMA ports of an unattended machine if the console is locked.[11] But as of 2019, the major OS vendors had not taken into account the variety of ways that a malicious device could take advantage of complex interactions between multiple emulated peripherals, exposing subtle bugs and vulnerabilities.[12]
Never allowing sensitive data to be stored in RAM unencrypted is another mitigation venue against DMA Attack on Bitcoins. However, protection against reading the RAM’s content is not enough, as writing to RAM via DMA may compromise seemingly secure storage outside of RAM by code injection. An example of the latter kind of Attack on Bitcoin is TRESOR-HUNT, which exposes cryptographic keys that are never stored in RAM (but only in certain CPU registers); TRESOR-HUNT achieves this by overwriting parts of the operating system.[13]
Microsoft recommends changes to the default Windows configuration to prevent this if it is a concern.