[go: up one dir, main page]

CN114448666A - Monitoring and defense method, electronic device and system for cache attack - Google Patents

Monitoring and defense method, electronic device and system for cache attack Download PDF

Info

Publication number
CN114448666A
CN114448666A CN202111589222.8A CN202111589222A CN114448666A CN 114448666 A CN114448666 A CN 114448666A CN 202111589222 A CN202111589222 A CN 202111589222A CN 114448666 A CN114448666 A CN 114448666A
Authority
CN
China
Prior art keywords
refresh
current process
interval
time
malicious
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111589222.8A
Other languages
Chinese (zh)
Inventor
王益斌
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Telecom Cloud Technology Co Ltd
Original Assignee
China Telecom Cloud Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Telecom Cloud Technology Co Ltd filed Critical China Telecom Cloud Technology Co Ltd
Priority to CN202111589222.8A priority Critical patent/CN114448666A/en
Publication of CN114448666A publication Critical patent/CN114448666A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1408Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic by monitoring network traffic
    • H04L63/1425Traffic logging, e.g. anomaly detection
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1408Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic by monitoring network traffic
    • H04L63/1416Event detection, e.g. attack signature detection
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1441Countermeasures against malicious traffic

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention relates to the technical field of security, in particular to a monitoring and defending method of cache attack, electronic equipment and a system, wherein the method comprises the steps of obtaining a current process and starting time of the current process; recording the end time of the current process and the corresponding refreshing times of the current process; determining a time interval based on the start time and the end time; when the Time interval is between a first threshold and a second threshold and the refresh frequency is greater than a preset refresh frequency, determining that the current process is a malicious process to prevent the refresh operation of the current process, wherein the first threshold is between a first refresh interval and a second refresh interval, the first refresh interval is a normal refresh interval, the second refresh interval is a Spcetre attack interval, the second threshold is between a third refresh interval and a fourth refresh interval, the third refresh interval is a Flush and Time attack interval, and the fourth refresh interval is a Flush and Reload attack interval. By combining the time interval and the refreshing times, whether the attack is malicious or not can be confirmed in real time.

Description

缓存攻击的监测防御方法、电子设备及系统Monitoring and defense method, electronic device and system for cache attack

技术领域technical field

本发明涉及安全技术领域,具体涉及缓存攻击的监测防御方法、电子设备及系统。The invention relates to the technical field of security, in particular to a monitoring and defense method, electronic device and system for cache attacks.

背景技术Background technique

信息系统及软件系统依托特定的物理设备运行的过程中会产生电磁辐射、声音、时间、计算机CPU内存运算等多种物理状态信息。缓存侧信道攻击作为一种典型的侧信道攻击方法,就是基于对程序运行过程中CPU高速缓存进程之间高度交互且共享内存状态的分析,利用其内存访问时间和缓存访问时间不同的特性破解密码系统而实施的攻击。During the operation of information systems and software systems relying on specific physical equipment, various physical state information such as electromagnetic radiation, sound, time, and computer CPU memory operations will be generated. As a typical side channel attack method, cache side channel attack is based on the analysis of the highly interactive and shared memory state between CPU cache processes during program operation, and uses the characteristics of different memory access time and cache access time to crack passwords. systematic attack.

缓存侧信道攻击的隐蔽性与破坏力极强,但目前针对缓存侧信道攻击的防御措施仍然存在很多不足,特别是在ARM架构上针对刷新缓存的侧信道攻击的防御技术还不能实现实时监测,检测的准确性和分辨率也较低。The stealth and destructive power of cache side-channel attacks are extremely strong, but there are still many deficiencies in the current defense measures against cache side-channel attacks, especially on the ARM architecture. The detection accuracy and resolution are also lower.

发明内容SUMMARY OF THE INVENTION

有鉴于此,本发明实施例提供了一种缓存攻击的监测防御方法、电子设备及系统,以解决缓存攻击监测的准确性的问题。In view of this, embodiments of the present invention provide a method, electronic device and system for monitoring and defending a cache attack, so as to solve the problem of the accuracy of cache attack monitoring.

根据第一方面,本发明实施例提供了一种缓存攻击的监测防御方法,包括:According to a first aspect, an embodiment of the present invention provides a method for monitoring and defending a cache attack, including:

获取当前进程以及所述当前进程的启动时间;Obtain the current process and the startup time of the current process;

记录所述当前进程的结束时间以及所述当前进程对应的刷新次数;Record the end time of the current process and the refresh times corresponding to the current process;

基于所述启动时间以及所述结束时间,确定时间间隔;based on the start time and the end time, determining a time interval;

当所述时间间隔在第一阈值与第二阈值之间,且所述刷新次数大于预设刷新次数时,确定所述当前进程为恶意进程以阻止所述当前进程的刷新操作,所述第一阈值在第一刷新间隔与第二刷新间隔之间,所述第一刷新间隔为正常刷新间隔,所述第二刷新间隔为Spcetre攻击间隔,所述第二阈值在第三刷新间隔与第四刷新间隔之间,所述第三刷新间隔为Flush和Time攻击间隔,所述第四刷新间隔为Flush和Reload攻击间隔。When the time interval is between the first threshold and the second threshold, and the number of refreshes is greater than the preset number of refreshes, it is determined that the current process is a malicious process to prevent the refresh operation of the current process, and the first The threshold is between the first refresh interval and the second refresh interval, the first refresh interval is the normal refresh interval, the second refresh interval is the Spcetre attack interval, and the second threshold is between the third refresh interval and the fourth refresh interval Between the intervals, the third refresh interval is the Flush and Time attack interval, and the fourth refresh interval is the Flush and Reload attack interval.

本发明实施例提供的缓存攻击的监测防御方法,与正常进程频繁地刷新缓存不同,基于刷新的缓存攻击由于分支预测训练或加密具有一个必要且根本的特征,即在执行刷新操作时都需要间隔特定的时间,尽管不同的攻击具有不同的值,但是这些值都在一定范围之内,基于此通过对当前进程对应的时间间隔以及刷新次数,将时间间隔与第一阈值与第二阈值进行比较且将刷新次数与预设刷新次数进行比较,从而实时确认其是否为恶意攻击。The method for monitoring and defending a cache attack provided by the embodiment of the present invention is different from a normal process that frequently refreshes the cache. The refresh-based cache attack has a necessary and fundamental feature due to branch prediction training or encryption, that is, an interval is required when performing a refresh operation. At a specific time, although different attacks have different values, these values are all within a certain range. Based on this, by comparing the time interval and the number of refreshes corresponding to the current process, the time interval is compared with the first threshold and the second threshold. And the number of refreshes is compared with the number of preset refreshes, so as to confirm in real time whether it is a malicious attack.

可选地,所述当所述时间间隔在第一阈值与第二阈值之间,且所述刷新次数大于预设刷新次数时,确定所述当前进程为恶意进程以阻止所述当前进程的刷新操作,包括:Optionally, when the time interval is between the first threshold and the second threshold, and the refresh count is greater than a preset refresh count, determining that the current process is a malicious process to prevent the current process from being refreshed operations, including:

当所述时间间隔在第一阈值与第二阈值之间,且所述刷新次数大于预设刷新次数时,将告警值设置为目标值;When the time interval is between the first threshold and the second threshold, and the refresh count is greater than the preset refresh count, set the alarm value as the target value;

基于所述告警值确定所述当前进程为恶意进程以阻止所述当前进程的刷新操作。It is determined based on the alarm value that the current process is a malicious process to prevent a refresh operation of the current process.

本发明实施例提供的缓存攻击的监测防御方法,在确定当前进程为恶意进程之后将告警值设置为目标值以便于读取该告警值阻止当前进程的刷新操作,简化了数据处理过程。The method for monitoring and defending a cache attack provided by the embodiment of the present invention sets an alarm value as a target value after determining that the current process is a malicious process, so that the alarm value can be read to prevent the refresh operation of the current process, and the data processing process is simplified.

可选地,所述基于所述告警值确定所述当前进程为恶意进程,包括:Optionally, the determining that the current process is a malicious process based on the alarm value includes:

读取所述告警值,并确定所述当前进程为恶意进程,以阻止所述当前进程的刷新操作。The alarm value is read, and it is determined that the current process is a malicious process, so as to prevent the refresh operation of the current process.

本发明实施例提供的缓存攻击的监测防御方法,通过软件方式进行恶意进程的监测与防御,简单易于实现。The monitoring and defense method for a cache attack provided by the embodiment of the present invention performs monitoring and defense of malicious processes through software, which is simple and easy to implement.

可选地,所述基于所述告警值确定所述当前进程为恶意进程,包括:Optionally, the determining that the current process is a malicious process based on the alarm value includes:

将所述告警值写入告警寄存器,以使得所述告警寄存器触发中断并在中断服务程序中将所述当前进程记录为恶意进程,以阻止所述当前进程的刷新操作。The alarm value is written into an alarm register, so that the alarm register triggers an interrupt and records the current process as a malicious process in an interrupt service routine, so as to prevent a refresh operation of the current process.

本发明实施例提供的缓存攻击的监测防御方法,通过硬件中断防御措施实现缓存攻击的监测防御。The monitoring and defense method for a cache attack provided by the embodiment of the present invention realizes the monitoring and defense of the cache attack through hardware interruption defense measures.

可选地,所述基于所述告警值确定所述当前进程为恶意进程,包括:Optionally, the determining that the current process is a malicious process based on the alarm value includes:

将所述告警值写入告警寄存器,以使得刷新防御器从所述告警寄存器读取所述告警值并将所述当前进程记录为恶意进程,以阻止所述当前进程的刷新操作。The alert value is written into an alert register, so that the flush defender reads the alert value from the alert register and records the current process as a malicious process to prevent a flush operation of the current process.

本发明实施例提供的缓存攻击的监测防御方法,通过硬件告警寄存器的防御措施实现缓存攻击的监测防御。The monitoring and defense method for a cache attack provided by the embodiment of the present invention realizes the monitoring and defense of the cache attack through the defense measures of the hardware alarm register.

可选地,所述方法还包括:Optionally, the method further includes:

当确定所述当前进程不是恶意进程时,基于所述当前进程刷新第一级缓存以及第二级缓存。When it is determined that the current process is not a malicious process, the first level cache and the second level cache are refreshed based on the current process.

根据第二方面,本发明实施例提供了一种电子设备,包括:存储器和处理器,所述存储器和所述处理器之间互相通信连接,所述存储器中存储有计算机指令,所述处理器通过执行所述计算机指令,从而执行第一方面或者第一方面的任意一种实施方式中所述的缓存攻击的监测防御方法。According to a second aspect, an embodiment of the present invention provides an electronic device, including: a memory and a processor, the memory and the processor are connected in communication with each other, the memory stores computer instructions, and the processor By executing the computer instructions, the first aspect or the method for monitoring and defending a cache attack described in any implementation manner of the first aspect is executed.

根据第三方面,本发明实施例提供了一种计算机可读存储介质,所述计算机可读存储介质存储计算机指令,所述计算机指令用于使所述计算机执行第一方面或者第一方面的任意一种实施方式中所述的缓存攻击的监测防御方法。According to a third aspect, an embodiment of the present invention provides a computer-readable storage medium, where the computer-readable storage medium stores computer instructions, and the computer instructions are used to cause the computer to execute the first aspect or any one of the first aspect. A monitoring and defense method for a cache attack described in an embodiment.

根据第四方面,本发明实施例提供了缓存攻击的监测防御系统,包括:According to a fourth aspect, an embodiment of the present invention provides a monitoring and defense system for cache attacks, including:

本发明第二方面所述的电子设备;The electronic device described in the second aspect of the present invention;

告警寄存器,与所述电子设备连接,用于存储所述告警值。An alarm register, connected with the electronic device, is used to store the alarm value.

可选地,所述系统还包括:Optionally, the system further includes:

刷新防御器,与所述告警寄存器连接,用于读取所述告警寄存器存储的告警值,当所述告警值为目标值时确定所述当前进程为恶意进程以阻止所述当前进程的刷新操作。A refresh defender, connected to the alarm register, for reading the alarm value stored in the alarm register, and determining that the current process is a malicious process when the alarm value is a target value to prevent the refresh operation of the current process .

需要说明的是,本发明实施例提供的电子设备、计算可读存储介质以及缓存攻击的监测防御系统的有益效果,请参见上文缓存攻击的监测防御方法的相关描述,在此不再赘述。It should be noted that, for the beneficial effects of the electronic device, the computer-readable storage medium, and the cache attack monitoring and defense system provided by the embodiments of the present invention, please refer to the above description of the cache attack monitoring and defense method, which will not be repeated here.

附图说明Description of drawings

为了更清楚地说明本发明具体实施方式或现有技术中的技术方案,下面将对具体实施方式或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the specific embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the specific embodiments or the prior art. Obviously, the accompanying drawings in the following description The drawings are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative efforts.

图1示出了Spectre、Flush+Reload和Flush+Time攻击的刷新特征的示意图;Figure 1 shows a schematic diagram of the refresh features of Spectre, Flush+Reload and Flush+Time attacks;

图2是根据本发明实施例的刷新攻击的监测防御方法的流程图;FIG. 2 is a flowchart of a method for monitoring and defending a refresh attack according to an embodiment of the present invention;

图3是根据本发明实施例的刷新攻击的监测防御方法的流程图;3 is a flowchart of a method for monitoring and defending a refresh attack according to an embodiment of the present invention;

图4是根据本发明实施例的刷新攻击的监测防御方法的流程图;4 is a flowchart of a method for monitoring and defending a refresh attack according to an embodiment of the present invention;

图5是根据本发明实施例的刷新攻击的监测防御方法的流程图;FIG. 5 is a flowchart of a method for monitoring and defending a refresh attack according to an embodiment of the present invention;

图6是根据本发明实施例的刷新攻击的监测防御方法的流程图;FIG. 6 is a flowchart of a method for monitoring and defending a refresh attack according to an embodiment of the present invention;

图7是根据本发明实施例的FlushDetector模块接口的示意图;7 is a schematic diagram of a FlushDetector module interface according to an embodiment of the present invention;

图8是根据本发明实施例的刷新攻击的监测防御系统架构的示意图;FIG. 8 is a schematic diagram of a monitoring and defense system architecture of a refresh attack according to an embodiment of the present invention;

图9是本发明实施例提供的电子设备的硬件结构示意图。FIG. 9 is a schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present invention.

具体实施方式Detailed ways

为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments These are some embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of the present invention.

本发明在通过统计攻击过程的一般特征,尤其是刷新操作的特征的基础上,提出了一种实时监测防御方案SecFlush,本发明通过硬件设计检测恶意的刷新行为,并通过禁止恶意进程在内核驱动程序中执行刷新操作来防御基于刷新的缓存攻击。基于硬件的检测具有计算速度快、效率高和计时方便的优势。更重要的是,由于SecFlush是建立在基于刷新的缓存攻击能够实施的根本原因上,因此攻击者很难逃避这个硬件检测机制。且,由于刷新操作对于这种基于刷新的缓存攻击来说必不可少,因此SecFlush禁止恶意进程在执行刷新操作意味着基于刷新的攻击必然失败,攻击者也很难逃避这种软件防御机制。The invention proposes a real-time monitoring and defense scheme SecFlush on the basis of counting the general characteristics of the attack process, especially the characteristics of the refresh operation. The invention detects malicious refresh behaviors through hardware design, and prohibits malicious processes from driving in the kernel. The flush operation is performed in the program to defend against flush-based cache attacks. Hardware-based detection has the advantages of fast computation, high efficiency, and convenient timing. What's more, since SecFlush is based on the root cause of flush-based cache attacks, it is very difficult for attackers to evade this hardware detection mechanism. Moreover, since the flush operation is essential for such flush-based cache attacks, SecFlush prohibits malicious processes from performing flush operations, which means that flush-based attacks are bound to fail, and it is difficult for attackers to evade this software defense mechanism.

