Replay attack prevention method and system for in-vehicle communication

By encrypting fresh value transmission during vehicle startup, employing cross-protocol timing coding, and implementing dynamic defense switching strategies, the security risks of the SecOC mechanism during vehicle startup and the timing disruption issues in hybrid bus networks are addressed, thereby improving the reliability and real-time performance of vehicle communication against replay attacks.

CN121367591APending Publication Date: 2026-01-20SINO TRUK JINAN POWER CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511754251.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-26
Publication Date
2026-01-20

AI Technical Summary

Technical Problem

The existing SecOC mechanism has security risks in the transmission of plaintext fresh values ​​during the vehicle startup phase, timing issues caused by protocol differences in hybrid bus networks, and resource exhaustion under high-traffic attacks, which affect the reliability of vehicle communication against replay attacks.

Method used

By encrypting the transmission of fresh values ​​with a hardware encryption module before the SecOC module is activated, and by utilizing cross-protocol timing coding and continuity verification mechanisms, combined with a dynamic defense switching strategy, unified synchronization of the time base, dynamic switching of hardware encryption and lightweight signature verification algorithms are achieved, thereby enhancing the security of vehicle communication and its resistance to replay attacks.

Benefits of technology

It effectively reduces safety risks during vehicle startup, enhances the ability to identify cross-protocol replay attacks in hybrid bus networks, ensures the normal operation of core security functions under high-traffic attacks, and quickly restores the consistency of security policies after the attack subsides.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121367591A_ABST
    Figure CN121367591A_ABST
Patent Text Reader

Abstract

The invention provides an in-vehicle communication replay attack prevention method and system, and belongs to the technical field of in-vehicle communication security. According to the method, after a vehicle is ignited, each ECU local clock is synchronized through a time service protocol, and clock register write protection is started; before the SecOC module is activated, a hardware encryption module is used for dynamically generating a secret key encryption fresh value bound with a PUF (Physical Unclonable Function) of a receiving end and transmitting the secret key encryption fresh value; the sending end fuses the current fresh value and the multi-bus protocol identifier to generate a time sequence verification code and writes the time sequence verification code into a message; the gateway checks the logical continuity of the time sequence verification code and discards the message exceeding the bus delay threshold value; monitoring attack traffic in real time, switching to a lightweight signature verification algorithm when the attack traffic exceeds a threshold value, and starting a hardware-level repeated message filter to distribute signature verification computing power according to an ASIL security level; the signature verification algorithm is reset continuously when the value is lower than the recovery threshold value, and the filter cache is emptied. According to the method, the fresh value plaintext transmission risk in the vehicle starting stage can be effectively defended, the computing power distribution is dynamically optimized, and the replay attack is prevented.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of in-vehicle communication security, and more particularly to an in-vehicle communication replay attack prevention method and system. BACKGROUND

[0002] With the rapid development of intelligent networked vehicles, the in-vehicle network architecture is becoming increasingly complex, and intelligent in-vehicle communication security has become the focus of industry attention. Among various security threats, replay attacks are particularly prominent due to their low implementation threshold and great harm. By maliciously repeating the sending of legitimate network packets, unauthorized control of vehicle functions can be achieved, seriously threatening road safety. To address this risk, the AUTOSAR standard proposes a SecOC (Secure Onboard Communication) security mechanism. This mechanism works in conjunction with Freshness Value (FV) and Message Authentication Code (MAC) to provide message authentication and replay protection for bus communication such as CAN / CAN FD, and has become the core technology for current vehicle communication security.

[0003] However, in practical applications, it is found that the existing SecOC mechanism has obvious defects in replay protection reliability. First, during the initialization phase of vehicle startup, the freshness value is usually transmitted in plaintext form on the bus during synchronization between electronic control units (ECUs), which provides an excellent attack window for attackers. Attackers can easily eavesdrop and intercept this initial freshness value, and then construct effective replay messages, causing the vehicle to be exposed to security risks at the moment of startup. Second, in mixed networks containing CAN FD and CAN buses with different rates and protocols, SecOC usually establishes independent key chains and verification processes for different buses. Due to inherent differences in protocol timing between different buses, the gateway is prone to timing misalignment when forwarding cross-bus messages, making it difficult for low-speed ECUs to effectively identify replay attack messages from high-speed buses, forming a protection blind area.

[0004] In addition, the existing SecOC mechanism is not effective in the face of high-traffic attacks. It usually uses fixed, computationally complex cryptographic algorithms (such as AES-128) to sign all messages. When an attacker launches a message flooding attack on the network, the limited computing resources of the ECUs will be quickly exhausted by the signature operation, causing normal communication services to be blocked or security functions to be bypassed, resulting in the failure of the overall security system. In summary, the existing technology has three major defects: security vulnerabilities during startup, poor timing coordination in mixed buses, and lack of resource adaptation capability under high load, which seriously restricts the replay protection reliability of the SecOC mechanism, and a more perfect in-vehicle communication security solution is urgently needed. SUMMARY

[0005] To solve the above problems, the present application aims to provide a replay attack prevention method and system for in-vehicle communication, which solves the security risk of plaintext transmission in the vehicle starting stage by encrypting the transmission freshness value using a hardware encryption module before activating the SecOC module; uses cross-protocol timing coding and continuity verification mechanism to solve the timing fragmentation problem caused by protocol differences in hybrid buses; uses a dynamic defense switching strategy to cope with the resource exhaustion risk in high-flow attack scenarios; and finally builds a comprehensive defense system covering startup security, cross-protocol collaboration, load adaptation, and time reference protection, to improve the anti-replay attack reliability of the vehicle-mounted network.

