Skip to content
Memory corruption Write-up Advanced

Binarly Finds Six High Severity Firmware Vulnerabilities In HP Enterprise Devices

Six high-severity firmware vulnerabilities in HP enterprise devices allow arbitrary code execution in System Management Mode (SMM) due to memory corruption and improper input validation. An attacker with code execution in the DXE phase could exploit these to escalate privileges to SMM and execute arbitrary code.

Binarly efiXplorer Team Follow

Published on binarly.io

The Binarly security research team has had a busy year finding, documenting and helping to fix high-impact vulnerabilities affecting multiple enterprise vendors. In this blog, we provide an in-depth look at some of the vulnerabilities we discussed at the Black Hat 2022 conference affecting HP EliteBook devices.

Binarly efiXplorer Team, on binarly.io

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 8 min read.

Context

This write-up covers six high-severity firmware vulnerabilities that the Binarly efiXplorer Team found in HP enterprise devices, primarily HP EliteBook laptops, with the same issues also present in multiple additional HP product lines. The vulnerabilities were discussed at Black Hat 2022, and the disclosure was published on 8 September 2022, coordinated with the HP PSIRT team under advisory HPSBHF03806.

All six are arbitrary code execution issues related to System Management Mode (SMM). SMM is the highest-privilege execution environment on x86 platforms, often called ring -2. Code running there is invisible to the operating system and survives anything the OS does. The vulnerable code sits in SMI handlers: firmware routines that the OS or DXE-phase code invokes through software SMIs, passing data in a Communication Buffer (CommBuffer). The handler is supposed to validate that buffer before touching it. In each of these cases, that validation was missing or incomplete.

The six issues break down as follows:

Vulnerability BRLY ID CVE ID CVSS score
SMM Memory Corruption (Arbitrary Code Execution) BRLY-2022-010 CVE-2022-23930 8.2 High
SMM Memory Corruption (Arbitrary Code Execution) BRLY-2022-011 CVE-2022-31644 7.5 High
SMM Memory Corruption (Arbitrary Code Execution) BRLY-2022-012 CVE-2022-31645 8.2 High
SMM Memory Corruption (Arbitrary Code Execution) BRLY-2022-013 CVE-2022-31646 8.2 High
SMM Memory Corruption (Arbitrary Code Execution) BRLY-2021-046 CVE-2022-31640 7.5 High
SMM Memory Corruption (Arbitrary Code Execution) BRLY-2021-047 CVE-2022-31641 7.5 High

At the time of writing, some HP enterprise devices (laptops and desktops) had still not received updates to patch these vulnerabilities, despite them having been publicly disclosed for over a month. Binarly's FwHunt integration with the Linux Vendor Firmware Service (LVFS) makes those gaps visible, as shown in the first figure.

Figure 1
Figure 1 From the original on binarly.io

Binarly's telemetry shows the same effect at scale: according to Binarly Platform data based on a study of enterprise-grade vendors, approximately 20% of firmware updates contain at least two or three previously disclosed known vulnerabilities.

Setup

The research was carried out by the Binarly efiXplorer Team. The Binarly Platform applies semantic properties and lightweight code checkers to firmware images, and FwHunt is Binarly's rule-based detection tool. FwHunt rules for these HP vulnerabilities are published in Binarly's GitHub repository and are also pushed to LVFS. No accounts, roles or specific tool versions are described in the report.

The relevant precondition for exploitation is execution context. Some of these SMI handlers cannot be reached from the operating system at all, because the handler can be unregistered before the OS boots. An attacker who can already execute code in the DXE phase can exploit such handlers in the window between SMI handler registration and unregistration, and use them to escalate to SMM. Separately, non-SMM DXE runtime drivers and applications are attractive targets: a malicious DXE driver can bypass Secure Boot and influence further boot stages, and a firmware implant is the final goal for an attacker seeking long-term persistence, whether as a modified legitimate module or a standalone driver.

Finding it