本发明是在刷新缓存攻击特征提取的基础上,得到用于时间阈值判断的第一阈值与第二阈值。在软件程序运行过程中,为了确保缓存一致性,即内存中数据与缓存中数据一致,操作系统需要频繁地刷新缓存,无论是DMA、多核异构处理器还是对称多处理器(SMP)架构都是这样运行程序,这些刷新是正常的操作。然而,这种基于刷新的缓存攻击的刷新操作具有不同的特点,由于需要训练分支预测器或加密等操作,缓存攻击在刷新缓存时,两次刷新操作之间会有一定的时间间隔(大于某个阈值)。并且为了提高攻击的成功率,攻击者会多次刷新同一个缓存行。因此,刷新是基于刷新的缓存攻击不可或缺的步骤,如果能够找到缓存攻击刷新基于刷新缓存攻击的硬件防御技术研究的特征就可以通过硬件实现来检测并及时防御所有基于刷新的缓存攻击。The present invention obtains the first threshold and the second threshold for judging the time threshold based on the extraction of the attack feature of the refresh cache. In the running process of a software program, in order to ensure cache coherence, that is, the data in the memory is consistent with the data in the cache, the operating system needs to frequently refresh the cache, whether it is DMA, multi-core heterogeneous processors or symmetric multi-processor (SMP) architectures. Running the program like this, these refreshes are normal operations. However, the refresh operation of this refresh-based cache attack has different characteristics. Due to the need to train branch predictors or operations such as encryption, when the cache attack refreshes the cache, there will be a certain time interval between two refresh operations (greater than a certain time interval). threshold). And in order to improve the success rate of the attack, the attacker will flush the same cache line multiple times. Therefore, flushing is an indispensable step for flush-based cache attacks. If we can find the characteristics of cache attack flush-based hardware defense technology research, we can detect and timely defend against all flush-based cache attacks through hardware implementation.

通过分析两次攻击刷新操作时间的数据,并将相邻两次刷新的时间间隔与次数之间的关系。如图1所示,可以看到刷新的间隔时间基本稳定但存在少量噪声且噪声偏大。By analyzing the data of the operation time of two attacks, and the relationship between the time interval and the number of two adjacent refreshes. As shown in Figure 1, it can be seen that the refresh interval is basically stable but there is a small amount of noise and the noise is too large.

对于Spectre攻击的刷新特征,图1中Loop1所代表的曲线,时间最短但次数最多,它是正常的刷新操作;Loop2所代表的曲线,间隔时间比Loop1大,这段时间间隔用来训练分支预测器,在Loop2中,刷新操作是一个恶意的刷新;Loop3的间隔时间最大,但次数最小,由于时间过大因此没有在图中表示,它是一次完整的Flush+Reload攻击时间。这是基于刷新的缓存攻击执行刷新操作的最大时间,因此大于Loop3的刷新是安全的。For the refresh feature of Spectre attack, the curve represented by Loop1 in Figure 1 has the shortest time but the most times, it is a normal refresh operation; the curve represented by Loop2 has a longer interval than Loop1, and this time interval is used to train branch prediction In Loop2, the refresh operation is a malicious refresh; in Loop3, the interval time is the largest, but the number of times is the smallest. Because the time is too large, it is not shown in the figure. It is a complete Flush+Reload attack time. This is the maximum time a flush-based cache attack can perform a flush operation, so flushes larger than Loop3 are safe.

对于Flush+Time攻击的刷新特征,Loopft代表Flush+Time攻击的刷新操作执行时所间隔的时间。Flush+Time攻击刷新操作的时间间隔比较均匀,这段间隔时间用于两次调用受害者进程的加密程序。Loopft的时间比Loopfr大,Loopft是一个恶意的刷新循环。For the refresh feature of the Flush+Time attack, Loopft represents the time interval between the execution of the refresh operation of the Flush+Time attack. Flush+Time attack refresh operation interval is relatively uniform, this interval is used to call the encryption program of the victim process twice. Loopft has a bigger time than Loopfr, which is a malicious refresh loop.

对于Flush+Reload攻击的刷新特征,在图1中Loopfr代表Flush+Reload攻击的刷新操作执行时的间隔时间。Flush+Reload攻击刷新操作的时间间隔同样比较均匀,这段间隔时间用来调用一次受害者进程的加密程序,Loopfr的时间比Loop2大,它同样是一个恶意的刷新循环。For the refresh feature of the Flush+Reload attack, Loopfr in Figure 1 represents the interval between the execution of the refresh operation of the Flush+Reload attack. The time interval of Flush+Reload attack refresh operation is also relatively uniform. This interval is used to call the encryption program of the victim process once. Loopfr has a longer time than Loop2, and it is also a malicious refresh cycle.

由于Loop2、Loopfr和Loopft是恶意的刷新循环,因此只要抓住Loop2、Loopfr和Loopft就检测到了基于刷新的缓存攻击。基于此,在本方案中设定了两个阈值,第一阈值T1与第二阈值T2,用来夹住Loop2、Loopfr和Loopft,在T1与T2之间的刷新都是恶意的刷新。T1的取值应该在Loop1与Loop2之间,这样既不会将正常的进程报错,又能够检测恶意的刷新。T1的取值十分重要,因为如果T1<Loop1会产生误报,如果T1>Loop2、Loopfr或Loopft,则会使得防御失败。T2的取值应该在Loopft与Loop3之间,在检测恶意刷新的同时使得去掉Loop2的Spcetre攻击不会被判定为恶意的。此外,本方案还设定了一个预设刷新次数malicious_number,用于判定恶意的进程。为了防止误报,我们决定只有恶意刷新的次数大于malicious_number的进程才被认为是恶意的进程。malicious_number的值越大越不容易产生误报,然而过大又不能够及时地检测到攻击或有可能产生漏报。因为Spectre攻击需要进行多次分支预测训练,从而诱导分支预测器进行错误的预测。每次训练都会产生一次恶意的刷新,分支预测训练超过5次的进程是一个恶意的进程。如图6所示,全局计时器、PMCCNTR和系统的时钟频率分别是是333MHz,667MHz和55MHz。使用全局计时器进行计时,将数据统一规约到了系统时钟频率上,进行阈值的选择。Since Loop2, Loopfr, and Loopft are malicious flush loops, flush-based cache attacks are detected as long as Loop2, Loopfr, and Loopft are caught. Based on this, two thresholds are set in this solution, the first threshold T1 and the second threshold T2, which are used to clamp Loop2, Loopfr, and Loopft. The refreshes between T1 and T2 are all malicious refreshes. The value of T1 should be between Loop1 and Loop2, so that the normal process will not be reported as an error, and malicious refreshes can be detected. The value of T1 is very important, because if T1<Loop1 will produce false positives, if T1>Loop2, Loopfr or Loopft, the defense will fail. The value of T2 should be between Loopft and Loop3. While detecting malicious refresh, the Spcetre attack that removes Loop2 will not be judged malicious. In addition, this solution also sets a preset number of refreshes malicious_number, which is used to determine malicious processes. To prevent false positives, we decided that only processes with malicious flushes greater than malicious_number are considered malicious. The larger the value of malicious_number is, the less likely it is to generate false positives. However, if it is too large, attacks cannot be detected in time or false positives may occur. Because the Spectre attack requires multiple branch prediction training, which induces the branch predictor to make wrong predictions. Each training generates a malicious refresh, and a process that trains branch prediction more than 5 times is a malicious process. As shown in Figure 6, the clock frequencies of the global timer, PMCCNTR and the system are 333MHz, 667MHz and 55MHz, respectively. The global timer is used for timing, the data is uniformly reduced to the system clock frequency, and the threshold is selected.

在本发明实施例中提出了三种监测防御措施,分别为:软件防御措施、硬件中断防御措施以及硬件告警寄存器防御措施。其中,对于软件防御措施,即通过软件的处理,确定恶意进程并阻止恶意进程的刷新操作;对于硬件终端防御措施,即通过有硬件的告警寄存器触发终端,在中断服务程序中确定恶意进程;对于硬件告警寄存器防御措施,通过读取告警寄存器的值,通过刷新防御器将恶意进程的标号发送给监测器。In the embodiment of the present invention, three monitoring defense measures are proposed, which are software defense measures, hardware interruption defense measures, and hardware alarm register defense measures. Among them, for software defense measures, that is, through software processing, determine the malicious process and prevent the refresh operation of the malicious process; for hardware terminal defense measures, that is, trigger the terminal through the hardware alarm register, and determine the malicious process in the interrupt service routine; The hardware alarm register defense measure, by reading the value of the alarm register, sends the label of the malicious process to the monitor by refreshing the defender.