[0006] To achieve the above-mentioned purposes, the present application realizes the following technical solutions: In a first aspect, the present application provides a replay attack prevention method for in-vehicle communication, comprising: After the vehicle ignition signal response, synchronizing the local clock of each electronic control unit to a unified time reference through a secure time protocol; Before activating the SecOC module, the sending end electronic control unit calls the hardware encryption module, generates an encryption key, and encrypts the initial freshness value, forms a secure synchronization message, and sends it to the receiving end electronic control unit; After activating the SecOC module, the sending end electronic control unit fuses the current freshness value and multi-bus protocol identifier for the message to be transmitted across the bus, generates a timing verification code, and writes the timing verification code into the authentication field of the message to generate a communication message; After the gateway receives the communication message, parse the timing verification code in it, and check its logical continuity, if the actual arrival time increment of the communication message exceeds the dynamic transmission delay threshold, perform a discard operation on the communication message; Real-time monitoring of attack flow rate on the bus; when the attack flow rate exceeds the first set threshold, switch the message authentication code verification algorithm to a lightweight mode, and at the same time enable the hardware-level duplicate message filter; When the attack flow rate continues to be lower than the second recovery threshold, reset the message authentication code verification algorithm to the standard mode, and clear the cache of the hardware-level duplicate message filter.

[0007] In an optional embodiment, after the vehicle ignition signal response, synchronizing the local clock of each electronic control unit to a unified time reference through a secure time protocol, comprising: After the vehicle ignition signal response, each electronic control unit synchronizes its local clock with the master clock source through a secure time synchronization protocol; the master clock source broadcasts a time synchronization message containing its master clock identifier and a 64-bit precise timestamp during the synchronization process; after synchronization is complete, each electronic control unit enables the write protection mechanism of the clock register and records the master clock identifier and the 64-bit timestamp of the final synchronization success, which together constitute the protected unified time reference; The secure execution environment verifies the digital signature of the secure time synchronization protocol and enables the write protection latch of the clock register after clock alignment, preventing untrusted firmware from modifying the clock drift compensation parameters.

[0008] In an optional embodiment, before the SecOC module is activated, the sending electronic control unit calls the hardware encryption module to generate an encryption key and encrypt the initial freshness value, form a secure synchronization message, and send it to the receiving electronic control unit, including: Before the SecOC module is activated, the master sending electronic control unit sends a physically unclonable function challenge code to the receiving electronic control unit; after receiving the challenge code, the receiving electronic control unit generates a PUF response through its integrated special PUF circuit and sends it to the sending electronic control unit; the sending electronic control unit calls the key generation engine in the built-in hardware encryption module, uses the PUF response and a random number seed from the hardware true random number generator as input, and uses the key derivation function to generate a dynamic encryption key for this communication session; The sending electronic control unit reads the pre-set initial freshness value from the built-in memory, calls the hardware encryption module, uses the AES-CBC encryption algorithm, uses the dynamic encryption key and a newly generated random initialization vector to perform encryption operations on the initial freshness value, and generates an encrypted initial freshness value; The private key of the sending electronic control unit is used to digitally sign the encrypted initial freshness value and the random initialization vector to generate a digital signature field; Get the master clock identifier and 64-bit timestamp, generate a secure synchronization message combined with the digital signature field, and set the secure synchronization message identifier in the message header; send the secure synchronization message to the receiving electronic control unit through the bus.

[0009] In an optional embodiment, before the SecOC module is activated, the sending electronic control unit calls the hardware encryption module to generate an encryption key and encrypt the initial freshness value, form a secure synchronization message, and send it to the receiving electronic control unit, including: When the bus load exceeds the pre-set load threshold, the hardware firewall deployed in the gateway intercepts messages that do not carry the secure synchronization message identifier, and records event logs in the secure storage area.

[0010] In an optional embodiment, after the SecOC module is activated, the sending end electronic control unit fuses the current freshness value and the multi-bus protocol identifier for the message to be transmitted across the bus, generates a time sequence verification code, and writes the time sequence verification code into the authentication field of the message to generate a communication message, including: After the SecOC module is activated, the sending end electronic control unit determines the target bus type of the message to be sent; if the target bus is a time-sensitive bus, the time slot identifier corresponding to the current communication period is extracted as the multi-bus protocol identifier; if the target bus is an event-triggered bus, the arbitration identifier of the message itself is extracted as the multi-bus protocol identifier; and the extracted multi-bus protocol identifier is uniformly encoded into a protocol context field of a fixed length; The current freshness value is obtained from the activated SecOC module; the protocol context field and the current freshness value are spliced by calling the hardware security module to form a to-be-verified primitive; Using the time sequence verification key pre-shared with the gateway, an AES-CMAC algorithm is used to calculate the to-be-verified primitive to generate a cryptographic digest, and the first 64 bits of the cryptographic digest are intercepted as the time sequence verification code of the message; Based on the to-be-sent message, the time sequence verification code is written into the SecOC authentication field of the message as extended authentication information to form a communication message.

[0011] In an optional embodiment, after the gateway receives the communication message, the time sequence verification code therein is parsed and its logical continuity is verified, and if the actual arrival time increment of the communication message exceeds the dynamic transmission delay threshold, a discard operation is performed on the communication message, including: The gateway records the arrival time stamp T1 of the communication message when it is received; The time sequence verification code TVC1, the freshness value FV1, and the source address in the data frame header are parsed from the SecOC authentication field of the communication message; According to the source address, the arrival time stamp T0 and the freshness value FV0 of the last communication message maintained by the gateway for the address are queried; It is calculated and judged whether the freshness value increment AFV=FV1–FV0 is greater than zero; if not, a discard operation is performed on the communication message; The actual arrival time increment AT of the consecutive communication messages is calculated by the formula AT=T1–T0; the dynamic transmission delay threshold is calculated according to the target bus type and the real-time bus load rate; it is judged whether AT is less than or equal to the dynamic transmission delay threshold; if not, a discard operation is performed on the communication message; The source address and the target bus type, in combination with the freshness value FV1, reconstruct the expected value of the time sequence verification code TVC0 locally according to the same algorithm as the sending electronic control unit, and compare it with TVC1; if TVC0 is inconsistent with TVC1, the communication message is discarded.