The size of the buffer, which is used for the validation, is not used further and is not checked against an expected value or range, allowing a partial bypass of the validation.

BRLY-2022-011, BRLY-2022-012 and BRLY-2022-013 share this nature: out-of-bounds write primitives built on direct memory manipulation API functionality. The team notes that all three were most likely caused by similar coding practices applied by the same firmware development team.

Exploitation

Step 1: Stack-based buffer overflow via unsanitised CommBuffer (BRLY-2022-010 / CVE-2022-23930, CWE-121)

A lack of sanitisation of the CommBuffer data allows an attacker to write an arbitrary controlled data buffer, which leads to arbitrary code execution in SMM. The figure below shows the vulnerable primitive.

Fig 2
Fig 2 From the original on binarly.io

Step 2: Bypass pointer validation with a controlled size (BRLY-2022-011 / CVE-2022-31644, CWE-787)

The Communication Buffer passed into this SMI handler contains two nested pointers: a pointer to a buffer and a pointer to its size. Both pointers are validated to point into SMRAM. However, the size of the buffer, which is what the validation relies on, is not used further and is never checked against an expected value or range. An attacker can therefore partially bypass the validation, for example by specifying:

Text
*(QWORD *)*CommBuffer = SMRAM_BASE - 1
size_ptr = 1 byte

With the buffer pointer placed one byte below SMRAM and a size of one byte, the validation is partially bypassed and the operation that follows reaches outside the intended region.

Fig 3
Fig 3 From the original on binarly.io

Step 3: Out-of-bounds write in sub_24E8

As a result of the bypass above, an attacker obtains an out-of-bounds write primitive inside the sub_24E8 function.

Fig 4
Fig 4 From the original on binarly.io

Step 4: Same bypass with a single nested pointer (BRLY-2022-012 / CVE-2022-31645, CWE-787)

Here the Communication Buffer contains a single nested pointer. The pointer itself is validated, but the size of the pointed buffer, which is used for the pointer validation, is not checked against an expected value or range. This again allows a partial bypass of the validation and leads to memory corruption in SMM.

Fig 5
Fig 5 From the original on binarly.io

Step 5: Repeated WStringCopy without validation (BRLY-2022-013 / CVE-2022-31646, CWE-787)

This is another OOB write primitive of the same family as BRLY-2022-011 and BRLY-2022-012. The figure shows a way to exploit WStringCopy() multiple times because of the lack of validation.

Fig 6
Fig 6 From the original on binarly.io

Note that BRLY-2022-010, BRLY-2022-011 and BRLY-2022-013 cannot be exploited directly from an operating system. An attacker capable of executing code during the DXE phase can use them to elevate privileges to SMM and execute arbitrary code. Such OOB write primitives are dangerous because the vulnerable non-SMM DXE drivers are often reachable for exploitation from the OS, as was the case with BRLY-2021-005 / CVE-2021-39299.

Step 6: SMM callout through EFI_PCD_PROTOCOL (BRLY-2021-046 / CVE-2022-31640, CWE-20)

BRLY-2021-046 and BRLY-2021-047 are classical examples of SMM callout vulnerabilities, and their vulnerable code primitives are very similar. The CommBuffer data can be controlled by an attacker and, because of the lack of validation, can be modified.

Fig 7
Fig 7 From the original on binarly.io

The handler locates the protocol interface EFI_PCD_PROTOCOL via a gBS->LocateProtocol call and then executes the SetBool() function from that protocol. An attacker can overwrite the PcdProtocol->SetBool pointer in the EFI_PCD_PROTOCOL table with a shellcode address and trigger the handler, which results in arbitrary code execution in SMM.

Fig 8
Fig 8 From the original on binarly.io

Step 7: The same callout in a second module (BRLY-2021-047 / CVE-2022-31641, CWE-20)

BRLY-2021-047 describes exactly the same vulnerability as BRLY-2021-046, discovered in a different module. The exploitation steps are identical. The figure shows the PcdProtocol->SetBool() call, equal to Get8(), being controlled by an attacker and triggering arbitrary code execution.