根据本发明实施例,提供了一种刷新攻击的监测防御方法实施例,需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。According to an embodiment of the present invention, an embodiment of a method for monitoring and defending a refresh attack is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and , although a logical order is shown in the flowcharts, in some cases steps shown or described may be performed in an order different from that herein.

在本实施例中提供了一种刷新攻击的监测防御方法,可用于电子设备,如FPGA等,图2是根据本发明实施例的刷新攻击的监测防御方法的流程图,如图2所示,该流程包括如下步骤:In this embodiment, a method for monitoring and defending a refresh attack is provided, which can be used for electronic devices, such as an FPGA, etc. FIG. 2 is a flowchart of a method for monitoring and defending a refresh attack according to an embodiment of the present invention, as shown in FIG. 2 , The process includes the following steps:

S11,获取当前进程以及当前进程的启动时间。S11, obtain the current process and the start time of the current process.

在电子设备中设置有计时器,当监测到当前进程时,启动该计时器并记录当前进程的启动时间。同时,为了区分各个进程,每一个进程均具有唯一的标识。A timer is set in the electronic device, when the current process is monitored, the timer is started and the start time of the current process is recorded. At the same time, in order to distinguish each process, each process has a unique identifier.

S12,记录当前进程的结束时间以及当前进程对应的刷新次数。S12, record the end time of the current process and the refresh times corresponding to the current process.

电子设备记录当前进程的结束时间,并对当前进程所触发的刷新次数进行统计。The electronic device records the end time of the current process, and counts the number of refreshes triggered by the current process.

S13,基于启动时间以及结束时间,确定时间间隔。S13, based on the start time and the end time, determine a time interval.

电子设备计算结束时间与启动时间之间的差值,即确定该当前进程对应的时间间隔。The electronic device calculates the difference between the end time and the start time, that is, determines the time interval corresponding to the current process.

S14,当时间间隔在第一阈值与第二阈值之间,且刷新次数大于预设刷新次数时,确定当前进程为恶意进程以阻止当前进程的刷新操作。S14, when the time interval is between the first threshold and the second threshold, and the number of refreshes is greater than the preset number of refreshes, determine that the current process is a malicious process to prevent the refresh operation of the current process.

其中,所述第一阈值在第一刷新间隔与第二刷新间隔之间,所述第一刷新间隔为正常刷新间隔,所述第二刷新间隔为Spcetre攻击间隔,所述第二阈值在第三刷新间隔与第四刷新间隔之间,所述第三刷新间隔为Flush和Time攻击间隔,所述第四刷新间隔为Flush和Reload攻击间隔。The first threshold is between the first refresh interval and the second refresh interval, the first refresh interval is the normal refresh interval, the second refresh interval is the Spcetre attack interval, and the second threshold is the third Between the refresh interval and the fourth refresh interval, the third refresh interval is the Flush and Time attack interval, and the fourth refresh interval is the Flush and Reload attack interval.

电子设备将当前时间间隔与第一阈值以及第二阈值进行比较,且将刷新次数与预设刷新次数进行比较,若同时满足时间间隔在第一阈值与第二阈值之间,且刷新次数大于预设刷新次数,且可以确定当前进程为恶意进程,需要阻止该恶意进程的刷新操作。The electronic device compares the current time interval with the first threshold and the second threshold, and compares the number of refreshes with the preset number of refreshes. Set the number of refreshes, and it can be determined that the current process is a malicious process, and the refresh operation of the malicious process needs to be prevented.

本实施例提供的缓存攻击的监测防御方法,与正常进程频繁地刷新缓存不同,基于刷新的缓存攻击由于分支预测训练或加密具有一个必要且根本的特征,即在执行刷新操作时都需要间隔特定的时间,尽管不同的攻击具有不同的值,但是这些值都在一定范围之内,基于此通过对当前进程对应的时间间隔以及刷新次数,将时间间隔与第一阈值与第二阈值进行比较且将刷新次数与预设刷新次数进行比较,从而实时确认其是否为恶意攻击。The monitoring and defense method for a cache attack provided in this embodiment is different from a normal process that frequently refreshes the cache. The refresh-based cache attack has a necessary and fundamental feature due to branch prediction training or encryption, that is, a certain interval is required when performing a refresh operation. Although different attacks have different values, these values are all within a certain range. Based on this, by comparing the time interval and the number of refreshes corresponding to the current process, the time interval is compared with the first threshold and the second threshold and Compare the number of refreshes with the preset number of refreshes to confirm in real time whether it is a malicious attack.

在本实施例中提供了一种刷新攻击的监测防御方法,可用于电子设备,如FPGA等,图3是根据本发明实施例的刷新攻击的监测防御方法的流程图,如图3所示,该流程包括如下步骤:In this embodiment, a method for monitoring and defending a refresh attack is provided, which can be used for electronic devices, such as an FPGA, etc. FIG. 3 is a flowchart of a method for monitoring and defending a refresh attack according to an embodiment of the present invention, as shown in FIG. 3 , The process includes the following steps:

S21,获取当前进程以及当前进程的启动时间。S21, obtain the current process and the start time of the current process.

详细请参见图2所示实施例的S11,在此不再赘述。For details, please refer to S11 of the embodiment shown in FIG. 2 , which will not be repeated here.

S22,记录当前进程的结束时间以及当前进程对应的刷新次数。S22, record the end time of the current process and the refresh times corresponding to the current process.

详细请参见图2所示实施例的S12,在此不再赘述。For details, please refer to S12 of the embodiment shown in FIG. 2 , which will not be repeated here.

S23,基于启动时间以及结束时间,确定时间间隔。S23, based on the start time and the end time, determine the time interval.

详细请参见图2所示实施例的S13,在此不再赘述。For details, please refer to S13 of the embodiment shown in FIG. 2 , which will not be repeated here.

S24,当时间间隔在第一阈值与第二阈值之间,且刷新次数大于预设刷新次数时,确定当前进程为恶意进程以阻止当前进程的刷新操作。S24, when the time interval is between the first threshold and the second threshold, and the number of refreshes is greater than the preset number of refreshes, determine that the current process is a malicious process to prevent the refresh operation of the current process.

其中,所述第一阈值在第一刷新间隔与第二刷新间隔之间,所述第一刷新间隔为正常刷新间隔,所述第二刷新间隔为Spcetre攻击间隔,所述第二阈值在第三刷新间隔与第四刷新间隔之间,所述第三刷新间隔为Flush和Time攻击间隔,所述第四刷新间隔为Flush和Reload攻击间隔。The first threshold is between the first refresh interval and the second refresh interval, the first refresh interval is the normal refresh interval, the second refresh interval is the Spcetre attack interval, and the second threshold is the third Between the refresh interval and the fourth refresh interval, the third refresh interval is the Flush and Time attack interval, and the fourth refresh interval is the Flush and Reload attack interval.

具体地,上述S24包括:Specifically, the above S24 includes:

S241,当时间间隔在第一阈值与第二阈值之间,且刷新次数大于预设刷新次数时,将告警值设置为目标值。S241 , when the time interval is between the first threshold and the second threshold, and the number of refreshes is greater than the preset number of refreshes, set an alarm value as a target value.

在满足时间间隔与刷新次数的条件时,电子设备将告警值设置与目标值。例如,设置为1。当然,时间间隔或刷新次数不满足上述条件,电子设备也可以设置告警值,例如,设置为0。When the conditions of the time interval and the number of refreshes are satisfied, the electronic device sets the alarm value to the target value. For example, set to 1. Of course, if the time interval or the number of refreshes does not meet the above conditions, the electronic device may also set an alarm value, for example, set it to 0.

