Router firmware updating method and system based on communication protocol
By introducing a multi-stage verification mechanism during the router firmware update process, the hidden faults caused by intermediate proxy devices and the problem of rollback mechanism failure are solved, ensuring the reliability and security of firmware updates and preventing the device from falling into a 'half-brick' state.
Patent Information
- Application Number
- CN202511497612.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-20
- Publication Date
- 2025-12-30
- Estimated Expiration
- 2045-10-20
AI Technical Summary
In complex network environments, especially when there are intermediate proxy devices, hidden faults may occur during router firmware updates, causing digital signature verification to pass but internal verification to fail. In some cases, the rollback mechanism may even destroy the old firmware boot information after the update fails, causing the device to become 'half-bricked'.
A multi-stage, multi-dimensional verification mechanism is introduced during the firmware update process, including firmware transmission metadata verification, real-time structural checks during the download process, and overall verification after the download is completed. By acquiring and verifying firmware transmission metadata, the download progress and content are monitored in real time to ensure the integrity and consistency of the firmware file.
It significantly improves the reliability and security of firmware updates, avoids devices from becoming 'half-bricked', reduces the risk of update failure, and ensures a reliable rollback to an available older firmware version in the event of an update failure.
Smart Images

Figure CN121239618A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of communication protocols, and in particular to a router firmware update method and system based on communication protocols. BACKGROUND
[0002] In daily network device maintenance, the firmware update of a router is an important link to ensure the performance, security and functionality of the device. Generally, this process relies on the router to download and install new firmware from the manufacturer's server through a secure communication protocol. In order to ensure the reliability of the update, the firmware package is usually digitally signed and verified after downloading. In addition, many routers also use a dual firmware partition mechanism to roll back to the old stable version in case of update failure, so as to avoid device startup failure. However, in a complex network environment, especially when there are intermediate proxy devices in the network, these conventional update and protection mechanisms may face unexpected challenges, resulting in hidden failures in the firmware update process, and even making the device fall into a difficult-to-recover state.
[0003] Specifically, in an enterprise network environment where a defective transparent proxy server is deployed and the manufacturer's server uses chunked transfer encoding, when the router performs firmware update through the HTTPS protocol, the transparent proxy server may introduce a small but non-original data tampering in the process of TLS man-in-the-middle decryption and HTTP response header processing. This tampering may cause the digital signature of the firmware package to pass the verification, but the internal integrity check (such as CRC or SHA256 hash value) fails. Since the router client has a certain flexibility in the design of HTTP protocol parsing, and the digital signature is usually located at the end of the firmware package, the small amount of non-original data introduced by the proxy may be considered outside the scope of signature verification, thus making the digital signature verification successful. However, when the router is ready to burn the firmware into the flash chip, the internal integrity check will fail due to these small differences.
[0004] More seriously, in some cases, the rollback mechanism after update failure may accidentally destroy the boot information or key metadata of the old firmware. For example, the update logic optimization of the bootloader in the new firmware version may mistakenly remove the temporary configuration or state information related to the new firmware when processing such "abnormal but signed valid" firmware package, thus destroying the boot information of the old firmware. This may eventually cause the router to fall into a "half-brick" state, i.e. the device can be normally powered on, but cannot load the complete operating system, cannot provide network services, and cannot be recovered through conventional means. This hidden failure and accidental destruction of the rollback mechanism make the router face great risks during firmware update, and an effective method is urgently needed to identify and correct the data tampering introduced by the proxy server, and to ensure reliable rollback to a usable old firmware version in any update failure case. Summary of the Invention
[0005] To address this, the present invention proposes a router firmware update method and system based on a communication protocol, aiming to solve the problems of hidden faults that may occur during router firmware updates in complex network environments, especially when intermediate proxy devices are present, and the potential for rollback mechanisms to accidentally destroy old firmware boot information after update failure.
[0006] The first objective of this invention is to provide a router firmware update method based on a communication protocol, comprising: When the router updates its firmware, obtain the firmware transmission metadata corresponding to the firmware to be updated, and verify the firmware transmission metadata. After successful verification, based on the firmware transmission metadata, a request is made to download the firmware file data. During the download process, the downloaded firmware file data is subjected to real-time structural checks in accordance with the firmware transmission metadata. Once all firmware file data has passed the structural check, all firmware file data is reassembled. After the firmware file data is reassembled, the overall checksum of the firmware file data is calculated and compared with the preset overall checksum contained in the firmware transmission metadata. If the comparison results are the same, proceed with the router firmware update; otherwise, stop the router firmware update.
[0007] This solution introduces multiple verification mechanisms before, during, and after firmware file download, including verification of firmware transmission metadata, real-time structural checks during the download process, and overall verification after download completion. This effectively identifies and prevents hidden firmware data anomalies caused by tampering with intermediate network devices, significantly improving the reliability and security of firmware updates and preventing devices from becoming "half-bricked".
[0008] The firmware transmission metadata includes: the preset overall checksum of the firmware file and the firmware file data structure information; the firmware file data structure information includes at least the preset storage space required by the firmware file, the protocol structure information, and the preset key area information of the firmware file.
[0009] This solution limits the structural information and checksums included in the firmware transmission metadata, enabling the router to obtain comprehensive expected information before downloading and updating firmware. This provides a reliable benchmark for subsequent real-time structural checks and overall verification, thereby enabling earlier and more accurate detection of potential data tampering or inconsistencies.
[0010] This includes performing real-time structural checks on the downloaded firmware file data based on the firmware transmission metadata, including: Compare the required storage space for the firmware file data with the preset storage space; if they are not equal, terminate the download. Based on the protocol structure information, the content of the firmware file data is compared with the content of the preset firmware file data in the protocol structure information. If there are differences, the download is terminated. The key area information in the downloaded firmware file data is compared with the corresponding information in the key area information of the preset firmware file. If there is a discrepancy, the download is terminated.
[0011] By performing real-time structural checks during firmware file downloads, data transmissions that do not conform to the preset structure or content can be detected and blocked in a timely manner. This avoids downloading invalid or tampered firmware files, thereby saving network bandwidth and storage resources and significantly reducing the risk of update failures.
[0012] This includes comparing the required storage space for the firmware file data with the preset storage space; if they are not equal, the download will be terminated. Determine the firmware file's transmission method, which includes whole-segment transmission and segmented transmission. If the firmware file is transmitted as a whole, the required storage space for the firmware file data is compared with the preset storage space. If they are equal, the download continues; otherwise, the download is terminated. If the firmware file is transmitted in segments, the number of segments and the storage space required for each segment are compared with the preset number of segments and the preset storage space for each segment contained in the segment information. If they are equal, the download continues; otherwise, the download is terminated.
[0013] Fine-grained storage space verification is performed for different firmware transmission methods (whole segment or segmented), ensuring that the downloaded firmware data strictly matches the preset storage requirements regardless of the transmission mode, further enhancing the robustness and accuracy of the download process.
[0014] This includes verifying the firmware transmission metadata, including: The firmware transmits metadata and performs normalization processing; this normalization processing includes: whitespace character removal, Unicode character normalization, and key-value pair sorting. The standardized firmware transmit metadata is subjected to structural and semantic verification; the structural and semantic verification includes: data type verification, numerical range verification, format verification, and mandatory field existence verification. Cross-validation of key parameters for consistency of firmware transmission metadata is performed. This cross-validation includes: comparing the preset storage space required for the firmware file when transmitting in whole segments with the total storage space required for all segments when transmitting in segments; associating the hash value of the key area of the firmware file with the overall hash value of the firmware file; and verifying the consistency between the version number and the download link.
[0015] Before firmware download, the firmware transmission metadata is verified in a multi-dimensional and in-depth manner, including normalization processing, structural semantic verification, and cross-verification of the logical consistency of key parameters. This can effectively identify and correct format errors, logical inconsistencies, or potential tampering of the metadata itself, ensuring the correctness of the subsequent firmware download and update process from the source.
[0016] Among the steps involved in cross-validating the logical consistency of key parameters in firmware transmission metadata: The comparison between the total storage space of the firmware file and the total storage space of each segment after the firmware file is segmented is to compare the preset storage space required when the firmware file is transmitted as a whole with the total storage space required when the firmware file is transmitted in segments. If the two are inconsistent, the verification fails. Associating the hash value of the key area of the firmware file with the hash value of the overall firmware file is a logical verification of the hash value of the key area of the firmware file in the firmware transmission metadata. If the hash value of the key area of the firmware file is logically incompatible with the hash value of the overall firmware file, the verification will fail. The version number and download link consistency verification verifies the firmware version number in the firmware transmission metadata against the version information contained in the download link. If the version information contained in the two is inconsistent, the verification fails.
[0017] By performing logical consistency cross-validation on key parameters in firmware transmission metadata, deep logical errors or malicious tampering that are difficult to detect with a single verification can be discovered, such as storage space calculation errors, mismatches between key area hash values and overall hash values, and inconsistencies between version numbers and download links, thereby further improving the rigor and security of metadata verification.
[0018] The verification of firmware transmission metadata also includes: For network environments with a network optimizer, while acquiring firmware transmission metadata, a list of network optimization modes is also acquired. The list of network optimization modes includes the mode identifier of the firmware transmission metadata, the original mode hash value, the regular expression processed by the network optimizer, and the expected length range of the original mode. During the firmware file data download process, the firmware file data is matched according to the network optimization mode list.
[0019] For special network environments with network optimizers, a list of network optimization modes is introduced, and content matching is performed during the download process. This can effectively identify and handle data transformations or tampering that may be introduced by the network optimizer, ensuring that the original and correct firmware data can be downloaded even in optimized network environments, thus solving the blind spots of traditional verification mechanisms in such scenarios.
[0020] During the firmware file data download process, content matching of the firmware file data is performed according to the network optimization mode list, including: Based on firmware transmission metadata, generate and initiate download links for firmware file data, and monitor in real time whether the download links contain optimization declaration header fields; If the download link contains an optimization declaration header field, then the downloaded firmware file data is matched against the network optimization mode list. Download will be terminated if the optimization declaration header field is not included.
[0021] By monitoring the optimization declaration header field in the download link in real time and matching the content according to the network optimization mode list, the system can intelligently identify and respond to the presence of the network optimizer, avoiding unnecessary matching operations in non-optimized environments, improving processing efficiency, and ensuring the integrity of firmware data in optimized environments.
[0022] Specifically, after matching the downloaded firmware file data with the content according to the network optimization mode list, the downloaded firmware file data optimized by the network optimizer is de-optimized to obtain the original firmware file data.
[0023] After the network optimizer optimizes the firmware data, the original firmware file data is restored through the deoptimization operation. This ensures that the firmware data ultimately received by the router is the original version without any third-party modifications, thereby completely eliminating the potential risks that the network optimizer may bring and ensuring the purity and reliability of the firmware update.
[0024] The second objective of this invention is to provide a router firmware update system based on a communication protocol, comprising: The firmware transmission metadata download and verification module is used to obtain the firmware transmission metadata of the corresponding firmware to be updated when the router updates the firmware, and to verify the firmware transmission metadata. The download check module is used to request the download of firmware file data based on firmware transmission metadata after verification, and to perform real-time structural checks on the downloaded firmware file data according to the firmware transmission metadata during the download process. The reassembly module is used to reassemble all firmware file data when all firmware file data has passed the structural check. The comparison module is used to calculate the overall check value of the firmware file data after the firmware file data is reassembled, and compare it with the preset overall check value contained in the firmware transmission metadata. The update judgment module is used to perform a router firmware update when the comparison results are the same, and otherwise stop the router firmware update.
[0025] This application, through modular design, realizes multi-stage and multi-dimensional verification and validation in the firmware update process. From metadata acquisition to firmware download, assembly and final verification, each link has a dedicated module responsible for ensuring that every step of the firmware update is strictly controlled and checked, thereby effectively improving the automation, reliability and security of the update process.
[0026] Unlike existing technologies, the router firmware update method based on communication protocols of this invention effectively solves the problems of hidden firmware update failures caused by tampering by network intermediary proxy devices and the potential damage to old firmware boot information by the rollback mechanism after update failure by introducing a multi-stage, multi-dimensional verification and validation mechanism during the firmware update process. Specifically, this method first rigorously verifies the firmware transmission metadata before firmware download to ensure the accuracy and integrity of the metadata itself; secondly, during the firmware file data download process, a structural check is performed in real time to promptly detect and prevent any data transmission that does not conform to the preset structure or content; finally, after the firmware file data is reassembled, the overall verification value is calculated and compared with the preset value to confirm the final integrity of the firmware data. Through this progressive verification strategy, this application can effectively identify and correct minor but non-original data tampering introduced by the proxy server, avoiding the contradictory situation where digital signature verification passes but internal overall verification fails. Furthermore, by conducting comprehensive checks before, during, and after the update, the risk of update failure is significantly reduced, thereby preventing the router from becoming "half-bricked" and ensuring that even if the update fails, it can reliably roll back to an available older firmware version, greatly improving the reliability, security, and user experience of router firmware updates.
[0027] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0028] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein: Figure 1 This is a flowchart illustrating a router firmware update method based on a communication protocol provided by the present invention.
[0029] Figure 2This is a schematic diagram of the structure of a router firmware update system based on a communication protocol provided by the present invention. Detailed Implementation
[0030] Embodiments of the present invention are described in detail below. Examples of these embodiments are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain the present invention, and should not be construed as limiting the present invention.
[0031] Traditional firmware update methods for WiFi routers often expose hidden faults when facing complex network environments, especially flawed transparent proxy servers. These faults may cause the firmware package's digital signature verification to pass, but the overall internal verification fails. They can even corrupt the boot information of the old firmware during a failed update rollback, rendering the device "partially bricked" and difficult to recover. If these issues are not addressed, the router's stability and security will be severely threatened, the user experience will deteriorate significantly, and large-scale device failures may occur, increasing maintenance costs.
[0032] like Figure 1 As shown, this embodiment of the invention provides a router firmware update method based on a communication protocol, including: S110: When the router updates the firmware, obtain the firmware transmission metadata corresponding to the firmware to be updated, and verify the firmware transmission metadata.
[0033] To better understand the technical solution proposed in this application, some key terms involved are explained first. Firmware transfer metadata refers to the data set used to describe information related to the firmware file to be updated when a router updates its firmware. It includes key attributes and verification information of the firmware file, such as the preset overall checksum of the firmware file and firmware file data structure information. Firmware file data structure information further refines the internal structure of the firmware file, such as the preset storage space required by the firmware file, protocol structure information, and preset key area information of the firmware file. This metadata and structural information are fundamental to ensuring the integrity and correctness of the firmware download and update process. This method is typically executed on a router device that connects to a firmware server via a network and performs data transmission according to a specific communication protocol (e.g., HTTPS).
[0034] When updating router firmware, the first step is to obtain the firmware transfer metadata for the firmware to be updated. This firmware transfer metadata can be downloaded directly from the firmware server or manually uploaded through the router's management interface. For example, the router can send an HTTP GET request to the firmware server, requesting the metadata file for a specific firmware version. Upon receiving the request, the server sends the file containing the firmware transfer metadata as a response to the router. After obtaining the firmware transfer metadata, it needs to be verified. The verification process can include checking the format, completeness, and consistency of the metadata. For example, it can check whether the metadata file conforms to a predefined JSON or XML format, or check whether any key fields are missing.
[0035] When updating router firmware, the first step is to obtain the firmware transfer metadata for the corresponding firmware to be updated. This firmware transfer metadata can be downloaded directly from the firmware server or manually uploaded through the router's management interface. For example, the router can send an HTTP GET request to the firmware server, requesting the metadata file for a specific firmware version. Upon receiving the request, the server sends the file containing the firmware transfer metadata as a response to the router. After obtaining the firmware transfer metadata, it needs to be verified. The verification process can include checking the format, completeness, and consistency of the metadata. For example, it can check whether the metadata file conforms to a predefined JSON or XML format, or check whether any key fields are missing.
[0036] S120: After successful verification, based on the firmware transmission metadata, request the download of firmware file data, and during the download process, perform real-time structural checks on the downloaded firmware file data according to the firmware transmission metadata.
[0037] After the firmware transfer metadata verification is successful, the router requests to download the firmware file data. The download request can be a standard HTTP or HTTPS request, containing a download link for the firmware file, which is typically included in the firmware transfer metadata. During the download process, the downloaded firmware file data needs to undergo real-time structure checks according to the firmware transfer metadata. For example, the download progress can be monitored in real time, and the current amount of data downloaded can be determined to match the expected firmware file size based on the preset size in the firmware transfer metadata. If the amount of data downloaded exceeds the preset size at any point in time, the download can be terminated immediately.
[0038] S130: When all firmware file data passes the structural check, reassemble all firmware file data.
[0039] Once all firmware file data has passed the structure check, the entire firmware file data is reassembled. For example, if the firmware file data is downloaded in chunks, after all chunks have been downloaded and passed the check, these chunks are assembled in the correct order to form a complete firmware file.
[0040] S140: After the firmware file data is reassembled, calculate the overall checksum of the firmware file data and compare it with the preset overall checksum contained in the firmware transmission metadata.
[0041] After reassembly, the overall checksum of the firmware file data is calculated. This checksum can be calculated using various algorithms, such as MD5, SHA256, or CRC32. After calculation, this overall checksum is compared with a preset overall checksum contained in the firmware's metadata. For example, the router can call its built-in hash algorithm library to calculate the SHA256 hash value of the reassembled firmware file, and then compare the result with the SHA256 hash value provided in the metadata.
[0042] S150: If the comparison results are the same, then perform a router firmware update; otherwise, stop the router firmware update.
[0043] If the comparison results are the same, the router firmware update proceeds. This means the firmware file is complete and has not been tampered with, and the update operation can be performed safely. The update process typically involves writing the new firmware to the router's flash memory chip. Conversely, if the comparison results are different, the router firmware update is stopped. In this case, the firmware file may have been tampered with or corrupted, and continuing the update would be risky. Therefore, the update should be stopped immediately, and a warning should be issued to the user or an error log should be logged.
[0044] The router firmware update method based on communication protocols proposed in this application aims to solve the problems of hidden faults and rollback mechanism violations in traditional firmware update processes. Its core innovation lies in the introduction of a multi-level, multi-stage firmware integrity verification mechanism.
[0045] Specifically, when updating router firmware, the first step is to acquire and verify the firmware transmission metadata. This step ensures that the underlying information for subsequent downloads and verifications is reliable. Unlike existing technologies that rely solely on digital signatures, this application performs real-time structural checks during the download process. For example, by comparing the required storage space of the firmware file data with the preset storage space, and by comparing the content of the firmware file data based on protocol structure information, minor data tampering introduced by the proxy server can be detected in a timely manner, avoiding the problem in traditional methods where the digital signature passes but internal verification fails.
[0046] Furthermore, after all firmware file data has passed structural checks and been reassembled, this application calculates the overall checksum of the firmware file data and compares it with the preset overall checksum contained in the firmware transmission metadata. This final verification step provides double protection for firmware integrity, ensuring that even the very few tamperings that are not detected during real-time checks can be identified. If the verification results are inconsistent, the update is immediately stopped, thereby effectively avoiding the risk of the device becoming "half-bricked" due to incomplete or tampered firmware.
[0047] Compared to existing technologies, the advantages of this application are: 1. Enhanced integrity verification: Traditional methods mainly rely on digital signatures, but this application adds firmware transmission metadata verification, real-time structural checks during the download process, and overall verification after the download is completed, forming multiple layers of protection, which can detect data tampering earlier and more comprehensively.
[0048] 2. Real-time and timely loss prevention: The system performs structural checks in real time during the download process. Once an anomaly is detected, the download can be terminated immediately, avoiding the download of complete but corrupted firmware. This saves time and network resources and reduces the risk of device damage.
[0049] 3. Prevent rollback mechanism from being compromised: Through a rigorous verification process, only complete and tamper-free firmware can enter the update stage, thereby preventing the rollback mechanism from being accidentally compromised due to abnormal firmware and improving the security of the update.
[0050] In summary, this application significantly improves the reliability and security of router firmware updates by introducing innovative mechanisms such as firmware transmission metadata verification, real-time structural checks, and overall verification. It effectively solves the problems caused by proxy server data tampering and rollback mechanism failure in existing technologies, providing a more robust and reliable solution for router firmware updates.
[0051] Specifically, in the aforementioned router firmware update method based on communication protocols, the firmware transmission metadata is defined in detail.
[0052] Firmware transmission metadata includes: the preset overall checksum of the firmware file and firmware file data structure information; wherein, the firmware file data structure information includes at least the preset storage space required by the firmware file, protocol structure information, and preset key area information of the firmware file.
[0053] The preset overall checksum of the firmware file refers to a hash value or checksum calculated by the firmware provider and embedded in the firmware transmission metadata before the firmware file is released. This checksum is used to verify the integrity of the downloaded and reassembled firmware file data after the firmware file data is reassembled, ensuring that it has not been tampered with or damaged during transmission. For example, it can be generated using cryptographic hash algorithms such as MD5 or SHA-256.
[0054] Firmware file data structure information is a collection of metadata describing the internal organization and expected characteristics of a firmware file. Its purpose is to guide real-time structure checks during the download process and to provide a basis for subsequent firmware file data reassembly.
[0055] Specifically, the preset storage space required for the firmware file refers to the minimum storage capacity required for the firmware file to be installed on the target router. This information is used to check whether the target device's storage space meets the requirements before or during the download, or to check whether the amount of data being downloaded matches expectations, in order to avoid update failures due to insufficient storage space.
[0056] Protocol structure information refers to the specifications of firmware files under a specific communication protocol, such as data encapsulation format, field definitions, and data order. This information is used in real time during the firmware file data download process to check whether the downloaded data conforms to the expected protocol structure. For example, it checks whether the data packet header, data body, and data trailer are arranged according to a preset format to identify illegal or tampered data segments.
[0057] Pre-defined critical areas in firmware files refer to regions within the firmware file that contain specific functionalities or security-sensitive information, such as the bootloader, kernel, and file system. Information about these regions, such as their starting address, length, hash value, or specific identifiers, is predefined in the firmware transfer metadata. This allows for focused checks on these critical areas during or after the download process to ensure their integrity and correctness, preventing malicious code injection or damage to critical functions.
[0058] This application's solution defines the preset overall checksum and firmware file data structure information in detail within the firmware transmission metadata. This allows the router to obtain a comprehensive and accurate description of the firmware file to be updated after acquiring the firmware transmission metadata. The preset overall checksum serves as the benchmark for final integrity verification, ensuring the final reliability of the firmware file data throughout the download, inspection, and reassembly process. The firmware file data structure information, including the preset storage space required by the firmware file, protocol structure information, and preset key area information, provides clear rules and criteria for real-time structural checks during the download process. Therefore, during firmware file data download, data can be verified segment by segment or block by block based on this structural information, promptly detecting and preventing any abnormal data that does not conform to the preset structure, size, or key area characteristics. This effectively avoids the risk of downloading corrupt or malicious firmware, significantly improving the security and reliability of the firmware update process.
[0059] By employing the aforementioned technical solution, key metadata information of the firmware file, including preset overall checksums and detailed structural information (such as preset storage space, protocol structure information, and preset key area information), is explicitly included in the firmware transmission metadata. This allows for sufficient verification evidence to be obtained in the early stages of the firmware update process. This not only enhances the verification capability of the firmware transmission metadata itself, but more importantly, it provides precise guidance and rigorous verification standards for subsequent firmware file data download and real-time structural checks. Consequently, it significantly improves the security, reliability, and efficiency of firmware updates, effectively preventing update failures or system instability caused by corrupted, tampered, or incompatible firmware files, thus providing a solid guarantee for the stable operation of the router firmware.
[0060] In the aforementioned router firmware update method based on communication protocols, the step of performing real-time structural checks on the downloaded firmware file data according to the firmware transmission metadata includes: Compare the required storage space for the firmware file data with the preset storage space; if they are not equal, terminate the download. Based on the protocol structure information, the content of the firmware file data is compared with the content of the preset firmware file data in the protocol structure information. If there are differences, the download is terminated. The key area information in the downloaded firmware file data is compared with the corresponding information in the key area information of the preset firmware file. If there is a discrepancy, the download is terminated.
[0061] The comparison between the required storage space for the firmware file data and the preset storage space aims to ensure that the downloaded firmware file data does not exceed the router's expected storage capacity, thereby avoiding update failures or system instability due to insufficient storage space. Specifically, during the download process, the cumulative size of the downloaded data can be monitored in real time and compared with the preset storage space required for the firmware file contained in the firmware transmission metadata. Once the amount of downloaded data is found to exceed the preset value, it is considered abnormal, and the download process is immediately terminated.
[0062] Furthermore, the critical area information in the downloaded firmware file data is compared with the corresponding information in the preset firmware file's critical area information to ensure the integrity and correctness of the core functional areas of the firmware. Critical areas of the firmware typically include the bootloader, operating system kernel, critical drivers, or security certificates. Any damage or tampering with these areas may cause the router to fail to boot properly or introduce security vulnerabilities. The preset firmware file's critical area information may include the expected hash value, version number, or specific identifier for these critical areas. During the download process, information corresponding to the critical areas in the downloaded firmware file data can be extracted and compared with the preset critical area information provided in the firmware transmission metadata. If the comparison results are inconsistent, it indicates that the critical areas may have been damaged or tampered with, and the download should be terminated immediately.
[0063] The solution proposed in this application introduces a real-time structural inspection mechanism during the firmware file data download process, which can effectively identify and prevent incomplete, damaged, or tampered firmware file data from entering the router system. Specifically, by performing multi-dimensional real-time verification on storage space, protocol structure, and key areas, the download is immediately terminated once any data that does not conform to the preset specifications is detected. This avoids downloading and reassembling potentially harmful or invalid firmware data completely, thereby reducing the computational overhead of subsequent verification stages and significantly reducing the risk of system crashes or functional malfunctions caused by abnormal firmware data during router updates.
[0064] Through the above technical solution, this application can detect and intercept abnormal data in the early stages of firmware file data download, significantly improving the security, reliability, and efficiency of the router firmware update process. Compared to relying solely on final overall verification, this real-time structural inspection mechanism can detect problems earlier, avoid unnecessary resource consumption, and provide the router with stronger resistance to malicious firmware attacks and data transmission errors, thereby ensuring the smooth progress of firmware updates and the stable operation of the router system.
[0065] In some embodiments described above, this application proposes performing real-time structural checks during firmware file download by comparing the required storage space of the firmware file data with a preset storage space. However, in actual firmware transmission scenarios, firmware files may be transmitted in different ways, such as in whole-segment transmission and segmented transmission. If an appropriate storage space check strategy is not adopted for different transmission methods, the check may be inaccurate, failing to detect storage space inconsistencies caused by differences in transmission methods in a timely manner, thereby affecting the reliability of firmware updates. Therefore, this application further proposes a specific method for comparing the required storage space of firmware file data. This method can adaptively adjust according to the firmware file transmission method to improve the accuracy and efficiency of the check.
[0066] Specifically, the steps mentioned above, which compare the required storage space for the firmware file data with the preset storage space and terminate the download if they are not equal, include: Determine the firmware file's transmission method, which includes whole-segment transmission and segmented transmission. If the firmware file is transmitted as a whole, the required storage space for the firmware file data is compared with the preset storage space. If they are equal, the download continues; otherwise, the download is terminated. If the firmware file is transmitted in segments, the number of segments and the storage space required for each segment are compared with the preset number of segments and the preset storage space for each segment contained in the segment information. If they are equal, the download continues; otherwise, the download is terminated.
[0067] In this embodiment, determining the firmware file transmission method refers to identifying, before or during the download of the firmware file data, whether the current firmware file is transmitted as a single complete data block (i.e., transmitted as a whole segment) or divided into multiple independent data blocks (i.e., transmitted in segments), based on the firmware transmission metadata or download protocol information. This determination forms the basis for subsequently adopting different storage space checking strategies.
[0068] Specifically, when the firmware file is determined to be transmitted as a single segment, the total storage space occupied by the firmware file data to be downloaded for this firmware update is obtained and directly compared with the preset storage space required by the firmware file in the firmware transmission metadata. If the two are completely equal, the storage space consistency check is considered passed, and the download process can continue; otherwise, if the two are not equal, it indicates that the firmware file data may have been truncated, corrupted, or tampered with during transmission, and the download process will be terminated immediately to prevent the installation of incomplete or incorrect firmware.
[0069] When the firmware file is determined to be transmitted in segments, a more detailed check is required because the firmware file is split into multiple segments for transmission. At this point, the number of firmware file segments to be downloaded for this firmware update, and the actual storage space occupied by each downloaded segment, are obtained. This information is compared with the preset number of segments and the preset storage space for each segment contained in the firmware transmission metadata. Only when the number of downloaded segments matches the preset number, and the actual storage space of each segment equals its corresponding preset storage space, is the segmented transmission storage space check considered passed, and the download process continues. If any of these conditions are not met, such as a mismatch in the number of segments or an incorrect segment size, the download process will be terminated. Segment information is typically included in the firmware transmission metadata to guide segmented transmission and subsequent reassembly.
[0070] In this embodiment, by introducing a judgment on the firmware file transmission method and adopting different storage space comparison strategies based on the judgment result, the limitations that traditional methods may have when handling different transmission modes are effectively solved. It is precisely because it can distinguish between whole-segment transmission and segmented transmission that storage space checks can more accurately adapt to actual transmission scenarios. For whole-segment transmission, direct total comparison can quickly verify file integrity; while for segmented transmission, through a refined comparison of the number of segments and the storage space of each segment, anomalies in individual segments can be detected in a timely manner, thus avoiding the situation where problems are only discovered after all segments have been downloaded, significantly improving the real-time performance and effectiveness of the check.
[0071] The above technical solution enables flexible and precise storage space consistency checks based on the specific transmission method of the firmware file. This not only improves the accuracy and reliability of structural checks during firmware file download but also allows for earlier detection and prevention of storage space mismatch issues caused by transmission errors, file corruption, or malicious tampering. Therefore, it effectively avoids the risk of incomplete or erroneous firmware being downloaded and installed, significantly enhancing the security and stability of the router firmware update process.
[0072] In some embodiments of the present invention, assuming the router needs to update a firmware file, its firmware transmission metadata includes a preset overall checksum for the firmware file, a preset storage space required for the firmware file, and firmware file data structure information. When the firmware file transmission method is determined to be a whole-segment transmission, for example, the firmware transmission metadata indicates that the total size of the firmware file should be 10MB. During the download process, if it is detected in real time that the size of the firmware file data to be downloaded for this update is 9.5MB, which does not match the preset 10MB, the system will immediately terminate the download and send an error notification to the user or management system, thereby avoiding the download of an incomplete firmware file.
[0073] As a specific implementation, when the firmware file is determined to be transmitted in segments—for example, if the firmware transmission metadata indicates that the total size of the firmware file is 10MB and it is divided into 10 segments, each 1MB in size—then the download process involves receiving each segment sequentially. If, when the third segment is received, its size is detected as 0.9MB, which does not match the preset 1MB, or if, after receiving all segments, only 9 segments are found to have been received, which does not match the preset number of 10 segments, the download is immediately terminated. This segmentation checking mechanism ensures that even during segmented transmission, any inconsistencies in storage space can be detected and addressed promptly, thereby guaranteeing the integrity of the firmware file data.
[0074] In some embodiments described above, a method is proposed to obtain and verify firmware transmission metadata corresponding to the firmware to be updated when updating router firmware. However, in practical applications, firmware transmission metadata may have potential defects due to various reasons (such as transmission errors, non-standard formats, malicious tampering, or internal logical inconsistencies). Simple verification may not be sufficient to fully identify these problems, resulting in structural errors, incomplete data, or discrepancies with expectations in the downloaded firmware file, and may even lead to security vulnerabilities or update failures.
[0075] In this regard, this application further proposes steps for verifying firmware transmission metadata, including: The firmware transmits metadata and performs normalization processing; this normalization processing includes: whitespace character removal, Unicode character normalization, and key-value pair sorting. The standardized firmware transmit metadata is subjected to structural and semantic verification; the structural and semantic verification includes: data type verification, numerical range verification, format verification, and mandatory field existence verification. Cross-validation of key parameters for consistency of firmware transmission metadata is performed. This cross-validation includes: comparing the preset storage space required for the firmware file when transmitting in whole segments with the total storage space required for all segments when transmitting in segments; associating the hash value of the key area of the firmware file with the overall hash value of the firmware file; and verifying the consistency between the version number and the download link.
[0076] Specifically, normalization refers to preprocessing the raw firmware transmission metadata to eliminate inconsistencies that may be introduced by different sources or encoding methods. Whitespace removal aims to remove unnecessary spaces, tabs, or newlines from the metadata, ensuring the compactness and consistency of the data content. Unicode character normalization is used to unify the same characters in different encoding forms into a standard form, avoiding parsing errors caused by differences in character encoding. Key-value pair sorting sorts all key-value pairs in the metadata according to preset rules (such as alphabetical order), which is crucial for subsequent hash calculations or comparison operations, ensuring that the logical content can still be correctly identified even if the order of metadata fields changes.
[0077] Structure and semantic validation perform in-depth validity checks on the normalized firmware transport metadata. Data type validation ensures that the value of each field conforms to its expected type; for example, fields representing storage space or version number should be numeric. Numeric range validation limits the range of values for numeric fields to prevent outliers from exceeding reasonable limits. Format validation verifies that specific fields (such as dates, URLs, or hash values) conform to predefined format specifications. Mandatory field existence validation confirms that all required critical fields are present in the metadata; if any mandatory field is missing, the metadata is considered invalid.
[0078] Cross-validation of key parameter logical consistency verifies the logical relationships between different parameters in the firmware transmission metadata to ensure that these parameters are logically self-consistent and consistent. Comparing the pre-defined storage space required for the firmware file when transmitting as a whole with the total storage space required for all segments when transmitting in segments verifies whether the total size declared in both transmission modes is consistent, preventing data mismatch due to transmission mode switching. Associating the hash value of key areas of the firmware file with the overall hash value of the firmware file verifies whether there is an expected logical relationship between the hash value of key areas declared in the metadata and the hash value of the overall firmware file. For example, whether the hash value of the key area is a component in the calculation of the overall hash value or can be derived through a specific algorithm. Version number and download link consistency verification checks whether the firmware version number declared in the metadata matches the version information contained in the actual download link to prevent downloading incorrect or tampered firmware.
[0079] The method of this invention effectively addresses the limitations of basic verification by introducing a multi-stage, multi-dimensional firmware transmission metadata verification mechanism. First, standardization ensures the uniformity of metadata format, eliminating potential parsing problems caused by differences in encoding, whitespace characters, or field order, laying the foundation for subsequent precise verification. Second, structural and semantic verification, starting from the legality of the data itself, ensures the accuracy and completeness of metadata content through checks on data type, numerical range, format, and the existence of mandatory fields, avoiding download or update problems caused by data errors or omissions. Finally, cross-validation of key parameter logical consistency starts from the logical correlation between parameters within the metadata. By comparing storage space under different transmission modes, the correlation between key area hash values and the overall hash value, and the consistency between the version number and the download link, more hidden logical errors or malicious tampering can be discovered. This minimizes the probability of firmware update failure or security risks due to metadata issues before firmware file data download.
[0080] Through the above technical solutions, this application can significantly improve the security, reliability, and robustness of the router firmware update process. Compared with solutions that only perform basic verification, this application effectively avoids parsing failures caused by inconsistent metadata formats through standardized processing; it ensures the accuracy and completeness of metadata content through structural and semantic verification, preventing the introduction of invalid or erroneous data; and it can identify logical contradictions or inconsistencies within the metadata through cross-validation of key parameter logical consistency, thereby effectively resisting more complex tampering attacks or configuration errors. Therefore, potential problematic firmware can be detected and prevented before the firmware file data is downloaded, greatly reducing the risk of update failures, system instability, or even security vulnerabilities caused by defects in firmware transmission metadata, ensuring the smooth progress of router firmware updates and the long-term stable operation of the system.
[0081] In another embodiment of the invention, it is assumed that the router needs to update its firmware and obtain a firmware transmission metadata.
[0082] First, the metadata transmitted by the firmware is standardized. For example, extra spaces or characters with different encodings in the metadata are removed or standardized. If the metadata is a JSON string, its key-value pairs are reordered alphabetically; for example, `{"version": "1.0", "size": "10MB"}` will be processed into `{"size": "10MB", "version": "1.0"}` to ensure standardized representation.
[0083] Secondly, the system performs structural and semantic checks on the standardized firmware transmission metadata. For example, it checks whether the "preset overall checksum of firmware file" field is in the expected hash string format, and whether the "preset storage space required for firmware file" field is a positive integer and its value is within a reasonable range (e.g., not less than 1MB and not more than 512MB). It also checks whether all fields defined as mandatory in the protocol (such as version number, file size, checksum type, etc.) are present.
[0084] Finally, cross-validation of key parameters for logical consistency is performed. For example, if the metadata provides both the preset storage space required for the firmware file during whole-segment transmission (e.g., 100MB) and the total storage space required for all segments during segmented transmission (e.g., segment 1 is 20MB, segment 2 is 30MB, segment 3 is 50MB, totaling 100MB), the system compares these two values. If they do not match, the verification fails. As another example, the firmware version number declared in the metadata (e.g., "V2.0") is extracted and compared with the version information in the download link. If the download link points to "V1.9," the version number is considered inconsistent with the download link, and the verification fails. Through these multi-layered verifications, even if the metadata appears correct on the surface, internal logical contradictions or discrepancies with external information can be detected and prevented in a timely manner, effectively ensuring the security of firmware updates.
[0085] Specifically, the detailed implementation method for the step of performing cross-validation of key parameter logical consistency on firmware transmission metadata is as follows: The comparison between the total storage space of the firmware file and the total storage space of each segment after the firmware file is divided is to compare the preset storage space required for the entire firmware file in the firmware transmission metadata with the total storage space required for all segments of the firmware file after the firmware file is divided. If the two are inconsistent, the verification fails. Associating the hash value of the key area of the firmware file with the hash value of the overall firmware file is a logical verification of the hash value of the key area of the firmware file in the firmware transmission metadata. If the hash value of the key area of the firmware file is logically incompatible with the hash value of the overall firmware file, the verification will fail. The version number and download link consistency verification verifies the firmware version number in the firmware transmission metadata against the version information contained in the download link. If the version information contained in the two is inconsistent, the verification fails.
[0086] Specifically, the total storage space of the firmware file is compared with the sum of the data storage spaces of each segment after the firmware file is segmented. This aims to ensure the consistency of the total storage space declared by the firmware file under different transmission modes (i.e., whole-segment transmission or segmented transmission). When the firmware transmission metadata provides both the preset storage space required for whole-segment transmission and the sum of the storage space required for all segmented data when the firmware file is transmitted in segments, the system will strictly compare these two values. If the comparison result shows any inconsistency between the two, it indicates that the firmware transmission metadata may be incorrect or has been tampered with. In this case, the verification process will fail, thereby effectively preventing potential firmware update risks.
[0087] Associating the hash value of a critical area in the firmware file with the overall hash value of the firmware file refers to the logical verification performed on the hash values of critical areas in the firmware file within the aforementioned firmware transmission metadata, comparing them with the overall hash value of the firmware file. This verification aims to ensure the expected logical compatibility between the core components (critical areas) of the firmware file and the integrity of the entire firmware file. For example, the hash value of a critical area might be designed as part of the overall hash value calculation, or there might be a specific mathematical relationship between the two. If this logical relationship is incompatible, it indicates that the firmware file may have been partially tampered with during transmission, or that the metadata itself is inconsistent. In this case, the verification will fail to maintain the integrity of the firmware.
[0088] Version number and download link consistency verification verifies the firmware version number in the firmware transmission metadata against the version information contained in the download link. Its purpose is to ensure that the firmware version the user attempts to download is completely consistent with the version declared in the metadata and the version pointed to by the download link. For example, the Uniform Resource Locator (URL) path of the download link may contain version number information. If the firmware version number does not match the version information contained in the download link, it may mean that the download source is incorrect, the link is expired, or there is malicious redirection. In this case, the verification will fail, thus preventing the download of incorrect or insecure firmware versions.
[0089] This application ensures the reliability and security of the firmware update process from the source by performing multi-dimensional and cross-validation of key parameters in the firmware transmission metadata. Specifically, by comparing storage space information under different transmission modes, it can effectively identify and prevent file size inconsistencies caused by differences in transmission methods or malicious tampering. By correlating the hash values of key areas of the firmware file with the overall hash value, it can thoroughly examine the consistency of the internal structure of the firmware file, preventing situations where critical components are tampered with individually without the overall hash value being detected. In addition, by verifying the consistency between the version number and the download link, it can avoid download errors or security vulnerabilities caused by version information mismatches. These cross-validation mechanisms work together to form a robust defense, significantly improving the robustness of the firmware update process.
[0090] The above technical solutions significantly enhance the security and reliability of the router firmware update process. Specifically, by performing logical consistency cross-validation on key parameters in the firmware transmission metadata, various potential attacks or errors can be effectively identified and prevented, such as file size mismatches, tampering with the internal firmware structure, and inconsistent version information. This not only ensures that the downloaded firmware file is complete, undisturbed, and consistent with the expected version, but also fundamentally reduces the risk of router malfunctions or security vulnerabilities due to firmware update failures or the installation of malicious firmware, thus providing users with a more secure and stable firmware update experience.
[0091] In some embodiments described above, firmware transmission metadata is verified, and the downloaded firmware file data undergoes structural checks to ensure the integrity and security of the firmware update. However, in real-world network environments, especially in scenarios with network optimizers, the network optimizer may modify or compress the transmitted firmware file data, causing the original verification and checking mechanisms to fail, misjudging the data as corrupted or tampered, and thus interrupting the normal firmware update process. Failure to address these issues may lead to router firmware update failures, impacting user experience and potentially introducing security vulnerabilities.
[0092] In this regard, this application further proposes that the steps for verifying the aforementioned firmware transmission metadata also include: For network environments with a network optimizer, while acquiring firmware transmission metadata, a list of network optimization modes is also acquired. The list of network optimization modes includes the mode identifier of the firmware transmission metadata, the original mode hash value, the regular expression processed by the network optimizer, and the expected length range of the original mode. During the firmware file download process, the firmware file data is matched according to the network optimization mode list.
[0093] Specifically, when a router updates its firmware, if a network optimizer is detected in the current network environment when obtaining the firmware transmission metadata for the firmware to be updated, the system will simultaneously obtain a list of network optimization patterns. This list of network optimization patterns is either pre-configured or dynamically obtained and describes the specific optimization behaviors that the network optimizer may perform on the firmware transmission metadata or firmware file data. The list includes pattern identifiers to uniquely identify a specific optimization pattern; the original pattern hash value to represent the expected hash value of the firmware transmission metadata or firmware file data before processing by the network optimizer, for integrity verification; the regular expression processed by the network optimizer to describe the specific pattern or structure that the data may present after processing, used for matching and identification during the download process; and the expected length range of the original pattern to provide the expected length range of the data in the unoptimized state, serving as another verification criterion. During the firmware file data download process, the system uses this list of network optimization patterns to perform real-time content matching on the received firmware file data to identify and adapt to any modifications that the network optimizer may introduce.
[0094] This application's solution obtains a list of network optimization patterns in a network environment with a network optimizer, and then matches the firmware file data against this list during the firmware file download process. This effectively identifies and processes firmware data modified by the network optimizer. Specifically, when the network optimizer compresses, encodes, or otherwise modifies firmware data, traditional hash checks or structure checks may fail. However, by introducing a list of network optimization patterns, the system can anticipate these optimization patterns and intelligently match and identify data during the download process using pattern identifiers, original pattern hash values, regular expressions processed by the network optimizer, and the expected length range of the original patterns. Therefore, even if data is modified by the optimizer, the system can determine whether these modifications conform to the expected optimization patterns and are not malicious tampering, thus ensuring the smooth progress of the firmware update process.
[0095] Through the above technical solution, this application can significantly improve the robustness and compatibility of router firmware update methods in complex network environments. Especially in scenarios with network optimizers, this solution can effectively avoid update failures caused by harmless modifications to data by the network optimizer, ensuring a high success rate for firmware updates. Simultaneously, by identifying and matching optimization modes, the security of the firmware update process can be further enhanced, distinguishing between normal optimization behavior and potential malicious tampering, thereby ensuring the stable operation of the router system and data security.
[0096] In some preferred embodiments, it is assumed that an HTTP compression optimizer is deployed in the network when a router firmware update server transmits firmware file data to the router. This optimizer compresses all transmitted firmware file data using Gzip compression. In a traditional update process, after the router receives the compressed data, its hash verification or structure check will fail because the data format does not match the expectation, causing the update to be interrupted.
[0097] According to the scheme in this application, when obtaining firmware transmission metadata, the system simultaneously obtains a list of network optimization patterns. This list may contain a pattern identifier "HTTP_GZIP_COMPRESSION," whose original pattern hash value corresponds to the hash value of the uncompressed firmware. The regular expression processed by the network optimizer may describe the header characteristics of the Gzip compressed data, and the expected length range of the original pattern indicates the expected size of the uncompressed firmware. During the firmware file data download process, the download inspection module monitors the downloaded data stream in real time. When the system detects that the data stream matches the regular expression characteristics of the "HTTP_GZIP_COMPRESSION" pattern, it recognizes that this is Gzip compressed data. At this point, based on the information in the list, the system can decompress the downloaded data using Gzip, restoring it to its original state before performing subsequent structural checks and overall verification. Subsequently, structural checks and hash verifications are performed on the decompressed data. If the decompressed data passes all checks, the firmware file data is considered complete and tamper-proof, thus allowing the firmware update to continue. In this way, even if the network optimizer modifies the data, the proposed solution can intelligently adapt and process it correctly, ensuring the smooth completion of the firmware update.
[0098] In the embodiments of this application, a scheme is proposed for network environments with a network optimizer, which involves obtaining a list of network optimization modes and performing content matching on the firmware file data according to this list during the firmware file download process. However, in practical applications, accurately determining whether the network optimizer has intervened in the current download process and deciding whether to perform content matching accordingly is crucial to ensuring the integrity and security of the firmware download. Failure to effectively identify the actual operating state of the network optimizer may lead to unnecessary matching operations or failure to perform necessary matching during the optimizer's actual operation, thereby affecting the correctness of the firmware data.
[0099] In this regard, this application further proposes a step in the firmware file download process that involves content matching of firmware file data according to a network optimization mode list, including: Based on firmware transmission metadata, generate and initiate download links for firmware file data, and monitor in real time whether the download links contain optimization declaration header fields; If the download link contains an optimization declaration header field, then the downloaded firmware file data is matched against the network optimization mode list. Download will be terminated if the optimization declaration header field is not included.
[0100] Specifically, generating and initiating the firmware file download link means that the router constructs a Uniform Resource Locator (URL) or similar access path to obtain the firmware file data based on the download address and related parameters provided in the firmware transmission metadata, and initializes the data transmission session. Real-time monitoring of the download link for optimization declaration header fields can be understood as parsing these headers after the download request is sent or when receiving HTTP header information from the server response to check for the presence of specific identifying fields added by the network optimizer. This optimization declaration header field is typically inserted by the network optimizer after optimizing the data to inform the recipient that the data has been optimized. For example, this field can be a custom HTTP header such as "X-Optimizer-Status: Optimized" or "Content-Encoding: optimized-format".
[0101] If the download link contains an optimization declaration header field, the received firmware file data is matched against the network optimization pattern list. This means that once it's confirmed that the data stream has been processed by the network optimizer, the system uses a pre-acquired network optimization pattern list to perform segment-by-segment or block-by-block matching checks on the firmware file data received during the download. This matching aims to verify whether the data processed by the optimizer conforms to expected patterns; for example, it checks whether the data structure, encoding method, or content of specific regions matches the regular expressions or expected patterns defined in the network optimization pattern list.
[0102] In practical applications, if the optimization declaration header field is not included, the download is terminated. This step aims to prevent erroneous content matching of firmware file data without network optimizer intervention, or more importantly, to prevent the download of unoptimized raw data as optimized data when an optimizer is expected but not actually present, leading to subsequent processing errors. Terminating the download effectively avoids potential data integrity issues and security risks.
[0103] This application's solution addresses the accuracy issue of firmware data download in a network optimizer environment by introducing real-time monitoring of the optimization declaration header field during the firmware file download process. When the router initiates a firmware file download link, it first checks whether the download link or response header contains the optimization declaration header field added by the network optimizer. This mechanism allows the system to dynamically determine whether the current data stream has indeed been processed by the network optimizer. If the optimization declaration header field is detected, it indicates that the data has been optimized. At this point, the downloaded firmware file data is matched against a preset list of network optimization modes, ensuring that the optimized data conforms to the expected structure and content, thereby guaranteeing data integrity and correctness. Conversely, if the optimization declaration header field is not detected, it means that the current data stream may not have been processed by the optimizer, or the optimizer may not be working as expected. In this case, terminating the download effectively prevents unoptimized data from being mistakenly treated as optimized data for processing, thus preventing firmware update failures or security vulnerabilities caused by data format mismatches.
[0104] Through the above technical solution, this application can accurately identify the network optimizer's intervention status in the firmware file download process, thereby performing targeted content matching operations. This avoids unnecessary matching when there is no optimizer intervention, improving download efficiency and system resource utilization. More importantly, by terminating the download when no optimization declaration header field is detected, it effectively prevents the download of unintended firmware file data when an optimizer is expected but actually not performing optimization, significantly enhancing the robustness and security of the firmware update process and ensuring the reliability of router firmware updates.
[0105] In some preferred embodiments, a specific example is given below. Assume the router needs to update its firmware and has already obtained firmware transfer metadata and a list of network optimization modes. Based on the firmware transfer metadata, the router generates and initiates a download link for the firmware file data.
[0106] Scenario 1: During the download process, the router detects an optimization declaration header field named "X-Optimized-Content: true" in the HTTP response header of the download link. This indicates that the optimizer in the network has already processed the firmware file data. At this point, the router will perform content matching on the received firmware file data according to a pre-acquired list of network optimization patterns. For example, the list of network optimization patterns may contain a regular expression to verify whether the optimized data blocks conform to a specific compression or encoding format. If the match is successful, the download continues; if the match fails, the download may be terminated and an error reported.
[0107] Scenario 2: During the download process, the router detects in real-time that the HTTP response header of the download link does not contain any optimization declaration header fields. This may mean that there is no network optimizer in the current network environment, or that the network optimizer has not intervened in this download. In this case, to avoid processing unoptimized data as optimized data, the router will immediately terminate the download. This ensures that firmware file data is only allowed to continue downloading and subsequent processing when it is clearly confirmed that the data has been processed by the optimizer and conforms to the expected pattern, thereby guaranteeing the accuracy and security of firmware updates.
[0108] In some of the embodiments described above in this application, a scheme is proposed to obtain a list of network optimization modes and perform content matching on firmware file data during the firmware file download process in a network environment with a network optimizer. However, even after content matching, the downloaded firmware file data may still be in a state optimized by the network optimizer, such as being compressed, encrypted, or otherwise modified. If these optimized data are used directly for router firmware updates, it may lead to update failure, system instability, or the introduction of security risks, because routers typically expect to receive raw, unmodified firmware file data.
[0109] In response, this application further proposes that, based on the aforementioned list of network optimization modes, after the downloaded firmware file data is matched for content, the downloaded firmware file data optimized by the network optimizer is de-optimized to obtain the original firmware file data.
[0110] Specifically, "downloaded firmware file data optimized by the network optimizer" refers to firmware file data that has been compressed, encrypted, encoded, or otherwise modified by the network optimizer during transmission in a network environment with a network optimizer. These modifications are intended to improve transmission efficiency or security, but may result in data that does not conform to the original firmware format expected by the router.
[0111] "Deoptimization" refers to the process of restoring firmware file data to its original state after it has been processed by the network optimizer. This may involve decompression, decryption, decoding, or reversing other optimization operations. The specific deoptimization method should correspond to the optimization method recorded in the network optimization mode list. For example, if the network optimizer performed Gzip compression, the deoptimization process will perform Gzip decompression.
[0112] "Raw firmware file data" refers to data that is completely identical to the original firmware file described in the firmware transfer metadata, without any modifications by the network optimizer. This is the final data format required for the router to perform firmware updates.
[0113] This application's solution ensures that even if the network optimizer modifies the firmware file data, the router ultimately receives the unmodified original firmware file data by performing a de-optimization operation after content matching. The risk of directly using optimized data for firmware updates stems from the fact that the network optimizer may adjust the format, content, or structure of the firmware file data. De-optimization eliminates these potential incompatibilities, allowing subsequent firmware reassembly, verification, and update processes to be based on correct data, thereby guaranteeing the success rate and security of firmware updates.
[0114] Through the above technical solution, this application effectively solves the problem that firmware file data modification may lead to update failure in network environments with network optimizers. This solution ensures that the router always uses original, untampered firmware file data during firmware updates, thereby significantly improving the reliability and security of firmware updates and avoiding update interruptions or system failures caused by data format mismatches or abnormal content.
[0115] In some preferred embodiments, it is assumed that during the firmware file data download process, an optimization declaration header field indicating that the data has been Gzip compressed is detected in the download link. Based on the network optimization mode list, the system identifies that the data has been Gzip compressed. After content matching of the received firmware file data, the system invokes the Gzip decompression algorithm to de-optimize the data. After decompression, the original firmware file data is obtained, which can then be used for subsequent reassembly and verification steps. As another specific implementation, it is assumed that the network optimizer performs specific encryption on the firmware file data, and the network optimization mode list contains the corresponding decryption key and algorithm information. After content matching, the system uses this information to decrypt the downloaded encrypted data, thereby recovering the original firmware file data.
[0116] like Figure 2 As shown, the present invention also provides a router firmware update system 200 based on a communication protocol, comprising: Firmware transmission metadata download verification module 210 is used to obtain the firmware transmission metadata of the corresponding firmware to be updated when the router updates the firmware, and to verify the firmware transmission metadata. The download inspection module 220 is used to request the download of firmware file data based on firmware transmission metadata after verification, and to perform a real-time structural inspection of the downloaded firmware file data according to the firmware transmission metadata during the download process. Reassembly module 230 is used to reassemble all firmware file data when all firmware file data has passed the structural check; The comparison module 240 is used to calculate the overall check value of the firmware file data after the firmware file data is reassembled, and compare it with the preset overall check value contained in the firmware transmission metadata. The update judgment module 250 is used to perform router firmware update when the comparison results are the same, and otherwise stop router firmware update.
[0117] Although embodiments of the present invention have been shown and described above, it is understood that the embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the embodiments within the scope of the present invention.
Claims
1. A method for updating a router firmware based on a communication protocol, the method comprising: The application relates to a method for updating firmware of a router. When the router updates the firmware, the firmware transmission metadata corresponding to the firmware to be updated is acquired, and the firmware transmission metadata is verified; After verification, based on the firmware transmission metadata, the firmware file data is requested to be downloaded, and during the downloading process, the downloaded firmware file data is checked in real time according to the firmware transmission metadata; When all the firmware file data passes the structural check, the firmware file data is reassembled; After the firmware file data is reassembled, the overall check value of the firmware file data is calculated and compared with the preset overall check value contained in the firmware transmission metadata; If the comparison result is the same, the router firmware is updated, otherwise, the router firmware update is stopped.
2. The communication protocol based router firmware update method of claim 1, wherein, The firmware transmission metadata includes a preset overall check value of the firmware file and firmware file data structure information; wherein the firmware file data structure information at least includes a preset storage space required by the firmware file, protocol structure information and preset firmware file key area information.
3. The communication protocol based router firmware update method of claim 2, wherein, According to the firmware transmission metadata, the downloaded firmware file data is checked in real time, including: If the required storage space of the firmware file data is not equal to the preset storage space, the downloading is terminated; Based on the protocol structure information, the content of the firmware file data is compared with the preset firmware file data content in the protocol structure information, if there is different content, the downloading is terminated; The key area information in the downloaded part of the firmware file data is compared with the corresponding information in the preset firmware file key area information, if there is different information, the downloading is terminated.
4. The communication protocol based router firmware update method of claim 3, wherein, If the required storage space of the firmware file data is not equal to the preset storage space, the downloading is terminated, including: The transmission mode of the firmware file is judged, the transmission mode of the firmware file includes whole segment transmission and segmented transmission; If the transmission mode of the firmware file is whole segment transmission, the required storage space of the firmware file data is compared with the preset storage space, if they are equal, the downloading is continued, if they are not equal, the downloading is terminated; If the transmission mode of the firmware file is segmented transmission, the number of segmented data of the firmware file and the required storage space of each segmented data are compared with the preset segmented data number and the preset storage space of each segmented data, if they are equal, the downloading is continued, if they are not equal, the downloading is terminated.
5. The communication protocol based router firmware update method of claim 4, wherein, The firmware transmission metadata is verified, including: The firmware transmission metadata is subjected to normalization processing; wherein the normalization processing includes blank character removal, Unicode character normalization and key-value pair sorting; The firmware transmission metadata subjected to normalization processing is subjected to structural and semantic verification; wherein the structural and semantic verification includes data type verification, numerical range verification, format verification and mandatory field existence verification; The key parameter logical consistency cross verification is performed on the firmware transmission metadata; wherein, the key parameter logical consistency cross verification includes: firmware file required preset storage space when using whole segment transmission is compared with total storage space of all segmented data when using segmented transmission, firmware file key region hash value is associated with firmware file overall hash value, version number and download link consistency verification.
6. The communication protocol based router firmware update method of claim 5, wherein, In the step of performing key parameter logical consistency cross verification on the firmware transmission metadata: Firmware file total storage space is compared with total storage space of each segmented data after firmware file segmentation, which is to compare firmware file required preset storage space when using whole segment transmission with total storage space of all segmented data when using segmented transmission in the firmware transmission metadata, if the two are inconsistent, the verification fails; Firmware file key region hash value is associated with firmware file overall hash value, which is to logically verify firmware file key region hash value and firmware file overall hash value in the firmware transmission metadata, if the firmware file key region hash value and the firmware file overall hash value are not logically compatible, the verification fails; Version number and download link consistency verification is to verify firmware version number in the firmware transmission metadata and version information contained in the download link, if the version information contained in the two is inconsistent, the verification fails.
7. The communication protocol based router firmware update method of claim 1, wherein, The verification on the firmware transmission metadata further includes: For network environment with network optimizer, network optimization mode list is obtained at the same time when the firmware transmission metadata is obtained; wherein, the network optimization mode list includes mode identifier, original mode hash value, regular expression after being processed by the network optimizer and expected length range of the original mode of the firmware transmission metadata; In the firmware file data download process, content matching is performed on the firmware file data according to the network optimization mode list.
8. The communication protocol based router firmware update method of claim 7, wherein, In the firmware file data download process, content matching is performed on the firmware file data according to the network optimization mode list, including: Based on the firmware transmission metadata, download link of the firmware file data is generated and started, and whether the optimization declaration header field is contained in the download link is monitored in real time; If the optimization declaration header field is contained in the download link, content matching is performed on the firmware file data received by download according to the network optimization mode list; If the optimization declaration header field is not contained, the download is terminated.
9. The communication protocol based router firmware update method of claim 8, wherein, After the content matching on the firmware file data received by download according to the network optimization mode list is completed, the firmware file data optimized by the network optimizer is de-optimized to obtain the original firmware file data.
10. A communication protocol based router firmware update system, characterized in that, It includes: Firmware transmission metadata download verification module, used for obtaining firmware transmission metadata corresponding to firmware to be updated when the router updates firmware, and verifying the firmware transmission metadata; Download checking module, used for requesting to download firmware file data based on the firmware transmission metadata after the verification passes, and performing real-time structural checking on the downloaded firmware file data according to the firmware transmission metadata in the download process; a reassembling module, configured to reassemble all the firmware file data when the structural check is passed; a comparison module, configured to calculate an overall check value of the firmware file data after the reassembling is completed, and compare the overall check value with a preset overall check value contained in the firmware transmission metadata; an update judging module, configured to perform the router firmware update when the comparison result is the same, and stop the router firmware update otherwise.
Citation Information
Patent Citations
Firmware processing method for IO card of trusted DCS and related equipment
CN119225776A
High-real-time security measurement method for secure and trusted controller
CN119377942A
Firmware protection method and system based on security coprocessor
CN120068051A
Wifi router online upgrade security verification method and system
CN120676360A
User apparatus based on trusted platform module and firmware updating method using the same
KR101805310B1