Fig 9
Fig 9 From the original on binarly.io

Step 8: Detecting the vulnerable firmware with FwHunt

The majority of the vulnerabilities discussed here, and their variants, can be proactively detected by the Binarly Platform using semantic properties and lightweight code checkers. FwHunt rules for all of these HP issues are publicly available in Binarly's GitHub repository and are pushed to LVFS so that defenders can scope vulnerable devices across an enterprise infrastructure. The FwHunt detection result for the HP firmware is shown below.

Fig 10
Fig 10 From the original on binarly.io

Root cause

The common mistake is trusting the CommBuffer and its size. In BRLY-2022-010 the buffer contents are copied without sanitisation. In BRLY-2022-011, BRLY-2022-012 and BRLY-2022-013 the pointer is validated against SMRAM but the size used for that validation is never checked against an expected value or range, so a crafted size lets the write land outside the intended buffer. In BRLY-2021-046 and BRLY-2021-047 the handler performs a callout to a protocol function whose table entry can be overwritten through attacker-controlled CommBuffer data. In BRLY-2022-011, BRLY-2022-012 and BRLY-2022-013 the pointer validation did not constrain the size, which allowed a partial bypass.

Impact

Successful exploitation gives arbitrary code execution in SMM, the highest privilege level on the platform. For BRLY-2022-010, BRLY-2022-011 and BRLY-2022-013 this is not reachable directly from the OS; it requires an attacker already executing code in the DXE phase, who can then escalate to SMM within the window in which the SMI handler is registered. The OOB write primitives matter because vulnerable non-SMM DXE drivers are often available for exploitation from the operating system, and a malicious DXE driver can bypass Secure Boot and influence later boot stages. The end goal for an attacker is a firmware implant that provides long-term persistence on the device. The affected population is HP enterprise laptops and desktops, and at the time of writing some of them had still not received updates more than a month after public disclosure.

Fix

The report does not describe the code changes HP made. What it does say is that the disclosure was coordinated with HP PSIRT under HPSBHF03806, and that some devices had not received the updates at the time of writing. On the defensive side, Binarly published FwHunt rules for these vulnerabilities in its GitHub repository and pushed them to LVFS so that organisations can identify vulnerable devices at scale.

Variants to test

  1. SMI handlers that validate a nested pointer but ignore the accompanying size. A positive result is a handler where a pointer just inside SMRAM combined with a small or unexpected size passes validation and the following operation writes outside the buffer.
  2. SMI handlers that copy CommBuffer contents into a stack buffer without sanitisation. A positive result is a controlled overwrite of stack data in SMM.
  3. Direct memory manipulation APIs such as WStringCopy() called repeatedly on attacker-controlled data. A positive result is an out-of-bounds write reachable more than once from the same handler.
  4. SMM callouts that locate a protocol with gBS->LocateProtocol and invoke a function pointer from its table, such as PcdProtocol->SetBool. A positive result is a protocol table entry that can be overwritten through CommBuffer data and then triggered.
  5. Non-SMM DXE runtime drivers reachable from the OS. A positive result is a driver that can be influenced from the operating system and that feeds an SMI handler with attacker-controlled data.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 18 min read.

What happened, in plain words

Every computer has a tiny, hidden operating system inside it that runs before the main one (Windows, Linux) even starts. This hidden software is called firmware. It wakes up the hardware, checks that the machine is healthy, and then hands control to the operating system you actually see. Because it sits underneath everything, firmware has more power than anything else on the machine.

A security research team called the Binarly efiXplorer Team spent time examining the firmware inside HP business laptops and desktops, especially the HP EliteBook line. They found six serious flaws. All six let an attacker run their own code in the most privileged part of the machine, a mode called System Management Mode (SMM). They discussed the findings at a security conference called Black Hat 2022 and published them on 8 September 2022, working with HP's product security team (HP PSIRT) under an advisory numbered HPSBHF03806.