S242,基于告警值确定当前进程为恶意进程以阻止当前进程的刷新操作。S242 , based on the alarm value, determine that the current process is a malicious process to prevent the refresh operation of the current process.

电子设备基于该告警值就可以直接确定出当前进程为恶意进程,或者,电子设备将该告警值存入告警寄存器,以使得告警寄存器通过触发中断的方式确定恶意进程并阻止当前进程的刷新操作;或者,电子设备将该告警值存入告警寄存器,以使得刷新防御器从告警寄存器内读取到告警值并发送给监视器,在当前进程为恶意进程的情况下,监视器阻止当前进程的刷新操作。The electronic device can directly determine that the current process is a malicious process based on the alarm value, or the electronic device stores the alarm value in the alarm register, so that the alarm register can determine the malicious process by triggering an interrupt and prevent the refresh operation of the current process; Or, the electronic device stores the alarm value in the alarm register, so that the refresh defender reads the alarm value from the alarm register and sends it to the monitor. In the case that the current process is a malicious process, the monitor prevents the refresh of the current process. operate.

本实施例提供的缓存攻击的监测防御方法,在确定当前进程为恶意进程之后将告警值设置为目标值以便于读取该告警值阻止当前进程的刷新操作,简化了数据处理过程。In the monitoring and defense method for a cache attack provided by this embodiment, after determining that the current process is a malicious process, an alarm value is set as a target value so that the alarm value can be read to prevent the refresh operation of the current process, and the data processing process is simplified.

作为本实施例的一个具体应用实例,当该监测防御方法为软件防御措施时,检测部分由软件部分实现,用户通过调用FlushAPI进行刷新操作,从而调用FlushDefender内核驱动。具体流程如下:第一,驱动检测恶意进程,对于该进程刷新的时间间隔进行记录。第二,对于非恶意的进程刷新缓存L1和L2,否则禁止刷新(阻止攻击)。第三,如果在T1和T2刷新的次数超过malicious_number,则会将当前进程的pid记录为恶意进程的pid。As a specific application example of this embodiment, when the monitoring and defense method is a software defense measure, the detection part is implemented by the software part, and the user invokes the FlushAPI to perform a refresh operation, thereby invoking the FlushDefender kernel driver. The specific process is as follows: First, the driver detects a malicious process, and records the time interval at which the process is refreshed. Second, flush caches L1 and L2 for non-malicious processes, otherwise flushing is prohibited (preventing attacks). Third, if the number of refreshes at T1 and T2 exceeds malicious_number, the pid of the current process will be recorded as the pid of the malicious process.

具体地,如图5所示,用户通过调用FlushAPI进行刷新操作,从而调用FlushDefender内核驱动。此时硬件计时器开始计时,并记录当前进程的pid,告警值alarm清零,记录当前时间以计算出当前进程的刷新时间间隔。若时间间隔在T1与T2之间且刷新次数超过预设刷新次数N,则将告警值alarm置1,否则告警值alarm不变。当告警值alarm为1时,则记录当前进程pid为恶意进程pid。Specifically, as shown in Figure 5, the user invokes the FlushAPI to perform a refresh operation, thereby invoking the FlushDefender kernel driver. At this point, the hardware timer starts timing and records the pid of the current process, the alarm value alarm is cleared to zero, and the current time is recorded to calculate the refresh interval of the current process. If the time interval is between T1 and T2 and the number of refreshes exceeds the preset number of refreshes N, the alarm value alarm is set to 1, otherwise the alarm value alarm remains unchanged. When the alarm value alarm is 1, the current process pid is recorded as the malicious process pid.

作为本实施例的一个具体应用实例,当该监测防御方法为硬件中断防御措施时,用户通过调用FlushAPI进行刷新操作,从而调用FlushDefender内核驱动。具体流程如下:第一,驱动将当前进程的pid写入寄存器,触发硬件进行检测。第二,对于非恶意的进程刷新缓存L1和L2,否则禁止刷新(阻止攻击)。ecFlush:基于刷新缓存攻击的实时监测防御方案。三,与硬件告警寄存器防御措施的区别在于由硬件的告警寄存器触发中断,在中断服务程序中将当前进程的pid记录为恶意进程的pid。As a specific application example of this embodiment, when the monitoring and defense method is a hardware interruption defense measure, the user performs a refresh operation by invoking the FlushAPI, thereby invoking the FlushDefender kernel driver. The specific process is as follows: First, the driver writes the pid of the current process into the register, triggering the hardware to detect. Second, flush caches L1 and L2 for non-malicious processes, otherwise flushing is prohibited (preventing attacks). ecFlush: A real-time monitoring defense scheme based on flushing cache attacks. Third, the difference from the hardware alarm register defense measures is that the interrupt is triggered by the hardware alarm register, and the pid of the current process is recorded as the pid of the malicious process in the interrupt service routine.

具体地,如图6所示,当检测到当前进程时,记录当前进程的pid,将pid写入硬件寄存器,调用硬件检测,并将需要刷新的虚拟地址转变为物理地址。在硬件检测时,硬件计时器计时,并记录当前进程的pid,alarm清零,记录当前时间,以计算刷新时间间隔。若时间间隔在T1与T2之间且刷新次数超过预设刷新次数N,则将告警值alarm置1,否则告警值alarm不变。当告警值alarm为1时,触发中断,在中断服务程序中记录当前进程pid为恶意进程pid。Specifically, as shown in FIG. 6 , when the current process is detected, the pid of the current process is recorded, the pid is written into the hardware register, the hardware detection is called, and the virtual address that needs to be refreshed is converted into a physical address. During hardware detection, the hardware timer counts, records the pid of the current process, clears the alarm, records the current time, and calculates the refresh interval. If the time interval is between T1 and T2 and the number of refreshes exceeds the preset number of refreshes N, the alarm value alarm is set to 1, otherwise the alarm value alarm remains unchanged. When the alarm value alarm is 1, an interrupt is triggered, and the current process pid is recorded in the interrupt service routine as the malicious process pid.

作为本实施例的一个具体应用实例,当该监测防御方法为硬件告警寄存器防御措施时,在硬件告警寄存器防御措施中,用户通过调用FlushAPI进行刷新操作,从而调用FlushDefender内核驱动。具体流程如下:第一,驱动将当前进程的pid写入寄存器,触发硬件进行检测。硬件对于该进程刷新的时间间隔进行记录,如果在T1和T2刷新的次数超过malicious_number,则会将alarm寄存器的值拉高。第二,对于非恶意的进程基于刷新缓存攻击的硬件防御技术研究刷新缓存L1和L2,否则禁止刷新(阻止攻击)。第三,读取硬件告警寄存器的值,如果发现告警,则将当前进程的pid记录为恶意进程的pid。As a specific application example of this embodiment, when the monitoring and defense method is a hardware alarm register defense measure, in the hardware alarm register defense measure, the user performs a refresh operation by calling FlushAPI, thereby calling the FlushDefender kernel driver. The specific process is as follows: First, the driver writes the pid of the current process into the register, triggering the hardware to detect. The hardware records the refresh time interval of the process. If the number of refreshes in T1 and T2 exceeds the malicious_number, the value of the alarm register will be pulled up. Second, for non-malicious processes, based on the hardware defense technology of flushing cache attack, the flushing cache L1 and L2 are studied, otherwise flushing is prohibited (blocking the attack). Third, read the value of the hardware alarm register, and if an alarm is found, record the pid of the current process as the pid of the malicious process.

具体地,与上述图5所示实施例不同的是,刷新防御器通过ioread32()读取alarm寄存器的值,并确定当前进程是否为恶意进程。若读取到的alarm的值为1,则确认当前进程为恶意进程。Specifically, different from the embodiment shown in FIG. 5 above, the refresh defender reads the value of the alarm register through ioread32(), and determines whether the current process is a malicious process. If the read value of alarm is 1, it is confirmed that the current process is a malicious process.