[0012] In an optional embodiment, the dynamic transmission delay threshold is calculated according to the target bus type and the real-time bus load rate, including: The dynamic transmission delay threshold ΔT_max is calculated by the formula ΔT_max=k•(1+α•BusLoad%); Wherein, k is a static delay reference determined according to the basic physical characteristics of the target bus type, and α is a load-sensitive coefficient, and BusLoad% is the real-time bus load rate.

[0013] In an optional embodiment, the attack traffic rate on the bus is monitored in real time; when the attack traffic rate exceeds a first set threshold, the message authentication code verification algorithm is switched to a lightweight mode, and a hardware-level repeated message filter is enabled at the same time, including: The attack traffic rate on the bus is counted in real time by the hardware flow monitor of the gateway; The attack traffic rate is compared with the first set threshold; when the attack traffic rate exceeds the first set threshold, the security policy manager is configured according to the differential signature algorithm of the message according to the functional safety level of the message; For ASIL-D level messages, the original standard AES-CMAC algorithm is maintained; For ASIL-B level messages, the CRC32-CMAC algorithm is switched to a lightweight mode; For QM level messages, the complete message authentication code calculation is suspended, and a fast CRC32 check is performed on the data payload; The hardware-level repeated message filter is enabled to intercept messages that are continuously received and have invalid message authentication codes.

[0014] In an optional embodiment, the clearing of the cache of the hardware-level repeated message filter includes clearing the pre-filter blacklist and restoring the standard message authentication code length.

[0015] In a second aspect, the embodiments of the present application also provide a replay attack prevention system for in-vehicle communication, including: A time reference management module is configured to synchronize the local clock of each electronic control unit to a unified time reference through a secure time service protocol after a vehicle ignition signal response; A security synchronization module is configured to, before the SecOC module is activated, call the hardware encryption module by the sending end electronic control unit, generate an encryption key and encrypt the initial freshness value, form a security synchronization message and send it to the receiving end electronic control unit. A time sequence encoding module is configured to, after the SecOC module is activated, fuse the current freshness value and the multi-bus protocol identifier for the message to be transmitted across the bus by the sending end electronic control unit, generate a time sequence verification code, and write the time sequence verification code into the authentication field of the message to generate a communication message. A continuity verification module is configured to, after the gateway receives the communication message, parse the time sequence verification code therein and verify the logical continuity thereof, and if the actual arrival time increment of the communication message exceeds the dynamic transmission delay threshold, perform a discarding operation on the communication message. A dynamic defense management module is configured to monitor the attack traffic rate on the bus in real time, switch the message authentication code verification algorithm to a lightweight mode when the attack traffic rate exceeds a first set threshold, and simultaneously enable a hardware-level repeated message filter. A security state recovery module is configured to reset the message authentication code verification algorithm to a standard mode and clear the cache of the hardware-level repeated message filter when the attack traffic rate continuously falls below a second recovery threshold.

[0016] In a third aspect, the embodiments of the present application further provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the replay attack prevention method for in-vehicle communication according to any one of the above embodiments when executing the program.

[0017] From the above technical solutions, the present application has the following advantages: In the replay attack prevention method for in-vehicle communication provided by the present application, the transmission freshness value is encrypted by the hardware encryption module before the SecOC module is activated, which effectively reduces the security risk of plaintext transmission of the freshness value in the vehicle startup stage and reduces the possibility of replay attack by the attacker using the initialization window. Then, the cross-protocol time sequence verification code is generated by fusing the time-sensitive bus time slot identifier and the event-triggered bus arbitration identifier, which, in combination with the message discarding mechanism of the gateway for the message exceeding the transmission delay threshold, improves the collaborative identification capability of the mixed bus network for cross-protocol replay attack, alleviates the time sequence fragmentation problem caused by the difference between bus protocols in the traditional scheme, and effectively prevents replay attack through the SecOC mechanism.

[0018] The application switches the lightweight signature verification algorithm based on the bus attack traffic rate and enables the hardware level duplicate message filter, allocates signature verification algorithm resources to ASIL safety level in high load, so that the system maintains the core security function operation in high traffic attack scene; enables lightweight message authentication code verification and injects pseudo random number padding message for non-safety critical message, reduces the overall failure risk caused by resource exhaustion. When the attack traffic is lower than the recovery threshold, reset the signature verification algorithm to the standard mode and clear the filter cache, improve the consistency of system security policy after the defense function reset, so as to reduce the failure of security function.

[0019] The application binds the physical unclonable function with the dynamic key to generate device unique initial fresh value, wherein the PUF function is integrated in the hardware security module special circuit containing anti-side channel protection layer, increasing the difficulty of historical replay message passing verification; enable clock register write protection latch in secure execution environment, prohibit non-trusted firmware to modify clock drift compensation parameters, guarantee the reliability of time reference; intercept unencrypted messages through gateway hardware firewall and record event log, enhance the active defense ability of bus saturation attack. BRIEF DESCRIPTION OF DRAWINGS

[0020] In order to more clearly illustrate the technical solutions of the present application, the drawings needed to be used in the description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0021] Figure 1 The flowchart of the replay attack prevention method for in-vehicle communication provided by the present application.

[0022] Figure 2 The structure diagram of the replay attack prevention system for in-vehicle communication provided by the present application.

[0023] Figure 3 The structure diagram of the electronic device provided by the present application. DETAILED DESCRIPTION

[0024] In the following detailed description of the specific steps of the replay attack prevention method for in-vehicle communication, various embodiments of the present disclosure will be described more fully. The present disclosure can have various embodiments, and adjustments and changes can be made therein. However, it should be understood that there is no intention to limit various embodiments of the present disclosure to specific embodiments disclosed herein, but the present disclosure should be understood to cover all adjustments, equivalents and / or alternatives falling within the spirit and scope of various embodiments of the present disclosure.

