Method for defending UEFI (Unified Extensible Firmware Interface) firmware buffer overflow vulnerability attack

By setting a read-only mode page protection mechanism in UEFI firmware, it identifies and defends against heap overflow vulnerability attacks, solves the problem of heap overflow vulnerabilities that cannot be defended by existing technologies, ensures system security, and is applicable to all UEFI firmware core data structures.

CN118627083AInactive Publication Date: 2024-09-10JIANGSU ZHUOYI INFORMATION TECH CO LTD +3

Patent Information

Application Number
CN202410711893.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-04
Publication Date
2024-09-10
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing technology cannot effectively defend against heap overflow vulnerability attacks in UEFI firmware, and in particular cannot detect and resist advanced attack methods targeting core data structures, resulting in threats to system security.

Method used

By setting the read-write attribute to read-only mode in the page management of the UEFI firmware core data structure, using the CPU page protection mechanism to trigger page faults, identify and prevent hackers from tampering with callback function pointers, and ensure system security.

Benefits of technology

It effectively prevents hackers from using heap overflow vulnerabilities to attack the core data structure of UEFI firmware, ensuring that system security is not destroyed. It is applicable to all UEFI firmware core data structures and extends the heap memory used in UEFI drivers or applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118627083A
    Figure CN118627083A
Patent Text Reader

Abstract

The invention discloses a method for defending UEFI (Unified Extensible Firmware Interface) firmware buffer overflow vulnerability attack, and relates to the technical field of system security. The method specifically comprises the following steps of: firstly, setting a read-write attribute of a page of a UEFI firmware core data structure into a readable and writable mode, and modifying the read-write attribute into a read-only mode after initialization is completed; the permission of updating the UEFI firmware core data structure by the UEFI driver and the application program is set to be updated only through the starting service; when service calling is started, the read-write attribute of the page is modified into a readable and writable mode, and after updating is completed, the read-write attribute of the page is modified into a read-only mode; when a hacker utilizes the heap overflow vulnerability, a CPU page protection mechanism can immediately trigger a page error, so that the type of attack is detected and defended. According to the method, page management of a UEFI firmware implementation core data structure is enhanced, and page errors are triggered through a page protection mechanism, so that attacks of the type are detected and defended, and the security of a system is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of system security, and in particular to a method for defending against UEFI firmware buffer overflow vulnerability attacks. Background Art

[0002] UEFI is the abbreviation of Unified Extensible Firmware Interface, which defines the interface between system firmware (BIOS) and hardware and operating system. Currently, most of the system firmware (BIOS) products in the industry are implemented based on UEFI. Buffer overflow vulnerabilities that may exist in the implementation of system firmware (BIOS) are a major area of ​​hacker attacks. Hackers can use this to achieve arbitrary code execution, allowing hacker code to gain control of the system, and then implant malicious code such as firmware rootkit or damage the system.

[0003] Buffer overflows can generally be divided into two types: stack overflow and heap overflow. For stack overflow, computing device hardware and software have introduced a variety of defense measures. For heap overflow, the situation is much more complicated, and the current defense measures are relatively limited. In the current UEFI firmware implementation, a technology called Heap Guard is introduced. Every time a heap memory page is allocated, a guard page is added before and after the allocated heap memory page, and the page table entries of these two guard pages are set to NOT PRESENT. When a heap overflow occurs, these two guard pages may be written and immediately trigger a Page Fault, thereby detecting a heap overflow. However, the disadvantage of this technology is that a Page Fault will only be triggered when a heap overflow occurs and the two guard pages are written, and it cannot resist heap overflow attacks against memory locations of specific data types (but not writing to the two guard pages). LogoFAIL-BlackHatEurope2023 (SPLIT) demonstrated an attack method that overwrites the core data structure PROTOCOL_ENTRY of the UEFI firmware through a heap overflow, replaces the PROTOCOL_NOTIFY callback function in a PROTOCOL_ENTRY with hacker code, and thus implements ArbitraryCodeExecution. This new, more advanced and covert attack method for Heap Overflow against the core data structure of the UEFI firmware cannot be detected and resisted by the aforementioned Heap Guard and other technologies. As long as there is a Heap Overflow vulnerability in the UEFI firmware implementation, it may theoretically be attacked by this method, which poses a serious threat to the security of computing devices and systems. Summary of the invention