本发明实施例还提供一种电子设备,请参阅图9,图9是本发明可选实施例提供的一种电子设备的结构示意图,如图9所示,该电子设备可以包括:至少一个处理器31,例如CPU(Central Processing Unit,中央处理器),至少一个通信接口33,存储器34,至少一个通信总线32。其中,通信总线32用于实现这些组件之间的连接通信。其中,通信接口33可以包括显示屏(Display)、键盘(Keyboard),可选通信接口33还可以包括标准的有线接口、无线接口。存储器34可以是高速RAM存储器(Random Access Memory,易挥发性随机存取存储器),也可以是非不稳定的存储器(non-volatile memory),例如至少一个磁盘存储器。存储器34可选的还可以是至少一个位于远离前述处理器31的存储装置。其中,存储器34中存储应用程序,且处理器31调用存储器34中存储的程序代码,以用于执行上述任一方法步骤。An embodiment of the present invention also provides an electronic device. Please refer to FIG. 9 . FIG. 9 is a schematic structural diagram of an electronic device provided by an optional embodiment of the present invention. As shown in FIG. 9 , the electronic device may include: at least one processing The device 31 is, for example, a CPU (Central Processing Unit, central processing unit), at least one communication interface 33 , a memory 34 , and at least one communication bus 32 . Among them, the communication bus 32 is used to realize the connection and communication between these components. The communication interface 33 may include a display screen (Display) and a keyboard (Keyboard), and the optional communication interface 33 may also include a standard wired interface and a wireless interface. The memory 34 may be a high-speed RAM memory (Random Access Memory, volatile random access memory), or may be a non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory 34 may also be at least one storage device located away from the aforementioned processor 31 . The application program is stored in the memory 34, and the processor 31 calls the program code stored in the memory 34 for executing any of the above method steps.

其中,通信总线32可以是外设部件互连标准(peripheral componentinterconnect,简称PCI)总线或扩展工业标准结构(extended industry standardarchitecture,简称EISA)总线等。通信总线32可以分为地址总线、数据总线、控制总线等。为便于表示,图9中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The communication bus 32 may be a peripheral component interconnect (PCI for short) bus or an extended industry standard architecture (EISA for short) bus or the like. The communication bus 32 can be divided into an address bus, a data bus, a control bus, and the like. For ease of presentation, only one thick line is used in FIG. 9, but it does not mean that there is only one bus or one type of bus.

其中,存储器34可以包括易失性存储器(英文:volatile memory),例如随机存取存储器(英文:random-access memory,缩写:RAM);存储器也可以包括非易失性存储器(英文:non-volatile memory),例如快闪存储器(英文:flash memory),硬盘(英文:hard diskdrive,缩写:HDD)或固态硬盘(英文:solid-state drive,缩写:SSD);存储器34还可以包括上述种类的存储器的组合。The memory 34 may include volatile memory (English: volatile memory), such as random-access memory (English: random-access memory, abbreviation: RAM); the memory may also include non-volatile memory (English: non-volatile memory) memory), such as flash memory (English: flash memory), hard disk (English: hard diskdrive, abbreviation: HDD) or solid-state drive (English: solid-state drive, abbreviation: SSD); the memory 34 may also include the above-mentioned types of memory The combination.

其中,处理器31可以是中央处理器(英文:central processing unit,缩写:CPU),网络处理器(英文:network processor,缩写:NP)或者CPU和NP的组合。The processor 31 may be a central processing unit (English: central processing unit, abbreviation: CPU), a network processor (English: network processor, abbreviation: NP), or a combination of CPU and NP.

其中,处理器31还可以进一步包括硬件芯片。上述硬件芯片可以是专用集成电路(英文:application-specific integrated circuit,缩写:ASIC),可编程逻辑器件(英文:programmable logic device,缩写:PLD)或其组合。上述PLD可以是复杂可编程逻辑器件(英文:complex programmable logic device,缩写:CPLD),现场可编程逻辑门阵列(英文:field-programmable gate array,缩写:FPGA),通用阵列逻辑(英文:generic arraylogic,缩写:GAL)或其任意组合。The processor 31 may further include a hardware chip. The above-mentioned hardware chip may be an application-specific integrated circuit (English: application-specific integrated circuit, abbreviation: ASIC), a programmable logic device (English: programmable logic device, abbreviation: PLD) or a combination thereof. The above-mentioned PLD may be a complex programmable logic device (English: complex programmable logic device, abbreviation: CPLD), a field programmable gate array (English: field-programmable gate array, abbreviation: FPGA), a general array logic (English: generic arraylogic , abbreviation: GAL) or any combination thereof.

可选地,存储器34还用于存储程序指令。处理器31可以调用程序指令,实现如本申请任一实施例中所示的缓存攻击的监测防御方法。Optionally, memory 34 is also used to store program instructions. The processor 31 may invoke program instructions to implement the method for monitoring and defending a cache attack as shown in any of the embodiments of the present application.

本发明实施例还提供了一种非暂态计算机存储介质,所述计算机存储介质存储有计算机可执行指令,该计算机可执行指令可执行上述任意方法实施例中的缓存攻击的监测防御方法。其中,所述存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)、随机存储记忆体(Random Access Memory,RAM)、快闪存储器(Flash Memory)、硬盘(HardDisk Drive,缩写:HDD)或固态硬盘(Solid-State Drive,SSD)等;所述存储介质还可以包括上述种类的存储器的组合。Embodiments of the present invention further provide a non-transitory computer storage medium, where the computer storage medium stores computer-executable instructions, and the computer-executable instructions can execute the method for monitoring and defending a cache attack in any of the foregoing method embodiments. Wherein, the storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a flash memory (Flash Memory), a hard disk (HardDisk) Drive, abbreviation: HDD) or solid-state drive (Solid-State Drive, SSD), etc.; the storage medium may also include a combination of the above-mentioned types of memories.

本发明实施例还提供了一种监测防御系统,包括电子设备以及告警寄存器。其中,电子设备的具体结构细节请参见上文所述。告警寄存器与电子设备连接,用于存储告警值。The embodiment of the present invention also provides a monitoring and defense system, which includes an electronic device and an alarm register. The specific structural details of the electronic device are referred to above. The alarm register is connected to the electronic device for storing the alarm value.

具体地,图8显示了整个系统架构,它由三个级别组成。用户层:用户进程,三个计时器API,刷新API和Monitor。操作系统层:三个计时器驱动程序和FlushDefender。硬件层:全局计时器,PMCCNTR计时器和缓存是系统随附的模块。NewTimer和FlushDetector使用FPGA实现的模块,它们通过AXI-GP接口连接到系统。FlushDetector和FlushDefender模块代表SecFlush的组件。Specifically, Figure 8 shows the overall system architecture, which consists of three levels. User layer: User process, three timer APIs, refresh API and Monitor. OS layer: Three timer drivers and FlushDefender. Hardware layer: Global timers, PMCCNTR timers and caches are modules that come with the system. NewTimer and FlushDetector use FPGA-implemented modules that connect to the system via an AXI-GP interface. The FlushDetector and FlushDefender modules represent components of SecFlush.

用户可以通过计时器API和刷新API调用计时器驱动程序和FlushDefender。计时器驱动程序用于获取精确的当前时间,该时间可以通过调用全局计时器,PMCCNTR计时器或新计时器来获得。FlushDetector是一个硬件检测模块,它记录每个刷新操作的基本数据,例如当前时间和进程的pid,它将记录的数据与基于刷新的缓存攻击的特征进行比较,以推断该进程是否执行了攻击。FlushDefender的基本功能是快速刷新L1和L2缓存行。而且,FlushDefender可以通过调用FlushDetector来检测异常。如果FlushDefender从FlushDetector收到警报,它将把当前进程记录为一个恶意进程,并通过禁止该恶意进程执行刷新操作,来防御基于刷新的缓存攻击。此外,它还会通过netlink将恶意进程的pid报告给Monitor。Monitor是一个用户级应用程序,它从内核层接收消息。User can call Timer Driver and FlushDefender through Timer API and Flush API. The timer driver is used to get the precise current time, which can be obtained by calling the global timer, the PMCCNTR timer, or a new timer. FlushDetector is a hardware detection module that records basic data for each flush operation, such as the current time and the pid of the process, and it compares the recorded data with the characteristics of flush-based cache attacks to infer whether the process performed the attack. The basic function of FlushDefender is to quickly flush L1 and L2 cache lines. Also, FlushDefender can detect anomalies by calling FlushDetector. If FlushDefender receives an alert from FlushDetector, it will log the current process as a malicious process and defend against flush-based cache attacks by preventing the malicious process from performing flush operations. Additionally, it reports the pid of the malicious process to Monitor via netlink. Monitor is a user-level application that receives messages from the kernel layer.