[0025] Hereinafter, the term "include" or "may include" used in various embodiments of the disclosure indicates the presence of the disclosed functions, operations, or elements and does not limit one or more additions of functions, operations, or elements. Also, as used in various embodiments of the disclosure, the terms "include", "have", and their conjugates merely indicate the presence of specific features, numbers, steps, operations, elements, components, or combinations thereof, and should not be construed as excluding the presence or addition of one or more other features, numbers, steps, operations, elements, components, or combinations thereof.

[0026] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.

[0027] Please refer to Figure 1 The method flowchart of a replay attack prevention method for in-vehicle communication in an embodiment is shown, and the method comprises: S1: After the vehicle ignition signal response, the local clock of each electronic control unit is synchronized to a unified time reference through a secure time synchronization protocol.

[0028] In the specific embodiment, first, when the vehicle ignition signal is recognized by the detection circuit, the secure time synchronization process is started immediately. The gateway or the designated master clock source ECU broadcasts a precision time protocol (PTP) message following the IEEE 1588 standard through the CAN FD bus. The time synchronization message contains a unique identifier of the master clock, a 64-bit global timestamp accurate to the microsecond level, and is digitally signed using the elliptic curve digital signature algorithm (ECDSA) to ensure integrity and source authenticity.

[0029] Then, after receiving the time synchronization message, each slave node ECU first verifies the digital signature of the message in the secure execution environment constructed by its hardware security module (HSM) using the pre-installed root certificate. After the signature verification is passed, the ECU enters the clock calibration stage, and uses a recursive filtering algorithm to perform multiple iteration calculations on the local clock to accurately compensate for transmission delay and clock drift. After 3-5 iterations, each node clock can be synchronized to a unified time reference with a deviation of ±100 microseconds from the master clock.

[0030] Then, after the clock synchronization is completed, the write protection latch mechanism of the clock register is activated immediately by setting the privilege register bit of the clock control unit in the microcontroller. This hardware-level protection mechanism can effectively prevent non-trusted system firmware or potentially malicious code from modifying the clock drift compensation parameters, ensuring the reliability and tamper resistance of the time reference.

[0031] Finally, the ECU will record the master clock identifier and the 64-bit timestamp of the final synchronization success in the protected storage area, which together constitute the protected unified time reference required for subsequent secure communication.

[0032] S2: Before the SecOC module is activated, the sending end ECU calls the hardware encryption module to generate an encryption key and encrypt the initial freshness value, forming a secure synchronization message and sending it to the receiving end ECU.

[0033] In the specific embodiment, first, in the startup window period when the SecOC security module of the vehicle network communication has not been activated, the system performs a pre-startup security synchronization process. The master sending end ECU sends a 128-bit physically unclonable function (PUF) challenge code to the target receiving end ECU. The receiving end ECU uses the special PUF circuit integrated in its hardware security module to generate a 256-bit PUF response that is bound to the physical characteristics of its silicon chip and is unclonable, and transmits it back to the sending end through a secure channel.

[0034] Then, the sending end ECU calls the key generation engine in its hardware encryption module, takes the PUF response and a 128-bit random number seed generated by a hardware true random number generator (TRNG) as input, and dynamically generates a 256-bit communication session encryption key through the HMAC-based KDF key derivation function.

[0035] Next, the sending end reads the pre-set 32-bit initial freshness value (monotonically increasing counter) from its non-volatile memory. It calls the hardware encryption module to encrypt the initial freshness value using the AES-256-CBC encryption mode, using the aforementioned dynamic session key and a newly generated 128-bit random initialization vector IV. After encryption is complete, the sending end uses its own private key to perform ECDSA digital signature on the encrypted initial freshness value and random initialization vector, generating a 64-byte digital signature field.

[0036] Finally, a secure synchronization message is constructed, whose payload contains the encryption result, IV, digital signature, and a specific secure synchronization message identifier (0x0AFF) is set in the message header. The message is sent to the receiving end through the bus, completing the secure synchronization. As an enhanced defense, when the gateway monitors that the bus load exceeds the 70% threshold, its built-in hardware firewall will actively intercept all messages that do not carry this security identifier, and record event logs containing timestamps and source addresses in the secure storage area.

[0037] S3: After the SecOC module is activated, the sending end electronic control unit generates a time sequence verification code for the message to be transmitted across the bus, fuses the current freshness value and the multi-bus protocol identifier, writes the time sequence verification code into the authentication field of the message, and generates a communication message.

[0038] In the specific embodiment, first, when the SecOC module is formally activated and enters normal operation, the cross-protocol time sequence coding mechanism is enabled for messages that need to be transmitted across different buses. The sending end ECU first determines the target bus type of the message: if the target is a time-sensitive bus such as FlexRay, the 11-bit time slot identifier corresponding to the current period is extracted from the communication scheduling table as the protocol identifier; if the target is an event-triggered bus such as CAN, the 29-bit arbitration identifier of the message itself is extracted as the protocol identifier. This identifier is uniformly encoded into a 32-bit protocol context field.

[0039] Then, the current 32-bit freshness value (counter) is obtained from the active SecOC module. The 32-bit protocol context field and the 32-bit freshness value are concatenated to form a 64-bit to-be-verified primitive by calling the cryptographic coprocessor of the hardware security module.

[0040] Next, using the 256-bit time sequence verification key pre-shared with the gateway, the primitive is calculated through the AES-CMAC algorithm to generate a 128-bit cryptographic digest. To balance security and bus load, the first 64 bits of the digest are intercepted as the time sequence verification code unique to the message.

[0041] Finally, when constructing the final communication message, the time sequence verification code is written into the SecOC authentication field of the message as extended authentication information before the standard MAC value. The message thus carries both the freshness value and MAC for standard SecOC authentication, and the time sequence verification code for the gateway to verify the time sequence continuity, achieving double security enhancement.

[0042] S4: After the gateway receives the communication message, the time sequence verification code in the message is parsed and its logical continuity is verified. If the actual arrival time increment of the communication message exceeds the dynamic transmission delay threshold, the communication message is discarded.