The awkward part: more than a month after the flaws became public, some HP business laptops and desktops still had not received the update that fixes them. The researchers also point out that approximately 20% of firmware updates, according to Binarly Platform data from a study of enterprise-grade vendors, contain at least two or three previously disclosed known vulnerabilities. In other words, the update you install may itself be built on old, already-known-broken code.

This article walks through each of the six flaws in the same order the researchers presented them, explaining every technical idea from scratch along the way.

The background you need first

What firmware is

Think of firmware as the building's caretaker who arrives before anyone else, unlocks the doors, turns on the lights and checks the plumbing, then hands the keys to the tenant (the operating system). The tenant can redecorate, but cannot easily see or change what the caretaker did before they arrived. If the caretaker is compromised, the tenant may never notice.

What SMM is, and why "ring -2" matters

Processors number their privilege levels. The operating system's core runs at "ring 0", the most privileged level a normal program can reach. Applications run at ring 3, far less privileged. SMM sits below ring 0, which is why people jokingly call it ring -2. Code running in SMM is invisible to the operating system: the OS cannot see it, stop it, or even know it ran. It is invisible to the operating system, which cannot see it, stop it, or even know it ran. That makes SMM the perfect hiding place for an attacker who wants to stay on a machine for a long time.

What an SMI handler and a CommBuffer are

When the operating system, or the firmware's own boot-time code, needs SMM to do something, it sends a signal called a software SMI (System Management Interrupt). The processor pauses whatever it was doing, jumps into a small routine in SMM called an SMI handler, lets it run, and then returns.

Because the caller and the handler are different pieces of software, they need a way to pass data. They use a shared patch of memory called a Communication Buffer, shortened to CommBuffer in the code. Think of it as a form the caller fills in and slides under the door; the handler picks it up and acts on what is written there.

The critical rule: the handler must check that form carefully before trusting it. If it does not, the caller can write anything it likes on the form, including instructions that make the handler misbehave. In all six flaws, that checking was missing or incomplete.

What a pointer and a size are

A pointer is just a number that says where in memory something lives, like a house number. A size says how many bytes that something occupies, like how many rooms the house has. When code wants to copy data safely, it needs both: where to start and how far to go. If it trusts the size without checking it, an attacker can claim a tiny size while pointing at a spot that makes the copy spill over into neighbouring memory. That spill is called an out-of-bounds write.

What the vulnerability classes mean

  • Stack-based buffer overflow (CWE-121): a fixed-size scratch area (the stack) is filled with more data than it can hold, so the extra data overwrites whatever sits next to it. Like pouring a litre of water into a 200 ml glass: the surplus goes everywhere.
  • Out-of-bounds write (CWE-787): code writes to a memory location outside the region it was supposed to touch. Like a postman who, instead of stopping at house 10, keeps pushing letters through the letterboxes of houses 11, 12 and 13.
  • Improper input validation (CWE-20): the program accepts input it should have rejected. Like a bouncer who lets anyone in without checking the guest list.

What arbitrary code execution means

It means the attacker gets to run whatever instructions they want, in the place where the flaw lives. Here, that place is SMM, so the attacker's code runs with more power than the operating system itself.

What a firmware implant is

An implant is malicious code planted inside the firmware so it loads every time the machine starts. The attacker can hide it as a modified legitimate module or as a standalone driver. Because firmware runs before the OS, the implant can hide from antivirus and survive reinstalling the operating system. This is the end goal the researchers describe: long-term persistence on the device.

What Secure Boot and DXE are

Secure Boot is a firmware feature that refuses to load boot software unless it carries a valid cryptographic signature. It is meant to stop tampered boot code from running.

DXE stands for Driver Execution Environment. It is a phase during boot when firmware loads drivers that set up the hardware. Some of those drivers keep running later, even after the OS has started. A malicious DXE driver can bypass Secure Boot and influence later boot stages, which is why the researchers warn that these drivers are attractive targets.