[0004] In view of the deficiencies of the above prior art, the present invention provides a method for defending against UEFI firmware buffer overflow vulnerability attacks. The innovation of the present invention is to enhance the page management of the core data structure of the UEFI firmware to prevent hackers from exploiting the heap overflow vulnerability. By identifying the specific data type in the memory, the UEFI firmware core data structure is found, and the callback function pointer therein is tampered with; and a page fault is triggered through the page protection mechanism, thereby detecting and defending against this type of attack and ensuring the security of the system.

[0005] To this end, the technical solution of the present invention is a method for defending against UEFI firmware buffer overflow vulnerability attacks, which specifically includes the following steps:

[0006] When S1 allocates a page for the UEFI firmware core data structure, it first sets the read-write attribute of the page in the page table entry to the read-write mode, and then changes the read-write attribute of the page to the read-only mode after completing the initialization of the UEFI firmware core data structure;

[0007] S2 sets the permission for the UEFI driver and the application to update the UEFI firmware core data structure, and sets the update permission to the UEFI driver and the application not having the permission to directly update the UEFI firmware core data structure, and can only update it through the boot-time service provided by the UEFI firmware kernel;

[0008] S3: When the boot-up service provided by the UEFI firmware kernel is called and the UEFI firmware core data structure needs to be updated, the read-write attribute of the page is first modified to the read-write mode, and after the update is completed, the read-write attribute of the page is modified to the read-only mode;

[0009] S4 When hackers exploit the heap overflow vulnerability, find the UEFI firmware core data structure by identifying specific data types in the memory, and tamper with the callback function pointer therein, the CPU page protection mechanism will immediately trigger a page error because the read-write attribute of the page is in read-only mode, thereby detecting and defending against this type of attack to ensure system security.

[0010] Furthermore, in the page table entry of the EFI firmware core data structure page, Bit 1 of the page table entry is used to control the read and write attributes of the page.

[0011] Furthermore, the steps for allocating and initializing the UEFI firmware core data structure are:

[0012] S1.1 allocates the UEFI firmware core data structure page and uses a flag bit in the page table entry to control the read and write properties of the page;

[0013] S1.2 first sets the read / write attribute of the page in the page table entry to the readable / writable mode;

[0014] S1.3 Initialize UEFI firmware core data structure;

[0015] S1.4 then changes the read-write attribute of the page in the page table entry to read-only mode.

[0016] Furthermore, the steps for updating the core data structure in the service when the UEFI firmware is started are:

[0017] S3.1 first changes the read-write attribute of the page to the read-write mode;

[0018] S3.2 Update UEFI firmware core data structure;

[0019] S3.3 then changes the read-write attribute of the page to read-only mode.

[0020] Furthermore, the steps for detecting and defending against heap overflow vulnerability attacks are:

[0021] S4.1 When a hacker exploits a heap overflow vulnerability, finds the UEFI firmware core data structure by identifying a specific data type in memory, and tampers with the callback function pointer therein, a page fault exception is triggered;

[0022] S4.2 locate the cause of the page fault exception through the page fault exception handler;

[0023] S4.3 determines whether the cause of the page error is a write operation on the page, and the attribute of the page is in read-only mode;

[0024] S4.4 If the judgment result of step S4.3 is no, then proceed to process the cause of other page errors;

[0025] S4.5 If the judgment result of step S4.3 is yes, it is considered that a heap overflow vulnerability attack has occurred, and the operation of shutting down or reporting to the system administrator is executed.

[0026] The beneficial effects of the present invention are as follows: the present invention enhances the page management of the core data structure of the UEFI firmware, prevents hackers from exploiting the heap overflow vulnerability, finds the UEFI firmware core data structure by identifying specific data types in the memory, and tampers with the callback function pointer therein; triggers a page fault through a page protection mechanism, thereby detecting and defending against this type of attack, and ensuring the security of the system.