FlushDetector模块的接口如图7所示,将slv_reg_wren信号拉高,基础操作部件,这个模块要Detector操作组件,将总线寄存器偏移地址的值输入axi_awaddr[1:0],然后将进程pid输入s_axi_wdata[31:0]。clock_counter作为计时器,并将每个时钟周期增加1,将alarm信号清零。记录current_pid,last_time,计算当前进程的时间间隔。如果在T1与T2之间,则说明存在一个恶意的刷新,此时将刷新计时器(flush_counter)加1。如果刷新计时器(flush_counter)等于malicious_number,alarm输出信号拉高,从而写到总线寄存器上报警。如果时间间隔小于T1,则刷新计时器(flush_counter)保持不变。如果时间间隔大于T2,则说明没有攻击,刷新计时器(flush_counter)清零。The interface of the FlushDetector module is shown in Figure 7, the slv_reg_wren signal is pulled high, the basic operation component, this module requires the Detector to operate the component, input the value of the bus register offset address into axi_awaddr[1:0], and then input the process pid into s_axi_wdata[ 31:0]. clock_counter acts as a timer and increments each clock cycle by 1, clearing the alarm signal. Record current_pid, last_time, and calculate the time interval of the current process. If it is between T1 and T2, there is a malicious flush, and the flush_counter is incremented by 1. If the refresh timer (flush_counter) is equal to malicious_number, the alarm output signal is pulled high, thereby writing the alarm to the bus register. If the time interval is less than T1, the flush timer (flush_counter) remains unchanged. If the time interval is greater than T2, there is no attack, and the flush_counter is cleared.

由于ARMCortex-A9上没有用户层面刷新缓存行的指令,因此使用FlushDefender内核驱动,通过读写状态通用寄存器实现快速刷新L1,L2缓存行的基本功能,同时与硬件、用户层进行交互,来防御基于刷新的缓存攻击。使用CP15协处理器和CPSR寄存器(CurrentProgramStatusRegister)来刷新L1缓存行;使用PL310缓存控制器来刷新L2缓存行,这时刷新的地址是物理地址。Since there is no user-level instruction to refresh the cache line on the ARMCortex-A9, the FlushDefender kernel driver is used to quickly refresh the L1 and L2 cache lines by reading and writing the status general register. Flush cache attack. Use the CP15 coprocessor and the CPSR register (CurrentProgramStatusRegister) to refresh the L1 cache line; use the PL310 cache controller to refresh the L2 cache line, and the refreshed address is the physical address.

FlushDefender防御从内核的指针current获取current_pid。然后,它通过iowrite32()函数将current_pid写入总线寄存器,同时调用FlushDetector检测来检测攻击,然后虚拟地址被转换为物理地址。接下来,如果当前进程不是恶意进程,则FlushDetector清除L1和L2数据缓存行中的历史数据并使它们无效再进行写入操作。然后,本实施例提出的三种防御方法。第一种方法是通过ioread32()函数来读取特定总线寄存器alarm的值,这就是FlushDetector的检测结果。如果特定总线寄存器alarm的值被拉高,则当前进程将被记录为一个恶意进程,并通过netlink机制的sendusrmsg()函数将恶意进程的标号(malicious_pid)发送到Monitor。另一种方法是通过alarm寄存器触发中断,然后记录恶意进程并在中断服务例程中向Monitor发出警报。称此方法为“硬件中断防御”。第三种方法是软件防御措施,具体如上文所述。The FlushDefender defense gets the current_pid from the kernel's pointer current. Then, it writes the current_pid to the bus register through the iowrite32() function, and calls the FlushDetector detection to detect the attack, and then the virtual address is converted to a physical address. Next, if the current process is not malicious, FlushDetector clears the historical data in the L1 and L2 data cache lines and invalidates them before writing. Then, three defense methods are proposed in this embodiment. The first method is to read the value of a specific bus register alarm through the ioread32() function, which is the detection result of FlushDetector. If the value of the specific bus register alarm is pulled high, the current process will be recorded as a malicious process, and the malicious process's label (malicious_pid) will be sent to the Monitor through the sendusrmsg() function of the netlink mechanism. Another way is to trigger an interrupt via the alarm register, then log the malicious process and alert the Monitor in the interrupt service routine. Call this method "Hardware Interruption Defense". The third method is software defenses, as described above.

结合图7所示的系统,该缓存攻击的监测防御方法,包括:Combined with the system shown in Figure 7, the monitoring and defense method for the cache attack includes:

(1)硬件模块FlushDetector主要流程如下:(1) The main process of the hardware module FlushDetector is as follows:

步骤1:将slv_reg_wren信号拉高;Step 1: Pull the slv_reg_wren signal high;

步骤2:将总线寄存器偏移地址的值输入axi_awaddr[1:0];Step 2: Input the value of the bus register offset address into axi_awaddr[1:0];

步骤3:后将进程pid输入s_axi_wdata[31:0];Step 3: Then input the process pid into s_axi_wdata[31:0];

步骤4:clock_counter作为计时器,并将每个时钟周期增加1;Step 4: clock_counter acts as a timer and increments each clock cycle by 1;

步骤5:将alarm信号清零;Step 5: Clear the alarm signal to zero;

步骤6:记录current_pid,last_time,计算当前进程的时间间隔;Step 6: Record current_pid, last_time, and calculate the time interval of the current process;

步骤7:如果在阈值1与阈值2之间,则说明存在一个恶意的刷新,此时将刷新计时器(flush_counter)加1;Step 7: If it is between threshold 1 and threshold 2, it means that there is a malicious flush, and the flush_counter is incremented by 1;

步骤8:如果刷新计时器(flush_counter)等于malicious_number,则alarm输出信号拉高,从而写到总线寄存器上报警。Step 8: If the refresh timer (flush_counter) is equal to malicious_number, the alarm output signal is pulled high, and the alarm is written to the bus register.

步骤9:如果时间间隔小于Threshold1,则刷新计时器(flush_counter)保持不变;Step 9: If the time interval is less than Threshold1, the refresh timer (flush_counter) remains unchanged;

步骤10:如果时间间隔大于Threshold2,则说明没有攻击,刷新计时器(flush_counter)清零。Step 10: If the time interval is greater than Threshold2, it means there is no attack, and the flush_counter is cleared.

(2)FlushDefender内核驱动程序模块防御攻击;(2) FlushDefender kernel driver module defends against attacks;

步骤1:FlushDefender从内核的指针current获取current_pid;Step 1: FlushDefender obtains current_pid from the kernel's pointer current;

步骤2:通过iowrite32()函数将current_pid写入总线寄存器;Step 2: Write current_pid to the bus register through the iowrite32() function;

步骤3:调用FlushDetector来检测攻击,然后虚拟地址被转换为物理地址;Step 3: The FlushDetector is called to detect the attack, and then the virtual address is converted to a physical address;

步骤4:如果当前进程不是恶意进程,则FlushDetector清除L1和L2数据缓存行并使它们无效;Step 4: If the current process is not malicious, FlushDetector clears the L1 and L2 data cache lines and invalidates them;

步骤5:通过ioread32()函数来读取特定总线寄存器alarm的值,这就是FlushDetector的检测结果。如果特定总线寄存器alarm的值被拉高,则当前进程将被记录为一个恶意进程,并通过netlink机制的sendusrmsg()函数将恶意进程的标号(malicious_pid)发送到Monitor;Step 5: Read the value of the specific bus register alarm through the ioread32() function, which is the detection result of the FlushDetector. If the value of the specific bus register alarm is pulled high, the current process will be recorded as a malicious process, and the malicious process label (malicious_pid) will be sent to the Monitor through the sendusrmsg() function of the netlink mechanism;