What a protocol and a callout are

In firmware, a protocol is a named bundle of functions that other code can look up and call. Think of it as a plug socket: any device that fits can plug in and use the electricity. The firmware finds a protocol by name using a lookup function, then calls one of the functions inside it.

An SMM callout is when code running in SMM calls out to a function that lives outside SMM, in ordinary memory. That is dangerous because ordinary memory can be modified by an attacker. If the attacker can swap the function's address for the address of their own code, SMM will happily jump to it and run it with SMM privileges.

The six vulnerabilities at a glance

All six are described as SMM memory corruption leading to arbitrary code execution. The table below lists them with their internal Binarly identifiers (BRLY IDs), their public CVE identifiers, and their CVSS scores. A CVE is a globally unique catalogue number for a publicly known vulnerability. A CVSS score is a standard 0 to 10 severity rating; anything from 7.0 to 8.9 counts as High.

Vulnerability BRLY ID CVE ID CVSS score
SMM Memory Corruption (Arbitrary Code Execution) BRLY-2022-010 CVE-2022-23930 8.2 High
SMM Memory Corruption (Arbitrary Code Execution) BRLY-2022-011 CVE-2022-31644 7.5 High
SMM Memory Corruption (Arbitrary Code Execution) BRLY-2022-012 CVE-2022-31645 8.2 High
SMM Memory Corruption (Arbitrary Code Execution) BRLY-2022-013 CVE-2022-31646 8.2 High
SMM Memory Corruption (Arbitrary Code Execution) BRLY-2021-046 CVE-2022-31640 7.5 High
SMM Memory Corruption (Arbitrary Code Execution) BRLY-2021-047 CVE-2022-31641 7.5 High

The patch gap, made visible

At the time of writing, some HP business laptops and desktops had still not received updates to fix these flaws, even though they had been public for over a month. To show this, the researchers used a tool called FwHunt, which scans firmware images for known-bad patterns, integrated with the Linux Vendor Firmware Service (LVFS). LVFS is a public catalogue of firmware updates for Linux systems; if a vendor has published a fixed firmware there, FwHunt can tell you whether the version you have still matches the vulnerable pattern.

Figure 1
Figure 1 From the original on binarly.io

The figure shows the FwHunt and LVFS view of which devices still lack a fixed firmware, making the gap between disclosure and patch visible.

At a larger scale, Binarly's own telemetry tells the same story. According to Binarly Platform data based on a study of enterprise-grade vendors, approximately 20% of firmware updates contain at least two or three previously disclosed known vulnerabilities. In plain terms: one in five firmware updates you install may still carry old, publicly known holes.

How the research was done

The Binarly efiXplorer Team used the Binarly Platform, which analyses firmware images by looking at their structure and meaning ("semantic properties") and running lightweight automated checkers over the code, plus FwHunt, a rule-based detection tool. FwHunt rules for these HP flaws are published in Binarly's GitHub repository and are also pushed to LVFS so that anyone can check their own devices. The report does not describe any accounts, roles or specific tool versions.

The key precondition for exploitation is where the attacker already is. Some of these SMI handlers cannot be reached from the operating system at all, because the handler is unregistered before the OS boots. An attacker who can already run code during the DXE phase can exploit such handlers in the short window between the handler being registered and being unregistered, and use them to climb into SMM. Separately, ordinary (non-SMM) DXE runtime drivers and applications are attractive targets: a malicious DXE driver can bypass Secure Boot and influence later boot stages, and a firmware implant is the attacker's end goal for long-term persistence.

How the flaws were found

The size of the buffer, which is used for the validation, is not used further and is not checked against an expected value or range, allowing a partial bypass of the validation.

BRLY-2022-011, BRLY-2022-012 and BRLY-2022-013 share this nature: out-of-bounds write primitives built on direct memory manipulation API functionality. An API is simply a set of functions one piece of software offers to another; here it means the firmware's built-in memory-copy helpers. The team notes that all three were most likely caused by similar coding practices applied by the same firmware development team.