[0027] The present invention solves the problem of heap overflow vulnerability attack that cannot be defended by existing technologies such as Heap Guard, and ensures that the system security is not damaged; the method proposed in the present invention is applicable to all UEFI firmware core data structures, so that hackers cannot carry out attacks by identifying specific data types of the UEFI firmware kernel in the memory; the method proposed in the present invention and its principle can also be extended to be applied to the heap memory allocated or used by the UEFI driver or application program as needed. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 It is the page table entry format of the 4K Byte page of the IA32 processor;

[0029] Figure 2 It is a flowchart of the allocation and initialization of the core data structure of the UEFI firmware;

[0030] Figure 3It is a flowchart of updating the core data structure in the service when the UEFI firmware is started;

[0031] Figure 4 It is a flowchart of heap overflow vulnerability attack detection and defense. DETAILED DESCRIPTION

[0032] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0033] The present invention provides a method for defending against UEFI firmware buffer overflow vulnerability attacks, which specifically includes the following steps:

[0034] When S1 allocates a page for a UEFI firmware core data structure (e.g., PROTOCOL_ENTRY), it first sets the read / write attribute of the page of the UEFI firmware core data structure in the page table entry to a read / write (R / W) mode, and after completing the initialization of the UEFI firmware core data structure, it then changes the read / write attribute of the page of the UEFI firmware core data structure in the page table entry to a read-only (Read Only) mode;

[0035] like Figure 1 As shown, Figure 1 This is a typical 4K Byte page table entry format for an IA32 processor. In this embodiment, for a page table entry of a UEFI firmware core data structure page, Bit 1 of the page table entry is used to control the read and write properties of the page.

[0036] The data structure of PAGE_TABLE_4K_ENTRY:

[0037]

[0038]

[0039] The data structure of PROTOCOL_ENTRY:

[0040]

[0041]

[0042] like Figure 2 The steps of allocating and initializing the UEFI firmware core data structure are as follows:

[0043] S1.1 allocates UEFI firmware core data structure pages, such as PROTOCOL_ENTRY;

[0044] S1.2 first sets the read / write attribute of the page in the page table entry to the read / write (R / W) mode, for example, setting PAGE_TABLE_4K_ENTRY.ReadWrite = 1;

[0045] S1.3 Initialize the UEFI firmware core data structure, such as initializing PROTOCOL_ENTRY;

[0046] S1.4 changes the read-write attribute of the page in the page table entry to read-only mode, such as setting PAGE_TABLE_4K_ENTRY.ReadWrite=0.

[0047] S2 sets the permission for UEFI drivers and applications to update the UEFI firmware core data structure. UEFI drivers and applications do not have the permission to directly update the UEFI firmware core data structure (such as PROTOCOL_ENTRY), and can only be updated through the boot services (BootServices) provided by the UEFI firmware kernel;

[0048] S3: When the boot service provided by the UEFI firmware kernel is called and the UEFI firmware core data structure (such as PROTOCOL_ENTRY) needs to be updated, the read-write attribute of the page of the UEFI firmware core data structure is first modified to the read-write (R / W) mode, and after the update is completed, the read-write attribute of the page of the UEFI firmware core data structure is modified to the read-only (Read Only) mode;

[0049] like Figure 3 The steps for updating the core data structure in the UEFI firmware boot service (Boot Services) are as follows:

[0050] S3.1 First, change the read / write attribute of the page to read / write (R / W) mode, for example,

[0051] PAGE_TABLE_4K_ENTRY.ReadWrite=1;

[0052] S3.2 updates the UEFI firmware core data structure, such as updating PROTOCOL_ENTRY;

[0053] S3.3 Change the read-write attribute of the page to read-only mode, for example,

[0054] PAGE_TABLE_4K_ENTRY.ReadWrite=0.