[0043] In the specific embodiment, first, the gateway acts as the network hub and is responsible for performing strict time sequence continuity verification. At the moment of receiving the communication message, the gateway's hardware timestamp unit records the accurate arrival timestamp T1. The message SecOC field is parsed to extract the 64-bit time sequence verification code TVC1, the 32-bit freshness value FV1, and the source address information.

[0044] Then, the gateway maintains a state record for the source address, which contains the arrival timestamp T0 and the freshness value FV0 of the last legal message. At this time, freshness sequence verification is performed, and ΔFV = FV1 - FV0 is calculated. If ΔFV ≤ 0, it indicates that the message sequence number has not increased normally, and it may be a replay message, which is immediately discarded and a security event is recorded.

[0045] Next, time reasonableness verification is performed. The actual arrival time increment ΔT = T1 - T0 of the consecutive messages is calculated. At the same time, according to the target bus type and the real-time bus load rate, the current maximum delay threshold ΔT_max is dynamically calculated through the formula ΔT_max = k • (1 + α • BusLoad%). If ΔT > ΔT_max, it indicates that the message delay is abnormal and it is discarded.

[0046] It should be particularly noted that in the calculation formula of the maximum delay threshold, ΔT_max is the maximum transmission delay deviation (unit: μs) currently allowed, and messages exceeding this value will be discarded; k is a static delay reference (unit: μs) determined according to the basic physical characteristics of the target bus type, as shown in Table 1; α is a load-sensitive coefficient with a value range of 0.3-0.7, reflecting the amplification effect of bus load on delay; BusLoad% is the real-time bus load rate (percentage) obtained by sampling once every 1 second through the gateway hardware counter.

[0047] Table 1: Value selection rules table of static delay reference k

[0048] Subsequently, protocol context verification is performed. The gateway reconstructs the expected value TVC0 of the time sequence verification code locally according to the source address and target bus type of the message, combined with FV1, using the same algorithm and key as the sending end. TVC0 and TVC1 in the message are compared bit by bit. If they do not match, it indicates that the protocol context of the message is abnormal, and it may be a cross-bus replay attack, and the same discard operation is performed.

[0049] Finally, only when all three verifications are passed, the gateway forwards the message to the target bus and updates T0 and FV0 in the state record. The entire verification process can be completed in 50 microseconds under the hardware acceleration of the gateway, meeting the real-time requirements of vehicle-mounted communication.

[0050] As an example, after the vehicle ignition signal detection circuit identifies, the gateway electronic control unit broadcasts a precision time synchronization protocol message through the CANFD communication bus. Before the SecOC security communication module is officially activated, the sending end electronic control unit starts the pre-encryption transmission process. The hardware security module first calls its integrated physically unclonable function circuit to extract physical fingerprint features in the vehicle level range. The feature is input into the key derivation engine to generate a dynamic encryption key combined with a random number seed. The freshness parameter is processed by the AES-CBC encryption algorithm, encrypted using a dynamic key and a random initialization vector, and a secure synchronization message is generated and transmitted to the receiving end. The receiving end electronic control unit uses the bound physically unclonable function to reconstruct the decryption key, generates a device unique initial freshness value, reduces the security risk of plaintext transmission of the freshness value during the vehicle startup phase, and reduces the possibility of replay attacks; According to the target bus type, set a differentiated transmission delay threshold, which also dynamically floats with the real-time bus load to ensure adaptability. Messages with incremental values exceeding the threshold are immediately discarded during the verification process, effectively alleviating the timing fragmentation problem in a mixed bus environment.

[0051] S5: Real-time monitoring of attack traffic rate on the bus; when the attack traffic rate exceeds the first set threshold, switch the message authentication code verification algorithm to a lightweight mode, and at the same time enable the hardware level duplicate message filter.

[0052] In the specific embodiment, first, through the gateway hardware traffic monitor, the number of messages on the bus is counted in real time with a time window of 100 milliseconds, and the attack traffic rate is calculated. The monitor is integrated in the network interface controller of the gateway, and can complete traffic statistics without increasing CPU load.

[0053] Then, when the attack traffic rate exceeds 200% of the normal traffic and lasts for 3 consecutive sampling windows, the defense state switching is triggered. The security policy manager sends mode switching instructions to the SecOC module and hardware security module of each ECU.

[0054] Next, the signature verification algorithm is configured differently according to the functional safety level of the message: the ASIL-D highest safety level message (such as brake and steering instructions) maintains the standard AES-128-CMAC algorithm to ensure that the core safety function is not affected; The ASIL-B medium safety level message (such as engine control) is switched to the AES-64-CMAC lightweight algorithm with a 40% reduction in calculation; The QM non-safety critical message (such as entertainment system information) is changed to execute the faster CRC32 check, significantly reducing the calculation overhead.

[0055] At the same time, enable the duplicate message filter integrated in the gateway hardware logic. The filter configures a 10 ms sliding time window, automatically detects and intercepts invalid messages with the same source address and MAC value that appear continuously within the window. For the detected duplicate messages, the filter directly discards at the hardware level and no longer submits to the SecOC module at the software level for repeated cryptographic verification.

[0056] In this step, the bus attack traffic rate is continuously monitored, and when the monitoring module detects that the rate exceeds the limit, the dynamic defense switching mechanism is activated. The security module first switches the message authentication algorithm from the standard to the lightweight, reducing the computational complexity. At the same time, the hardware-level duplicate message filter is enabled, which is integrated in the global timer module and configured to detect and intercept messages with the same authentication code continuously within the window within the specified time. The resource allocation strategy is simultaneously started: allocate high verification power to key messages of functional safety level ASIL-D to ensure core safety functions; allocate low resources to ASIL-B level messages; and enable a simplified verification algorithm for non-safety critical messages, so that the system can optimize allocation and maintain core safety function operation in high traffic attack scenarios.

[0057] S6: When the attack traffic rate continues to be below the second recovery threshold, reset the message authentication code verification algorithm to the standard mode, and clear the cache of the hardware-level duplicate message filter.

[0058] In the specific implementation, first, the attack traffic rate is continuously monitored, and when it is detected that the rate is continuously below 120% of the normal traffic for 5 sampling windows, the recovery process is started.

[0059] Then, the message authentication code algorithm is uniformly reset to the standard AES-128-CMAC mode, ensuring that the authentication strength of all messages returns to the optimal state. The reset instruction is issued to each ECU through a secure communication channel, and the algorithm switching of the entire network is completed within 100 ms.

[0060] Next, clear all cache contents of the hardware-level duplicate message filter, including clearing all entries in its temporary blacklist, resetting all source address count registers, and restoring the MAC verification length to the standard configuration.

[0061] Finally, record the state recovery event in the security event log, including the recovery timestamp, the final attack traffic rate value, and other key information. The entire recovery process ensures that it is completed within 200 ms, so that the system security policy completely returns to the normal state, while continuously monitoring the bus state to prepare for the next possible attack.

[0062] In this step, when the attack traffic continues to be below the recovery threshold, the system enters the security state recovery phase. The process first resets the message authentication algorithm to the standard mode, ensuring security strength. The cache area of the hardware-level duplicate message filter is emptied, including clearing all entries in the pre-filter blacklist. The message authentication code length is restored to the standard configuration, ensuring the security verification strength of subsequent communication. The entire state transition process is completed within a specified time, and monitoring is used to ensure that all defense components are reset synchronously, maintaining the consistency of the system security policy.

[0063] In this embodiment, by constructing a multi-level cooperative defense system covering vehicle startup, cross-protocol communication and high-load running scenarios, comprehensive security enhancement is achieved: first, during the vehicle startup phase, a reliable time reference is established through secure time service and clock write protection, and then the initial freshness value is securely synchronized through PUF binding key and encrypted transmission; in normal operation, time sequence verification codes are generated by fusing multi-bus protocol identifiers, effectively solving the time sequence fragmentation problem of hybrid bus networks; when high traffic attacks are encountered, the signature algorithm can be dynamically switched and the computing power can be allocated according to security levels, while the hardware-level duplicate message filter is enabled to ensure continuous security protection; finally, after the attack subsides, the standard security configuration is quickly restored, thereby significantly improving the reliability, real-time performance and robustness of the in-vehicle network defense against replay attacks as a whole.

[0064] As shown in Figure 2 The following is an embodiment of an in-vehicle communication replay attack prevention system provided by the embodiments of the present disclosure. The system and the above-mentioned in-vehicle communication replay attack prevention method belong to the same inventive concept. Details not described in the in-vehicle communication replay attack prevention system embodiment can be referred to the above-mentioned in-vehicle communication replay attack prevention method embodiment.

[0065] An in-vehicle communication replay attack prevention system, comprising: A time reference management module for synchronizing the local clock of each electronic control unit to a unified time reference through a secure time service protocol after a vehicle ignition signal response.

[0066] A security synchronization module for calling a hardware encryption module by a sending electronic control unit to generate an encryption key and encrypt an initial freshness value to form a security synchronization message and send it to a receiving electronic control unit before activating a SecOC module.

[0067] A time sequence encoding module for fusing the current freshness value and multi-bus protocol identifier to generate a time sequence verification code for messages to be transmitted across the bus by the sending electronic control unit after activating the SecOC module, and writing the time sequence verification code into the authentication field of the message to generate a communication message.

[0068] A continuity verification module is configured to parse the time sequence verification code in the communication message received by the gateway and verify the logical continuity thereof, and if the actual arrival time increment of the communication message exceeds the dynamic transmission delay threshold, perform a discard operation on the communication message.

[0069] A dynamic defense management module is configured to monitor the attack traffic rate on the bus in real time, switch the message authentication code verification algorithm to a lightweight mode when the attack traffic rate exceeds a first set threshold, and simultaneously enable a hardware-level duplicate message filter.

[0070] A security state recovery module is configured to reset the message authentication code verification algorithm to a standard mode and clear the cache of the hardware-level duplicate message filter when the attack traffic rate continuously falls below a second recovery threshold.

[0071] The replay attack prevention system for in-vehicle communication provided by the embodiment effectively improves the anti-replay attack capability of the in-vehicle network by constructing a multi-level collaborative defense system covering the full scene of vehicle startup, cross-protocol communication and high-load operation. Before the SecOC module is activated, the system uses hardware encryption and PUF binding technology to securely synchronize the freshness value, thereby rooting out the risk of plaintext transmission in the startup phase. By fusing multiple bus protocol identifiers to generate a time sequence verification code and performing continuity verification by the gateway, the system accurately identifies and blocks cross-bus replay attacks, thereby solving the problem of time sequence fragmentation in hybrid buses. The system introduces a dynamic defense mechanism based on attack traffic monitoring, intelligently switches to a lightweight signature verification algorithm in a high-load scenario, and enables a hardware-level filter to allocate computing power according to security levels, ensuring that core functions are not interrupted, and ultimately achieving comprehensive security enhancement from time reference, security synchronization, protocol collaboration to resource scheduling.

[0072] Figure 3 A hardware structure schematic diagram of an electronic device for implementing various embodiments of the present application.

[0073] The replay attack prevention method for in-vehicle communication provided by the embodiment of the present application can be applied to an electronic device. Those skilled in the art can understand that the electronic device structure involved in the embodiments of the present application does not constitute a limitation on the electronic device, and the electronic device can include more or fewer components than the illustration, or combine certain components, or different component arrangements. In the embodiments of the present application, the electronic device includes but is not limited to a laptop computer, a desktop computer, a workstation, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the embodiments of the present application described and / or claimed herein.

[0074] Electronic devices may include processors, external memory interfaces, internal memory, universal serial bus (USB) interfaces, charging management modules, power management modules, batteries, wireless communication modules, audio modules, speakers, microphones, sensor modules, buttons, cameras, displays, and SIM card interfaces, etc.