Walking through each flaw

Step 1: Stack-based buffer overflow via unsanitised CommBuffer (BRLY-2022-010 / CVE-2022-23930, CWE-121)

A lack of sanitisation of the CommBuffer data allows an attacker to write an arbitrary controlled data buffer, which leads to arbitrary code execution in SMM. "Sanitisation" means cleaning and checking input before using it, the way a kitchen washes vegetables before cooking. Here, the handler takes whatever is in the CommBuffer without sanitising it. By choosing the data carefully, the attacker can make the processor jump into their own code.

Fig 2
Fig 2 From the original on binarly.io

The figure shows the vulnerable primitive.

Step 2: Bypass pointer validation with a controlled size (BRLY-2022-011 / CVE-2022-31644, CWE-787)

The Communication Buffer passed into this SMI handler contains two nested pointers: a pointer to a buffer and a pointer to its size. "Nested" means the CommBuffer does not hold the data itself, only directions to where the data and its size live, like a note saying "the parcel is in locker 12 and it weighs 3 kg".

Both pointers are validated to point into SMRAM. That is, the handler checks that the locker really is inside the secure room. However, the size of the buffer, which is what the validation relies on, is not used further and is never checked against an expected value or range. An attacker can therefore partially bypass the validation, for example by specifying:

Text
*(QWORD *)*CommBuffer = SMRAM_BASE - 1
size_ptr = 1 byte

Line by line:

  • *(QWORD *)*CommBuffer = SMRAM_BASE - 1 tells the handler that the buffer starts one byte below the bottom of SMRAM. QWORD means a 64-bit number, the standard width of a pointer on these machines. SMRAM_BASE is the address where the protected SMRAM region begins, so SMRAM_BASE - 1 is just outside it.
  • size_ptr = 1 byte tells the handler that the buffer is only one byte long.

With the buffer pointer placed one byte below SMRAM and a size of one byte, the validation is partially bypassed and the operation that follows reaches outside the intended region.

Fig 3
Fig 3 From the original on binarly.io

Step 3: Out-of-bounds write in sub_24E8

As a result of the bypass above, an attacker obtains an out-of-bounds write primitive inside the sub_24E8 function. sub_24E8 is just the name a disassembler gives to a function it found at a particular address; it is not a friendly name the developers chose. The point is that the write lands outside the buffer the code meant to touch.

Fig 4
Fig 4 From the original on binarly.io

Step 4: Same bypass with a single nested pointer (BRLY-2022-012 / CVE-2022-31645, CWE-787)

Here the Communication Buffer contains a single nested pointer. The pointer itself is validated, but the size of the pointed buffer, which is used for the pointer validation, is not checked against an expected value or range. This again allows a partial bypass of the validation and leads to memory corruption in SMM.

Fig 5
Fig 5 From the original on binarly.io

Step 5: Repeated WStringCopy without validation (BRLY-2022-013 / CVE-2022-31646, CWE-787)

This is another OOB write primitive of the same family as BRLY-2022-011 and BRLY-2022-012. WStringCopy() is a firmware helper that copies a wide-character string (a string where each character takes more than one byte) from one place to another. The figure shows a way to exploit WStringCopy() multiple times because of the lack of validation.

Fig 6
Fig 6 From the original on binarly.io

A note on reachability: BRLY-2022-010, BRLY-2022-011 and BRLY-2022-013 cannot be exploited directly from an operating system. An attacker capable of executing code during the DXE phase can use them to elevate privileges to SMM and execute arbitrary code. Such OOB write primitives are dangerous because the vulnerable non-SMM DXE drivers are often reachable for exploitation from the OS, as was the case with BRLY-2021-005 / CVE-2021-39299. In other words, the attacker first needs a foothold in the boot process, but once there, these flaws turn that foothold into full SMM control.

Step 6: SMM callout through EFI_PCD_PROTOCOL (BRLY-2021-046 / CVE-2022-31640, CWE-20)