[0055] S4 When hackers exploit the heap overflow vulnerability, find the UEFI firmware core data structure (such as PROTOCOL_ENTRY) by identifying specific data types in the memory, and tamper with the callback function pointer therein, the CPU page protection mechanism will immediately trigger a page fault (PageFault) because the read-write attribute of the page is in read-only mode, thereby detecting and defending against this type of attack to ensure system security.

[0056] The CPU page protection mechanism refers to a technology that protects memory pages from illegal access or modification through hardware. The CPU page protection mechanism mainly includes the following two aspects:

[0057] 1. Memory paging mechanism: The memory is divided into pages of fixed size, and the firmware kernel or operating system maps each page to the virtual address space to achieve address isolation and protection. Each page has its own access rights, such as readable, writable, executable, etc. These rights are controlled by the firmware kernel or operating system.

[0058] 2.CPU hardware support: In the CPU, there are some special registers for storing information such as page tables or segment tables. Through these registers, the CPU can quickly find the page corresponding to the physical address and check whether the access rights are legal. If not, an exception or interrupt will be triggered, and the firmware kernel or operating system will handle these events accordingly.

[0059] In this way, the CPU page protection mechanism can prevent common security vulnerabilities such as program out-of-bounds access and buffer overflow, and ensure the stability and security of the system.

[0060] A page fault is an exception that occurs when a program accesses a virtual memory page that does not exist in memory. In simple terms, the requested page does not exist in physical memory and needs to be loaded from the hard disk or other storage device into memory. Page Fault is part of virtual memory management, which allows programs to use a larger address space than physical memory.

[0061] When a Page Fault occurs, the firmware kernel or operating system needs to take a series of steps to handle the abnormal situation. Page Fault handling methods include:

[0062] Interrupt processing: When a Page Fault occurs, the firmware kernel or operating system interrupts the executing process to handle the exception.

[0063] Find a free page: The firmware kernel or operating system looks for a free physical page to accommodate the requested page.

[0064] Page replacement algorithm: If there are no free pages available in the physical memory, the firmware kernel or operating system needs to select a page for replacement and replace it with the requested page.

[0065] Loading a page: If the requested page is not in physical memory, the firmware kernel or operating system loads the page from the hard disk or other storage device into memory.

[0066] Update the page table: After processing the Page Fault, the firmware kernel or operating system needs to update the page table to ensure that the page can be directly obtained the next time it is accessed.

[0067] like Figure 4 The steps of detecting and defending against the Heap Overflow vulnerability attack are as follows:

[0068] S4.1 When a hacker exploits a heap overflow vulnerability, finds the UEFI firmware core data structure by identifying a specific data type in the memory, and tampers with the callback function pointer therein, a page fault exception (Page Fault Exception) is triggered; Page Fault Exception is a firmware kernel or operating system exception. In the present invention, when a program attempts to access a protected memory page, the CPU will send a Page Fault Exception.

[0069] S4.2 locates the cause of the page fault exception (Page Fault Exception) through the page fault exception handler (Page Fault Exception Handler).

[0070] Page Fault Exception Handler is an exception handler in the firmware kernel or operating system. When a program attempts to access a protected memory page, the CPU will throw a page fault exception. At this time, Page Fault Exception Handler will be called to handle the exception.

[0071] S4.3 determines whether the cause of the page fault is a write operation on the page, and the attribute of the page is read-only mode, that is, PAGE_TABLE_4K_ENTRY.ReadWrite=0.

[0072] S4.4 If the judgment result of step S4.3 is no, then proceed to process the cause of other page faults;

[0073] S4.5 If the judgment result of step S4.3 is yes, it is considered that a heap overflow vulnerability attack has occurred, and the system is shut down or reported to the system administrator.

[0074] The present invention has the following advantages:

[0075] 1. Security: The method proposed in the present invention solves the heap overflow vulnerability attack problem that cannot be defended by existing technologies such as Heap Guard, ensuring that the system security is not damaged.