[0075] A processor may include one or more processing units, such as: a central processing unit (CPU), an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors.

[0076] The processor can serve as the nerve center and command center of an electronic device. The controller can generate operation control signals based on the instruction opcode and timing signals to control the fetching and execution of instructions.

[0077] The processor may also include memory for storing instructions and data. In some embodiments, the memory in the processor is a cache memory. This memory can store instructions or data that the processor has just used or that are used repeatedly. If the processor needs to use the instruction or data again, it can retrieve it directly from this memory. This avoids repeated accesses, reduces processor latency, and thus improves system efficiency.

[0078] An external storage interface (ESI) can be used to connect external memory cards, such as microSD cards, to expand the storage capacity of electronic devices. The external memory card communicates with the processor through the ESI to perform data storage functions, such as saving music and video files on the external memory card.

[0079] Internal memory can be used to store computer executable program code, which includes instructions. The processor executes various functional applications and data processing of electronic devices by running the instructions stored in internal memory. Internal memory can include a program storage area and a data storage area. Internal memory can include high-speed random access memory, and can also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.

[0080] Wireless communication functionality in electronic devices can be achieved through antennas, wireless communication modules, modem processors, and baseband processors.

[0081] Wireless communication modules can provide solutions for wireless communication applications in electronic devices, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies.

[0082] Electronic devices can implement audio functions through audio modules, speakers, receivers, microphones, headphone jacks, and application processors.

[0083] Electronic devices can achieve shooting functions through ISPs, cameras, video codecs, GPUs, displays, and application processors.

[0084] Electronic devices can achieve display functions through GPUs, displays, and application processors.

[0085] A GPU is a microprocessor for image processing, connected to the display screen and application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering. A processor may include one or more GPUs, which execute program instructions to generate or modify display information.

[0086] A display screen is used to display images, videos, etc. A display screen includes a display panel.

[0087] The aforementioned electronic device implements the replay attack prevention method for in-vehicle communication of this application by constructing a comprehensive, multi-layered collaborative mechanism that integrates pre-startup encryption synchronization, cross-protocol timing continuity verification, and dynamic load adaptive defense. This achieves the beneficial effects of significantly improving the reliability of the SecOC mechanism in preventing replay attacks in complex in-vehicle network environments, effectively alleviating the timing fragmentation problem of hybrid buses, and ensuring that the core security functions of the system are not interrupted under high-traffic attack scenarios.

[0088] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for preventing replay attacks in in-vehicle communication, characterized in that, include: After the vehicle ignition signal is received, the local clocks of each electronic control unit are synchronized to a unified time base through a safety timing protocol. Before the SecOC module is activated, the sending end electronic control unit calls the hardware encryption module to generate an encryption key and encrypt the initial freshness value, forming a secure synchronization message and sending it to the receiving end electronic control unit. After the SecOC module is activated, the sending end electronic control unit integrates the current freshness value and the multi-bus protocol identifier to generate a timing verification code for the message that needs to be transmitted across the bus, and writes the timing verification code into the authentication field of the message to generate a communication message. After the gateway receives the communication message, it parses the timing verification code in it and verifies its logical continuity. If the actual arrival time increment of the communication message exceeds the dynamic transmission delay threshold, the communication message is discarded. Real-time monitoring of the attack traffic rate on the bus; when the attack traffic rate exceeds a first set threshold, the message authentication code verification algorithm is switched to lightweight mode, and a hardware-level duplicate message filter is enabled at the same time. When the attack traffic rate remains below the second recovery threshold, the message authentication code verification algorithm is reset to standard mode, and the cache of the hardware-level duplicate message filter is cleared.

2. The method for preventing replay attacks in in-vehicle communication according to claim 1, characterized in that, The step of synchronizing the local clocks of each electronic control unit to a unified time base via a safety timing protocol after the vehicle ignition signal is received includes: After the vehicle ignition signal is received, each electronic control unit synchronizes its local clock with the master clock source through a secure timing protocol. During the synchronization process, the master clock source broadcasts a timing message containing its master clock identifier and a 64-bit precision timestamp. After synchronization is completed, each electronic control unit enables the write protection mechanism of the clock register and records the master clock identifier and the 64-bit timestamp of the final successful synchronization, which together constitute a protected unified time reference. The digital signature of the secure timing protocol is verified through a secure execution environment, and the write-protect latch of the clock register is enabled after clock alignment to prevent untrusted firmware from modifying the clock drift compensation parameters.

3. The method for preventing replay attacks in in-vehicle communication according to claim 2, characterized in that, Before the SecOC module is activated, the sending end electronic control unit calls the hardware encryption module to generate an encryption key and encrypt the initial freshness value, forming a secure synchronization message and sending it to the receiving end electronic control unit, including: Before the SecOC module is activated, the main transmitting electronic control unit sends a Physically Unclonable Function (PUF) challenge code to the receiving electronic control unit. After receiving the challenge code, the receiving electronic control unit generates a PUF response through its integrated dedicated PUF circuit and sends it to the transmitting electronic control unit. The transmitting electronic control unit calls the key generation engine in the built-in hardware encryption module, takes the PUF response and a random number seed from a hardware true random number generator as input, and uses the key derivation function to generate the dynamic encryption key for this communication session. The transmitting end electronic control unit reads the preset initial freshness value from the built-in memory, calls the hardware encryption module, uses the AES-CBC encryption algorithm, and uses the dynamic encryption key and a newly generated random initialization vector to perform encryption operation on the initial freshness value to generate an encrypted initial freshness value. The encrypted initial freshness value and random initialization vector are digitally signed using the private key of the sending end electronic control unit to generate a digital signature field; Obtain the master clock identifier and 64-bit timestamp, combine them with the digital signature field to generate a secure synchronization message, set the secure synchronization message identifier in the message header, and send the secure synchronization message to the receiving electronic control unit via the bus.

