Download whitepaper (PDF 878 KB)

Download whitepaper (PDF 16 MB)

Introduction

In recent years, embedded software security has become a red-hot topic, attracting the attention of high profile security researchers from all around the globe. However, the quality of code is still far from perfect as long as its security is considered. For instance, the CVE-2017-5721 SMM Privilege Elevation vulnerability in the firmware could affect such scope of vendors like Acer, ASRock, ASUS, Dell, HP, GIGABYTE, Lenovo, MSI, Intel, and Fujitsu. This white paper is intended to describe how to detect a vulnerability in a motherboard firmware with the help of the following tools:

Intel DAL

UEFITool

CHIPSEC

RWEverything

and how to bypass the patch that fixes this vulnerability.

For those readers who need some background information, here is the list of helpful additional materials:

Preliminary stage of the research

Making a showcase stand

To make a showcase, we used the GA-Q170M-D3H motherboard with Intel Q170 Express chipset. The motherboard turned out to be a perfect choice for the research, due to the following reasons:

Firmware updates are available as a binary image. Therefore, there is no need for users to burden themselves with extracting firmware parts from .exe files, in contrast with some other vendors' devices. Note: In the scope of the research, we used the latest available firmware version – F22.

The firmware is based on AMI BIOS Aptio V widely used by motherboard and laptop manufacturers.

It is possible to enable the Intel Direct Connect Interface.

The most obvious question that may come to a reader's mind here is: ''What is the Intel Direct Connect Interface?" In a nutshell, the Intel Direct Connect Interface (the DCI) is a technology that allows low-level processor debugging without putting much effort in the process. The only thing needed to debug a target system is the Intel Skylake processor (6th gen. or higher) and USB 3.0 Debugging Cable, and, of course, USB 3.0 ports in both host and target systems. To operate with the interface one can use the Intel DFx Abstraction Layer (DAL) application available as a part of the Intel System Studio trial version. For more details, see "Intel DCI Secrets".

It is also necessary to install a CPU on the motherboard. The motherboard used in the scope of the research was equipped with Intel Core i3-6320. Of course, the DRAM is also needed to be installed. The assembled showcase stand looked this way (see Fig. 1).

As you can see on the picture, we have unsoldered the SPI flash memory (which stores the motherboard's firmware) and put it into SOIC8 adapter. Hence, if we occasionally "brick" the system we would be able to recover the original firmware image using the hardware programmer.

Enabling Intel DCI on a target system

There are two ways to turn on DCI: the first one is simple, the other is difficult, which is quite obvious.

Enabling Intel DCI. The easy way

If your system is based on System on Chip (SoC), you must be able to enable DCI using the BIOS Setup (see Fig. 2).

Another option is to use the INTEL-SA-00073 vulnerability that some motherboards have. This vulnerability allows enabling the DCI right from a target platform by writing just one byte to memory.

It turned out that GA-Q170M-D3H has no option to enable the DCI in BIOS Setup. In such a case it is worth using PCH Private Configuration Space while the system is running (see Fig. 3).

DCI Control Register (ECTRL) — Offset 4h

According to the documentation, the DCI activation is conducted by toggling the fourth bit of the ECTRL register. The bit is located in memory at SBREG_BAR + (0xB8 << 0x10) + 4. The showcase had installed Windows 10 Enterprise, that is why the RW-Everything tool was used. Unfortunately, it was not possible to enable the DCI with the help of the fourth bit, while the eighth one is set to value 1. By practical consideration, it was found out that the eighth bit stands for "Locked", which hinders the DCI during the system operation. Nonetheless, if a system register is empty, there are all chances to enable the debugging interface without any difficulties (see Fig. 4).

Enabling DCI. The difficult way

The DCI can be enabled by changing default settings of BIOS or PCH Straps (held inside the firmware image) with Intel Flash