[0076] 2. Universality: The method proposed in the present invention is applicable to all UEFI firmware core data structures, making it impossible for hackers to carry out attacks by identifying specific data types of the UEFI firmware kernel in the memory;

[0077] 3. Extensibility: The UEFI firmware core data structure proposed in the present invention takes PROTOCOL_ENTRY as an example, and can also be extended to other UEFI firmware core data structures. In addition, the method and principle proposed in the present invention can also be extended to the heap memory allocated or used by the UEFI driver or application as needed.

[0078] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A method for defending against UEFI firmware buffer overflow vulnerability attacks, characterized in that: The specific steps include: When S1 allocates a page for the UEFI firmware core data structure, it first sets the read-write attribute of the page in the page table entry to the read-write mode, and then changes the read-write attribute of the page to the read-only mode after completing the initialization of the UEFI firmware core data structure; S2 sets the permission for the UEFI driver and the application to update the UEFI firmware core data structure, and sets the update permission to the UEFI driver and the application not having the permission to directly update the UEFI firmware core data structure, and can only update it through the boot-time service provided by the UEFI firmware kernel; S3: When the boot-up service provided by the UEFI firmware kernel is called and the UEFI firmware core data structure needs to be updated, the read-write attribute of the page is first modified to the read-write mode, and after the update is completed, the read-write attribute of the page is modified to the read-only mode; S4 When hackers exploit the heap overflow vulnerability, find the UEFI firmware core data structure by identifying specific data types in the memory, and tamper with the callback function pointer therein, the CPU page protection mechanism will immediately trigger a page error because the read-write attribute of the page is in read-only mode, thereby detecting and defending against this type of attack to ensure system security.

2. The method for defending against UEFI firmware buffer overflow vulnerability attacks according to claim 1, characterized in that: In the page table entry of the EFI firmware core data structure page, Bit 1 of the page table entry is used to control the read and write attributes of the page.

3. The method for defending against UEFI firmware buffer overflow vulnerability attack according to claim 1, characterized in that: The steps for allocating and initializing the UEFI firmware core data structure are: S1.1 allocates the UEFI firmware core data structure page and uses a flag bit in the page table entry to control the read and write properties of the page; S1.2 first sets the read / write attribute of the page in the page table entry to the readable / writable mode; S1.3 Initialize UEFI firmware core data structure; S1.4 then changes the read-write attribute of the page in the page table entry to read-only mode.

4. The method for defending against UEFI firmware buffer overflow vulnerability attacks according to claim 1, characterized in that: The steps for updating the core data structure in the service when the UEFI firmware starts are: S3.1 first changes the read-write attribute of the page to the read-write mode; S3.2 Update UEFI firmware core data structure; S3.3 then changes the read-write attribute of the page to read-only mode.

5. The method for defending against UEFI firmware buffer overflow vulnerability attack according to claim 1, characterized in that: The steps for detecting and defending against heap overflow vulnerability attacks are: S4.1 When a hacker exploits a heap overflow vulnerability, finds the UEFI firmware core data structure by identifying a specific data type in memory, and tampers with the callback function pointer therein, a page fault exception is triggered; S4.2 locate the cause of the page fault exception through the page fault exception handler; S4.3 determines whether the cause of the page error is a write operation on the page, and the attribute of the page is in read-only mode; S4.4 If the judgment result of step S4.3 is no, then proceed to process the cause of other page errors; S4.5 If the judgment result of step S4.3 is yes, it is considered that a heap overflow vulnerability attack has occurred, and the operation of shutting down or reporting to the system administrator is executed.

Citation Information

Patent Citations

  • Inter-process persistent memory protection method working in kernel mode

    CN110147670A

  • Kernel data attack behavior detection method for virtualization platform operating system

    CN110737888A

  • Container security reinforcement system and method for kernel data

    CN114035886A

  • File reading and writing method and system, computer equipment and storage medium

    CN115630026A

  • Memory access method and device for core static data, equipment and storage medium

    CN117667769A

Cited By

  • Vulnerability detection method and device, storage medium and electronic equipment

    CN121659313A