4. The method for preventing replay attacks in in-vehicle communication according to claim 3, characterized in that, Before the SecOC module is activated, the sending-end electronic control unit calls the hardware encryption module to generate an encryption key and encrypt the initial freshness value, forming a secure synchronization message and sending it to the receiving-end electronic control unit, which also includes: When the bus load exceeds a preset load threshold, packets without a security synchronization message identifier are blocked by the hardware firewall deployed on the gateway, and the event log is recorded in the security storage area.

5. The method for preventing replay attacks in in-vehicle communication according to claim 4, characterized in that, After the SecOC module is activated, the sending electronic control unit, for messages requiring cross-bus transmission, integrates the current freshness value and the multi-bus protocol identifier to generate a timing verification code, and writes this timing verification code into the authentication field of the message to generate a communication message, including: After the SecOC module is activated, the target bus type of the message to be sent is determined by the electronic control unit at the sending end. If the target bus is a time-sensitive bus, the timeslot identifier corresponding to the current communication cycle is extracted as the multi-bus protocol identifier. If the target bus is an event-triggered bus, the arbitration identifier of the message itself is extracted as the multi-bus protocol identifier. The extracted multi-bus protocol identifiers are uniformly encoded into a fixed-length protocol context field. Obtain the current freshness value from the activated SecOC module; Invoke the hardware security module to concatenate the protocol context field with the current freshness value to form the primitive to be verified; Using the timing verification key pre-shared with the gateway, the primitive to be verified is calculated using the AES-CMAC algorithm to generate a cryptographic digest. The first 64 bits of the cryptographic digest are extracted as the timing verification code of the message. Based on the message to be sent, the timing verification code is used as extended authentication information and written into the SecOC authentication field of the message to form a communication message.

6. The method for preventing replay attacks in in-vehicle communication according to claim 5, characterized in that, After receiving a communication message, the gateway parses the timing verification code and verifies its logical continuity. If the actual arrival time increment of the communication message exceeds the dynamic transmission delay threshold, the communication message is discarded. This includes: When the gateway receives the communication message, it records its arrival timestamp T1; Parse the SecOC authentication field of the communication message to obtain the timing verification code TVC1, the freshness value FV1, and the source address in the data frame header; Based on the source address, query the arrival timestamp T0 and freshness value FV0 of the previous communication message maintained by the gateway for that address; Calculate and determine whether the freshness value increment ΔFV = FV1 – FV0 is greater than zero; if not, discard the communication message. The actual arrival time increment ΔT between consecutive communication messages is calculated using the formula ΔT=T1–T0; the dynamic transmission delay threshold is calculated based on the target bus type and real-time bus load rate; it is then determined whether ΔT is less than or equal to the dynamic transmission delay threshold; if not, the communication message is discarded. The source address and target bus type, combined with the freshness value FV1, are used to reconstruct the expected value of the timing verification code TVC0 locally using the same algorithm as the sending end electronic control unit, and then compared with TVC1; if TVC0 and TVC1 are inconsistent, the communication message is discarded.

7. The method for preventing replay attacks in in-vehicle communication according to claim 6, characterized in that, The calculation of the dynamic transmission delay threshold based on the target bus type and real-time bus load rate includes: The dynamic transmission delay threshold ΔT_max is calculated using the formula ΔT_max=k•(1+α•BusLoad%). Where k is the static delay baseline determined based on the basic physical characteristics of the target bus type, α is the load sensitivity coefficient, and BusLoad% is the real-time bus load rate.

8. The method for preventing replay attacks in in-vehicle communication according to claim 7, characterized in that, The real-time monitoring bus is used to detect the attack traffic rate. When the attack traffic rate exceeds a first preset threshold, the message authentication code verification algorithm is switched to lightweight mode, and a hardware-level duplicate message filter is enabled simultaneously, including: The attack traffic rate on the bus is counted in real time through the hardware traffic monitor of the gateway. The attack traffic rate is compared with a first set threshold; when the attack traffic rate exceeds the first set threshold, the security policy manager configures a differentiated signature verification algorithm based on the functional security level of the message. For ASIL-D level messages, maintain the original standard AES-CMAC algorithm; For ASIL-B level messages, switch to the lightweight CRC32-CMAC algorithm; For QM level messages, the calculation of the complete message authentication code is paused, and instead a fast CRC32 check is performed on the data payload. Enable hardware-level duplicate message filter to intercept continuously received messages with invalid message authentication codes.

9. The method for preventing replay attacks in in-vehicle communication according to claim 7, characterized in that, Clearing the cache of the hardware-level duplicate message filter includes clearing the pre-filter blacklist and restoring the standard message authentication code length.

10. A replay attack prevention system for in-vehicle communication, characterized in that, The system employs the replay attack prevention method for in-vehicle communication as described in any one of claims 1 to 9; The system includes: The time reference management module is used to synchronize the local clocks of each electronic control unit to a unified time reference through a safe timing protocol after the vehicle ignition signal is responded to. The secure synchronization module is used to call the hardware encryption module of the sending end electronic control unit before the SecOC module is activated, generate an encryption key and encrypt the initial freshness value, form a secure synchronization message and send it to the receiving end electronic control unit. The timing coding module is used by the sending end electronic control unit to generate a timing verification code for the message that needs to be transmitted across the bus after the SecOC module is activated, by combining the current freshness value and the multi-bus protocol identifier, and write the timing verification code into the authentication field of the message to generate a communication message. The continuity verification module is used to parse the timing verification code in the communication message after the gateway receives it, and to verify its logical continuity. If the actual arrival time increment of the communication message exceeds the dynamic transmission delay threshold, the communication message is discarded. The dynamic defense management module is used to monitor the attack traffic rate on the bus in real time. When the attack traffic rate exceeds the first set threshold, the message authentication code verification algorithm is switched to lightweight mode, and a hardware-level duplicate message filter is enabled at the same time. The security state recovery module is used to reset the message authentication code verification algorithm to standard mode and clear the cache of the hardware-level duplicate message filter when the attack traffic rate continues to be lower than the second recovery threshold.