BRLY-2021-046 and BRLY-2021-047 are classical examples of SMM callout vulnerabilities, and their vulnerable code primitives are very similar. The CommBuffer data can be controlled by an attacker and, because of the lack of validation, can be modified. Remember the plug-socket analogy: the handler looks up a protocol by name and then calls a function from it. If the attacker can change the address stored in that protocol's table, the handler will call the attacker's code instead.

Fig 7
Fig 7 From the original on binarly.io

The handler locates the protocol interface EFI_PCD_PROTOCOL via a gBS->LocateProtocol call and then executes the SetBool() function from that protocol. gBS is the firmware's global boot-services table, a directory of services the firmware offers; LocateProtocol is the lookup that finds a named protocol. SetBool() is a function that sets a true/false setting. An attacker can overwrite the PcdProtocol->SetBool pointer in the EFI_PCD_PROTOCOL table with a shellcode address and trigger the handler, which results in arbitrary code execution in SMM. Shellcode is a small piece of machine code an attacker wants to run; here it would run with SMM privileges.

Fig 8
Fig 8 From the original on binarly.io

Step 7: The same callout in a second module (BRLY-2021-047 / CVE-2022-31641, CWE-20)

BRLY-2021-047 describes exactly the same vulnerability as BRLY-2021-046, discovered in a different module. The exploitation steps are identical. The figure shows the PcdProtocol->SetBool() call, equal to Get8(), being controlled by an attacker and triggering arbitrary code execution. "Equal to Get8()" means the compiler produced the same machine code for this call as it would for a function that reads a single byte, so the two look alike in the disassembly.

Fig 9
Fig 9 From the original on binarly.io

Step 8: Detecting the vulnerable firmware with FwHunt

The majority of the vulnerabilities discussed here, and their variants, can be proactively detected by the Binarly Platform using semantic properties and lightweight code checkers. FwHunt rules for all of these HP issues are publicly available in Binarly's GitHub repository and are pushed to LVFS so that defenders can scope vulnerable devices across an enterprise infrastructure. "Scoping" means finding out which machines in an organisation are affected, the way a fire warden checks which rooms have smoke detectors.

Fig 10
Fig 10 From the original on binarly.io

The figure shows the FwHunt detection result for the HP firmware.

Why these flaws exist

The common mistake is trusting the CommBuffer and its size. In BRLY-2022-010 the buffer contents are copied without sanitisation. In BRLY-2022-011, BRLY-2022-012 and BRLY-2022-013 the pointer is validated against SMRAM but the size used for that validation is never checked against an expected value or range, so a crafted size lets the write land outside the intended buffer. In BRLY-2021-046 and BRLY-2021-047 the handler performs a callout to a protocol function whose table entry can be overwritten through attacker-controlled CommBuffer data. In BRLY-2022-011, BRLY-2022-012 and BRLY-2022-013 the pointer validation did not constrain the size, which allowed a partial bypass.

A useful comparison: a nightclub bouncer who checks that your ID is genuine but never checks whether the photo matches your face. The check exists, it just does not cover the thing that matters.

What an attacker gains

Successful exploitation gives arbitrary code execution in SMM, the highest privilege level on the platform. For BRLY-2022-010, BRLY-2022-011 and BRLY-2022-013 this is not reachable directly from the OS; it requires an attacker already executing code in the DXE phase, who can then escalate to SMM within the window in which the SMI handler is registered. The OOB write primitives matter because vulnerable non-SMM DXE drivers are often available for exploitation from the operating system, and a malicious DXE driver can bypass Secure Boot and influence later boot stages. The end goal for an attacker is a firmware implant that provides long-term persistence on the device. The affected population is HP business laptops and desktops, and at the time of writing some of them had still not received updates more than a month after public disclosure.

The fix