步骤6:通过alarm寄存器触发中断,然后记录恶意进程并在中断服务例程中向Monitor发出警报。Step 6: Trigger an interrupt via the alarm register, then log the malicious process and alert the Monitor in the interrupt service routine.

通过分析出与正常进程频繁地刷新缓存不同,基于刷新的缓存攻击由于分支预测训练或加密具有一个必要且根本的特征,即在执行刷新操作时都需要间隔特定的时间,尽管不同的攻击具有不同的值,但是这些值都在一定范围之内。然后采用软硬件相结合的方式构建防御体系,由FlushDetector硬件模块根据缓存攻击的刷新特征实时监测恶意进程,再由FlushDefender软件内核驱动禁止恶意进程执行刷新操作来防御攻击。最后设计合理的硬件模块和软件模块实现对缓存侧信道攻击的实时监测和有效防御,准确性高,时间开销小,从而解决ARM架构移动终端面临的严重攻击威胁。By analyzing, different from the frequent flushing of the cache by the normal process, the flush-based cache attack has a necessary and fundamental feature due to branch prediction training or encryption, that is, the flushing operation needs to be performed at a specific time interval, although different attacks have different values, but these values are within a certain range. Then, a defense system is constructed by combining software and hardware. The FlushDetector hardware module monitors malicious processes in real time according to the refresh characteristics of cache attacks, and the FlushDefender software kernel driver prohibits malicious processes from performing refresh operations to defend against attacks. Finally, reasonable hardware modules and software modules are designed to realize real-time monitoring and effective defense of cache side-channel attacks, with high accuracy and small time overhead, thus solving the serious attack threat faced by ARM-based mobile terminals.

虽然结合附图描述了本发明的实施例,但是本领域技术人员可以在不脱离本发明的精神和范围的情况下做出各种修改和变型,这样的修改和变型均落入由所附权利要求所限定的范围之内。Although the embodiments of the present invention have been described with reference to the accompanying drawings, various modifications and variations can be made by those skilled in the art without departing from the spirit and scope of the present invention, and such modifications and variations fall within the scope of the appended claims within the limits of the requirements.

Claims (10)

1. A monitoring and defense method for cache attacks is characterized by comprising the following steps:
acquiring a current process and starting time of the current process;
recording the end time of the current process and the refreshing times corresponding to the current process;
determining a time interval based on the start time and the end time;
when the Time interval is between a first threshold and a second threshold and the refresh frequency is greater than a preset refresh frequency, determining that the current process is a malicious process to prevent refresh operation of the current process, wherein the first threshold is between a first refresh interval and a second refresh interval, the first refresh interval is a normal refresh interval, the second refresh interval is a Spcetre attack interval, the second threshold is between a third refresh interval and a fourth refresh interval, the third refresh interval is a Flush and Time attack interval, and the fourth refresh interval is a Flush and Reload attack interval.
2. The method according to claim 1, wherein when the time interval is between a first threshold and a second threshold and the refresh time is greater than a preset refresh time, determining that the current process is a malicious process to prevent a refresh operation of the current process comprises:
when the time interval is between a first threshold value and a second threshold value and the refreshing time is greater than a preset refreshing time, setting an alarm value as a target value;
and determining that the current process is a malicious process based on the alarm value so as to prevent the refresh operation of the current process.
3. The method of claim 2, wherein the determining that the current process is a malicious process based on the alert value comprises:
and reading the alarm value, and determining that the current process is a malicious process so as to prevent the refreshing operation of the current process.
4. The method of claim 2, wherein the determining that the current process is a malicious process based on the alert value comprises:
and writing the alarm value into an alarm register so that the alarm register triggers an interrupt and records the current process as a malicious process in an interrupt service program to prevent the refresh operation of the current process.
5. The method of claim 2, wherein the determining that the current process is a malicious process based on the alert value comprises:
and writing the alarm value into an alarm register so that the refresh defensive device reads the alarm value from the alarm register and records the current process as a malicious process to prevent the refresh operation of the current process.
6. The method of claim 1, further comprising:
when the current process is determined not to be a malicious process, refreshing a first-level cache and a second-level cache based on the current process.
7. An electronic device, comprising:
a memory and a processor, the memory and the processor being communicatively connected to each other, the memory having stored therein computer instructions, the processor executing the computer instructions to perform the method for monitoring and defending against cache attacks according to any one of claims 1 to 6.
8. A computer-readable storage medium storing computer instructions for causing a computer to execute the method for monitoring and defending against cache attacks according to any one of claims 1 to 6.
9. A monitoring and defense system for cache attacks, comprising:
the electronic device of claim 7;
and the alarm register is connected with the electronic equipment and used for storing the alarm value.
10. The system of claim 9, further comprising:
and the refresh defensive device is connected with the alarm register and is used for reading the alarm value stored in the alarm register and determining that the current process is a malicious process to prevent the refresh operation of the current process when the alarm value is a target value.
CN202111589222.8A 2021-12-23 2021-12-23 Monitoring and defense method, electronic device and system for cache attack Pending CN114448666A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111589222.8A CN114448666A (en) 2021-12-23 2021-12-23 Monitoring and defense method, electronic device and system for cache attack

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111589222.8A CN114448666A (en) 2021-12-23 2021-12-23 Monitoring and defense method, electronic device and system for cache attack

Publications (1)

Publication Number Publication Date
CN114448666A true CN114448666A (en) 2022-05-06

Family

ID=81364462

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111589222.8A Pending CN114448666A (en) 2021-12-23 2021-12-23 Monitoring and defense method, electronic device and system for cache attack

Country Status (1)

Country Link
CN (1) CN114448666A (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9436603B1 (en) * 2014-02-27 2016-09-06 Amazon Technologies, Inc. Detection and mitigation of timing side-channel attacks

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9436603B1 (en) * 2014-02-27 2016-09-06 Amazon Technologies, Inc. Detection and mitigation of timing side-channel attacks

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
CHURAN TANG: "Flush+Time:一种高精度和高分辨率ARM-FPGA嵌入式SoC的缓存攻击", 《IEEE》, 4 June 2020 (2020-06-04), pages 2 - 3 *
CHURAN TANG: "SecFlush:一种针对基于刷新的缓存攻击的检测与防御的硬件/软件设计", 《SPRINGER》, 31 December 2020 (2020-12-31), pages 3 *

Similar Documents

Publication Publication Date Title
US11363058B2 (en) Detecting execution of modified executable code
US11777705B2 (en) Techniques for preventing memory timing attacks
US10185824B2 (en) System and method for uncovering covert timing channels
US9542557B2 (en) Snoop-based kernel integrity monitoring apparatus and method thereof
KR101701014B1 (en) Reporting malicious activity to an operating system
US10140449B2 (en) Cluster anomaly detection using function interposition
JP2012195016A (en) System and method for identifying and preventing security violation within computer system
US10395033B2 (en) System, apparatus and method for performing on-demand binary analysis for detecting code reuse attacks
WO2020005450A1 (en) Heuristic and machine-learning based methods to prevent fine-grained cache side-channel attacks
CN108388814A (en) Method, detection device and the detecting system of measurement processor
JP2022537079A (en) Behavior-based VM resource capture for forensics
US11126721B2 (en) Methods, systems and apparatus to detect polymorphic malware
CN111898127A (en) A method and system for resisting Spectre attack based on flush operation
US9015374B2 (en) Virtual interrupt filter
CN114139154A (en) A malicious code detection method, device, computer and readable storage medium
CN114448666A (en) Monitoring and defense method, electronic device and system for cache attack
CN110516445B (en) Identification method and device for anti-detection malicious code and storage medium
US9880947B2 (en) Return oriented programming stack pivoting protection
CN106909840A (en) A kind of method and device of monitor operating system behavior
JP5069406B2 (en) System and method for identifying and preventing security breaches in computer systems
CN106909838A (en) A kind of method and device of hooking system service call
US20240354404A1 (en) Migration of attacking software as a mitigation to an attack by a malicious actor
US11966471B2 (en) Interrupt latency and interval tracking
WO2021207874A1 (en) Non-secure software detection apparatus and detection method, and storage medium
CN115694981A (en) Method and device for preventing side channel information leakage

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination