A Security Assessment Method for Firmware Out-of-Band Data Storage Mode
By evaluating the out-of-band data storage mode of firmware using the random forest algorithm, the problem of lack of security detection in existing technologies is solved, and the security assessment and protection of firmware data is realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG UNIV
- Filing Date
- 2023-12-04
- Publication Date
- 2026-07-17
Smart Images

Figure CN117648722B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of hardware security technology, and in particular relates to a security assessment method for firmware out-of-band data storage mode, which can be used to help assess the security level of firmware out-of-band storage mode when designing memory chips. Background Technology
[0002] With the rapid development of IoT technology, IoT products are becoming increasingly diverse, playing a vital role in people's daily lives, from cloud platforms to smart home appliances. However, because IoT products involve users' personal information and data, protecting the information security of IoT products has become particularly important. Especially since most IoT products contain firmware and can be controlled through firmware, the security of firmware data storage is crucial. One common method to enhance firmware data security is to add error correction codes. Generally, the chip storing firmware mainly stores two parts of data: the firmware data itself and out-of-band data. Out-of-band data is used to correct errors in the firmware data; when errors occur in the firmware data, they can be corrected using out-of-band data. Commercial memory chips generally disclose the out-of-band data storage mode, but IoT product designers can modify the out-of-band data storage mode.
[0003] Currently, existing firmware security testing primarily focuses on analyzing firmware source code or binary code, using methods such as static and dynamic analysis to identify security vulnerabilities and weaknesses. However, there are no suitable security analysis and prevention measures for the out-of-band data storage mode of firmware. This results in the firmware storage format being unprotected, allowing attackers to easily replace data within the firmware, leading to problems such as loss of control of IoT products and leakage of user privacy data.
[0004] Therefore, a current issue is the lack of a security detection method for out-of-band firmware data storage. Such a method could help protect the integrity and security of firmware data, preventing attackers from maliciously tampering with or replacing it. Simultaneously, it would also enhance firmware security and protect user privacy data from infringement. Summary of the Invention
[0005] The purpose of this application is to address the shortcomings of existing technologies by providing a method for security assessment of firmware out-of-band data storage modes.
[0006] According to a first aspect of the embodiments of this application, a method for security assessment of firmware out-of-band data storage mode is provided, comprising:
[0007] (1) Firmware data extraction: Extract all firmware data, remove data except for data bits and out-of-band error correction codes, and convert the remaining data bits and out-of-band error correction codes into feature vectors and labels as inputs to the random forest algorithm, respectively.
[0008] (2) Random forest evaluation: The random forest algorithm is used to test the reversibility of each bit of the error correction code and the error correction code as a whole, and the corresponding prediction accuracy is obtained, which is the reversibility score of the corresponding error correction code.
[0009] (3) Security assessment: Based on the error correction code reversibility score obtained in step (2), calculate the security of the firmware out-of-band data storage mode.
[0010] Furthermore, step (1) specifically includes:
[0011] (1.1) Convert the firmware binary file into a processable file format and obtain the position, number of bits and corresponding relationships of the data bits and out-of-band error correction codes;
[0012] (1.2) Based on the position, number of bits and correspondence of the data bits and out-of-band error correction codes, extract the data bits and out-of-band error correction codes and convert them into feature vectors and labels as inputs to the random forest algorithm.
[0013] Furthermore, in step (1.2), duplicate data bits are removed when extracting data bits and error correction codes.
[0014] Furthermore, step (2) specifically includes:
[0015] (2.1) Random forest construction: Based on the data bits and error correction code, the CART algorithm is used to generate a random forest classification tree, and the CART pruning algorithm is used to prune and select the optimal subtree;
[0016] (2.2) Data evaluation: Divide the data bits and corresponding error correction codes obtained in step (1) into training set and test set. Use the training set to train the random forest model obtained in step (2.1). While using the test set to obtain prediction results, adjust the parameters. Under the settings of using one bit of the error correction code as the label and using the entire error correction code as the label, use the adjusted model to predict the test set. Obtain the prediction results of each bit of the error correction code and the error correction code as a whole, and calculate the prediction accuracy of each bit, i.e. the reversibility score of the error correction code.
[0017] Furthermore, step (3) is achieved through the following formula:
[0018]
[0019] Where s1 to s nThe score represents the difficulty of reversing each bit of the error-correcting code, where n is the specific number of bits in the error-correcting code, and s is the score representing the difficulty of reversing each bit. e S is a score representing the difficulty of reverse engineering all error correction codes as a whole, and S is the security assessment score of the firmware error correction code algorithm.
[0020] According to a second aspect of the embodiments of this application, a firmware out-of-band data storage mode security assessment device is provided, comprising:
[0021] Firmware data extraction module: Extracts all firmware data, removes all data except data bits and error correction codes, and converts the remaining data bits and error correction codes into feature vectors and labels, which are used as inputs to the random forest algorithm, respectively.
[0022] Random Forest Evaluation Module: The random forest algorithm is used to test the reversibility of each bit of the error-correcting code and the error-correcting code as a whole, and the corresponding prediction accuracy is obtained, which is the reversibility score of the corresponding error-correcting code.
[0023] Security assessment module: Calculates the security of firmware out-of-band data storage mode based on the error correction code reversibility score obtained from the random forest assessment module.
[0024] According to a third aspect of the embodiments of this application, an electronic device is provided, comprising:
[0025] One or more processors;
[0026] Memory, used to store one or more programs;
[0027] When the one or more programs are executed by the one or more processors, the one or more processors perform the method as described in the first aspect.
[0028] According to a fourth aspect of the embodiments of this application, a computer-readable storage medium is provided that stores computer instructions thereon, which, when executed by a processor, implement the steps of the method as described in the first aspect.
[0029] The technical solution of this invention can be summarized as follows:
[0030] 1. A method for extracting and processing firmware data. Extract all firmware data, remove redundant content, retain the correspondence between data bits and error correction codes, and save the data in a format that conforms to the requirements of the random forest algorithm;
[0031] 2. A method for evaluating the reversibility of error-correcting codes using random forests. This method can perform reversibility analysis on individual bits or the entire error-correcting code and score its difficulty.
[0032] 3. A method for ensuring the security of firmware out-of-band data storage mode. Based on the previously obtained score for the difficulty of reversing error correction codes, the security score of the firmware out-of-band data storage mode (firmware out-of-band data generation algorithm) is obtained by substituting it into the security assessment formula.
[0033] The technical solutions provided by the embodiments of this application may include the following beneficial effects:
[0034] As can be seen from the above embodiments, this application, by constructing a process for evaluating the security of firmware error correction code algorithms using random forests, can effectively confirm the reliability of the error correction code algorithms used during firmware development, promptly identify and fix potential errors, and improve the security and privacy protection of firmware data. This invention proposes for the first time a security evaluation method for firmware out-of-band data storage modes, filling a gap in this field. It also has advantages such as simple operation, strong versatility, and significant results. Using random forest algorithms for feature and label training and prediction is a common and widely applicable method that can be applied to different types of firmware out-of-band data generation algorithms. Furthermore, the operation steps of this method are simple and clear, requiring no complex technologies or equipment.
[0035] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0036] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0037] Figure 1 This is a flowchart illustrating a firmware out-of-band data storage mode security assessment method according to an exemplary embodiment.
[0038] Figure 2 This is a schematic diagram of a random forest decision tree model according to an exemplary embodiment.
[0039] Figure 3 This is a block diagram illustrating a firmware out-of-band data storage mode security evaluation apparatus according to an exemplary embodiment.
[0040] Figure 4 This is a schematic diagram of an electronic device according to an exemplary embodiment. Detailed Implementation
[0041] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application.
[0042] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0043] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."
[0044] Figure 1 This is a flowchart illustrating a firmware out-of-band data storage mode security assessment method according to an exemplary embodiment, such as... Figure 1 As shown, this method, when applied to a terminal, may include the following steps:
[0045] (1) Firmware data extraction: Extract all firmware data, remove data bits and out-of-band error correction codes, and convert the remaining data bits and out-of-band error correction codes into feature vectors and labels, which are used as inputs to the random forest algorithm; specifically, this includes the following sub-steps:
[0046] (1.1) Reading Firmware Data: Converting the firmware (binary file) into a processable file format, such as a text file. Data bits refer to the portion of the firmware containing the actual data, while out-of-band error correction (OOC) codes refer to the extra bits used to correct data errors. Typically, the storage of data bits and OOC codes follows a certain pattern, often exhibiting a cycle of data bits followed by OOC codes, then data bits again, and then OOC codes again, accompanied by specific character sequences or markers (e.g., storing multiple 0xFF bits before the OOC codes as markers). By identifying these markers, the specific location and number of bits of data bits and OOC codes in the current firmware data are determined, along with the number of data bits corresponding to the number of OOC code bits.
[0047] (1.2) Data Processing: After confirming the specific location and number of bits of the data bits and out-of-band error correction codes, extract all data bits and out-of-band error correction codes, and convert them to an appropriate format according to the requirements of the random forest algorithm used (e.g., random forest requires the Label data to have a dimension of 1; if the actual data does not meet this requirement, the data needs to be converted). During the extraction process, data other than data bits and error correction codes should be removed to avoid interference and confusion. Duplicate data and data that are not significant for the evaluation (such as data with all bits set to 0) should also be removed to reduce data redundancy and improve the efficiency and accuracy of the evaluation.
[0048] (1.3) Data storage: Random forest expects feature vectors and labels as input. This invention uses data bits as the feature vectors required for input to random forest, and out-of-band error correction codes as the labels required for input. The data converted in step (1.2) is stored according to the requirements of the dataset needed by the random forest algorithm, ensuring a one-to-one correspondence between data bits and out-of-band error correction codes.
[0049] By following the steps above, we obtain a dataset that contains only data bits and out-of-band error correction codes, does not contain duplicate or invalid data, and meets the input requirements of a random forest.
[0050] (2) Random Forest Evaluation: The random forest algorithm is used to test the reversibility of each bit of the out-of-band error correction code and the out-of-band error correction code as a whole, and the corresponding prediction accuracy is obtained, which is the reversibility score of the corresponding error correction code; the specific steps include the following:
[0051] (2.1) Random Forest Construction: Random forest is a machine learning algorithm commonly used in regression and classification problems. It makes predictions and classifications by constructing multiple decision trees and then integrating the results of these decision trees to obtain more accurate results. The construction of a decision tree consists of two parts: samples and features. For firmware data, a part of the data samples are randomly selected with replacement, and a decision tree is trained using this part of the samples; during the process of constructing a decision tree, only a part of the features of the entire firmware data are used. The following is the construction process of a decision tree: First, randomly select a part of the data samples with replacement in the firmware data (a pair of matching data bits and out-of-band error correction codes is a data sample), and use this part of the selected samples as the data samples at the root node of the decision tree. Second, each data sample has M data features. When each node of the decision tree needs to be split, randomly select m features from these M data features, where m << M. Then, use a certain strategy (such as information gain) to select 1 attribute from these m features as the splitting attribute of this node, forming a new node. Finally, continuously repeat the above step in the new node, and continuously split the existing large nodes into small nodes according to the splitting strategy until the newly generated nodes cannot be split according to the splitting strategy. In this way, a decision tree is constructed. It should be noted that there is no pruning in the formation process of the entire decision tree. Continuously select different data samples according to the above method, construct a large number of new decision trees, and thus form a random forest. Each decision tree will have a voting result, and the category with the most votes in the final voting result is the final prediction result of the random forest.
[0052] A decision tree is a tree structure composed of nodes (including internal nodes and leaf nodes) and directed edges. A decision tree can be regarded as a set of if-then rules. According to the rules, the conditions are judged in turn, and finally, it belongs to a specific category according to the path.
[0053] The model is a classification and regression tree (CART) model. This model assumes that the decision tree is a binary tree, and the values of the internal node features are "yes" and "no", which is equivalent to recursively dichotomizing each feature. The CART algorithm consists of two steps: decision tree generation and decision tree pruning.
[0054] Decision tree generation is a process of recursively constructing a binary tree. The minimum squared error criterion is used for regression trees, and the minimum Gini index criterion is used for classification trees to perform feature selection and generate a binary tree. The Gini index represents the uncertainty of a set under a specific feature. The larger the Gini index value, the greater the uncertainty of the sample.
[0055] This invention uses the random forest classification algorithm. The following is a brief introduction to the generation of the random forest classification tree in the CART algorithm: Based on the firmware data, starting from the root node, the following operations are recursively performed on each node to construct a binary decision tree. (1) Let the firmware data of the node be D, and calculate the Gini index of the existing features for the dataset. For each data feature A, for each possible value a, according to the test of the sample point for A=a as "yes" or "no", D is divided into two parts, D1 and D2, and the Gini index when A=a is calculated; (2) Among all possible features A and all their possible split points a, the feature with the smallest Gini index and its corresponding split point are selected as the optimal feature and the optimal split point. Based on the optimal feature and the optimal split point, two child nodes are generated from the current node, and the firmware data is assigned to the two child nodes according to the features; (3) Recursively call (1) and (2) on the two child nodes until the stopping condition is met.
[0056] (2.2) Data evaluation: The firmware data (including data bits and corresponding out-of-band error correction codes) obtained in step (1) is divided into training set and test set. The random forest model obtained in step (2.1) is trained using the firmware data. While obtaining prediction results using the test set, the model parameters of the random forest in (2.1) are adjusted. Under the settings of using one bit of the error correction code as the label and using the entire error correction code as the label, the adjusted model is used to predict the test set. The prediction results of each bit of the error correction code and the error correction code as a whole are obtained respectively, and the prediction accuracy of each is calculated, that is, the reversibility score of the error correction code.
[0057] Specifically, the data bits are used as the feature vector input to the random forest algorithm, and the error correction code is used as the label input to the random forest algorithm. The dataset obtained in step (1) is divided into a training set and a test set. The random forest model is trained using the training set, and the parameters are adjusted while obtaining prediction results using the test set to improve the accuracy of the random forest model. After obtaining a random forest model with good performance, the model is used to predict the test set under the settings of using one bit of the error correction code as the label and using the entire error correction code as the label, respectively. The prediction results of each bit of the error correction code and the error correction code as a whole are obtained respectively, and the prediction accuracy of each is calculated, that is, the reversibility score of the error correction code.
[0058] In this embodiment, CART pruning is used for random forest training. The training set is used to prune the generated trees and select the optimal subtree. The loss function is used as the pruning criterion. The specific operation of the CART pruning algorithm is as follows:
[0059] 1. Given the training set, the original decision tree and tree nodes, and the out-of-band error correction code data of the firmware corresponding to the nodes;
[0060] 2. Calculate the error of subtrees rooted at different nodes on the training set formed by firmware data from bottom to top;
[0061] 3. Use the loss function to prune the nodes and determine their categories by majority voting to obtain new subtrees;
[0062] 4. If the new subtree is not a tree consisting of a root node and two nodes, repeat steps 2 and 3 of the algorithm;
[0063] 5. Use cross-validation to select the optimal subtree from the subtree sequence as the optimal output tree.
[0064] It should be noted that the CART pruning algorithm is a standard technique in this field and will not be elaborated upon here.
[0065] In implementing the random forest algorithm, you can choose to call existing random forest libraries, such as scikit-learn, or you can write your own algorithm. This invention implements the algorithm by calling the scikit-learn library.
[0066] The efficiency and accuracy of the random forest model can be improved by adjusting parameters, including the number of decision trees, the maximum depth of each tree, and the randomness of feature selection.
[0067] (3) Security Assessment: Based on the error correction code reversibility score obtained in step (2), the security of the firmware out-of-band data storage mode is calculated. The specific security assessment calculation formula is as follows:
[0068]
[0069] Where s1 to s n The accuracy result of reversing each bit of the error-correcting code corresponds to a score indicating the difficulty of reversing that bit, where n is the specific number of bits in the error-correcting code, and s... e S represents the difficulty of reverse engineering all error correction codes as a whole, and is the security assessment score of the firmware error correction code algorithm. In practice, the parameters of the evaluation formula (default parameters are 0.4 and 0.6) can be adjusted according to factors such as the number of bits in the error correction code.
[0070] The security assessment score ranges from 0 to 1. The higher the score, the easier it is for the firmware error correction code to be reverse engineered, and the lower the security.
[0071] Corresponding to the aforementioned embodiments of the firmware out-of-band data storage mode security assessment method, this application also provides embodiments of the firmware out-of-band data storage mode security assessment apparatus.
[0072] Figure 2This is a block diagram illustrating a firmware out-of-band data storage mode security evaluation apparatus according to an exemplary embodiment. (Refer to...) Figure 2 The device may include:
[0073] Firmware data extraction module 21: Extracts all firmware data, removes data except for data bits and error correction codes, and converts the remaining data bits and error correction codes into feature vectors and labels that are used as inputs to the random forest algorithm;
[0074] Random Forest Evaluation Module 22: The random forest algorithm is used to test the reversibility of each bit of the error-correcting code and the error-correcting code as a whole, and the corresponding prediction accuracy is obtained, which is the reversibility score of the corresponding error-correcting code.
[0075] Security assessment module 23: Calculates the security of firmware out-of-band data storage mode based on the error correction code reversibility score obtained from the random forest assessment module.
[0076] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0077] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this application according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0078] Accordingly, this application also provides an electronic device, including: one or more processors; a memory for storing one or more programs; and when the one or more programs are executed by the one or more processors, causing the one or more processors to implement the firmware out-of-band data storage mode security assessment method as described above. Figure 4 The diagram shown is a hardware structure diagram of any device with data processing capabilities, used in an embodiment of the firmware out-of-band data storage mode security assessment method provided by the present invention. (Except for...) Figure 4 In addition to the processor, memory, and network interface shown, any data processing device in the embodiment may also include other hardware depending on the actual function of the data processing device, which will not be described in detail here.
[0079] Accordingly, this application also provides a computer-readable storage medium storing computer instructions thereon, which, when executed by a processor, implement the firmware out-of-band data storage mode security assessment method described above. The computer-readable storage medium can be an internal storage unit of any data-processing device as described in any of the foregoing embodiments, such as a hard disk or memory. The computer-readable storage medium can also be an external storage device, such as a plug-in hard disk, smart media card (SMC), SD card, flash card, etc., equipped on the device. Furthermore, the computer-readable storage medium can include both internal storage units of any data-processing device and external storage devices. The computer-readable storage medium is used to store the computer program and other programs and data required by the data-processing device, and can also be used to temporarily store data that has been output or will be output.
[0080] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the disclosure herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein.
[0081] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope.
Claims
1. A method for security assessment of firmware out-of-band data storage mode, characterized in that, include: (1) Firmware data extraction: Extract all firmware data, remove data bits and out-of-band error correction codes, and convert the remaining data bits and out-of-band error correction codes into feature vectors and labels as inputs to the random forest algorithm, respectively. (2) Random forest evaluation: The random forest algorithm is used to test the reversibility of each bit of the error correction code and the error correction code as a whole, and the corresponding prediction accuracy is obtained, which is the reversibility score of the corresponding error correction code. (3) Security assessment: Based on the error correction code reversibility score obtained in step (2), calculate the security of the firmware out-of-band data storage mode; Step (2) specifically includes: (2.1) Random forest construction: Based on the data bits and error correction code, the CART algorithm is used to generate a random forest classification tree, and the CART pruning algorithm is used to prune and select the optimal subtree; (2.2) Data evaluation: Divide the data bits and corresponding error correction codes obtained in step (1) into training set and test set. Use the training set to train the random forest model obtained in step (2.1). While using the test set to obtain prediction results, adjust the parameters. Under the settings of using one bit of the error correction code as the label and using the entire error correction code as the label, use the adjusted model to predict the test set. Obtain the prediction results of each bit of the error correction code and the error correction code as a whole, and calculate the prediction accuracy of each bit, i.e. the reversibility score of the error correction code. Step (3) is achieved through the following formula: , in s 1 to s n Score the difficulty of reversing each bit of the error correction code. n The specific number of bits in the error correction code. s e Score the difficulty of reverse engineering all error-correcting codes as a whole. S This is the security assessment score for the firmware error correction code algorithm.
2. The method according to claim 1, characterized in that, Step (1) specifically includes: (1.1) Convert the firmware binary file into a processable file format and obtain the position, number of bits and corresponding relationships of the data bits and out-of-band error correction codes; (1.2) Based on the position, number of bits and correspondence of the data bits and out-of-band error correction codes, extract the data bits and out-of-band error correction codes and convert them into feature vectors and labels as inputs to the random forest algorithm.
3. The method according to claim 2, characterized in that, In step (1.2), duplicate data bits are removed when extracting data bits and error correction codes.
4. An apparatus for a firmware out-of-band data storage mode security assessment method as described in claim 1, characterized in that, include: Firmware data extraction module: Extracts all firmware data, removes all data except data bits and error correction codes, and converts the remaining data bits and error correction codes into feature vectors and labels, which are used as inputs to the random forest algorithm, respectively. Random Forest Evaluation Module: The random forest algorithm is used to test the reversibility of each bit of the error-correcting code and the error-correcting code as a whole, and the corresponding prediction accuracy is obtained, which is the reversibility score of the corresponding error-correcting code. Security assessment module: Calculates the security of firmware out-of-band data storage mode based on the error correction code reversibility score obtained from the random forest assessment module.
5. An electronic device, characterized in that, include: One or more processors; Memory, used to store one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-3.
6. A computer-readable storage medium storing computer instructions thereon, characterized in that, When executed by the processor, this instruction implements the steps of the method as described in any one of claims 1-3.