The report does not describe the code changes HP made. What it does say is that the disclosure was coordinated with HP PSIRT under HPSBHF03806, and that some devices had not received the updates at the time of writing. On the defensive side, Binarly published FwHunt rules for these vulnerabilities in its GitHub repository and pushed them to LVFS so that organisations can identify vulnerable devices at scale.

Patterns worth checking elsewhere

These are the code patterns behind the six vulnerabilities:

  1. SMI handlers that validate a nested pointer but ignore the accompanying size. A positive result is a handler where a pointer just inside SMRAM combined with a small or unexpected size passes validation and the following operation writes outside the buffer.
  2. SMI handlers that copy CommBuffer contents into a stack buffer without sanitisation. A positive result is a controlled overwrite of stack data in SMM.
  3. Direct memory manipulation APIs such as WStringCopy() called repeatedly on attacker-controlled data. A positive result is an out-of-bounds write reachable more than once from the same handler.
  4. SMM callouts that locate a protocol with gBS->LocateProtocol and invoke a function pointer from its table, such as PcdProtocol->SetBool. A positive result is a protocol table entry that can be overwritten through CommBuffer data and then triggered.
  5. Non-SMM DXE runtime drivers reachable from the OS. A positive result is a driver that can be influenced from the operating system and that feeds an SMI handler with attacker-controlled data.

Glossary

  • API: a set of functions one piece of software offers to another so they can work together.
  • Arbitrary code execution: the ability for an attacker to run whatever instructions they choose on a machine.
  • Black Hat: a well-known security conference where researchers present their findings.
  • BRLY ID: Binarly's internal identifier for a vulnerability it discovered.
  • CommBuffer (Communication Buffer): a shared patch of memory used to pass data between the caller and an SMI handler.
  • CVE: a globally unique catalogue number for a publicly known vulnerability.
  • CVSS: a standard 0 to 10 severity score for vulnerabilities; 7.0 to 8.9 is High.
  • CWE: a catalogue of weakness types, such as buffer overflow or improper input validation.
  • DXE (Driver Execution Environment): a boot phase in which firmware loads drivers that set up the hardware.
  • Firmware: the low-level software built into a device that runs before the operating system.
  • Firmware implant: malicious code hidden in firmware so it loads on every boot and survives OS reinstalls.
  • FwHunt: Binarly's rule-based tool for detecting known-bad patterns in firmware images.
  • gBS: the firmware's global table of boot services, used to look up things like protocols.
  • HP PSIRT: HP's Product Security Incident Response Team, which coordinates vulnerability reports.
  • HPSBHF03806: the HP security advisory number for this disclosure.
  • LVFS (Linux Vendor Firmware Service): a public catalogue of firmware updates for Linux systems.
  • Out-of-bounds write (CWE-787): writing to memory outside the region the code was supposed to touch.
  • Pointer: a number that says where in memory something lives.
  • Protocol: in firmware, a named bundle of functions that other code can look up and call.
  • QWORD: a 64-bit number, the usual width of a pointer on these machines.
  • Ring -2: an informal name for SMM, because it sits below the operating system's ring 0.
  • Sanitisation: cleaning and checking input before using it.
  • Secure Boot: a firmware feature that refuses to load boot software without a valid cryptographic signature.
  • Shellcode: a small piece of machine code an attacker wants to run.
  • SMI (System Management Interrupt): a signal that makes the processor pause and run an SMM routine.
  • SMI handler: the routine in SMM that runs when an SMI arrives.
  • SMM (System Management Mode): the most privileged execution mode on x86 machines, invisible to the operating system.
  • SMM callout: SMM code calling a function that lives outside SMM, in memory an attacker may be able to modify.
  • SMRAM: the protected memory region where SMM code and data live.
  • Stack: a fixed-size scratch area in memory used for temporary data and return addresses.
  • Stack-based buffer overflow (CWE-121): filling a fixed-size stack area with more data than it can hold, overwriting what sits next to it.
  • sub_24E8: a function name automatically generated by a disassembler from its address.
  • WStringCopy(): a firmware helper that copies a wide-character string from one place to another.

More from HP

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.