Internet of Things firmware fuzzy test seed generation method and device facing security function
By generating intent files and utilizing large language model variant initial seed sets, combined with similarity evaluation algorithm, the problem of difficulty in effectively mining the vulnerability of the firmware security function function of IoT devices in the existing technology is solved, and a higher fuzzy test seed coverage rate is achieved and vulnerability discovery efficiency.
Patent Information
- Application Number
- CN202411572622.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-02-18
AI Technical Summary
In the firmware fuzz testing based on coverage boot strategy, it is difficult for existing fuzz testing tools to effectively explore the vulnerabilities of the firmware security function functions of IoT devices, especially because the security function functions of the firmware are sparse.
By generating intent files, including operation types, key security information types, test variables and test variable assignments, parsing intent files line by line to match the security function code template, generating initial seed collections, and using large language models for mutation updates to generate new seeds to generate new seeds gather. At the same time, a similarity evaluation algorithm is introduced to ensure the diversity of new seed sets.
It improves the coverage of IoT firmware fuzzy testing seeds, effectively explores vulnerabilities in security function functions, and avoids incomplete tests caused by the sparseness of firmware security function functions.
Smart Images

Figure CN119473895A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Internet of Things, and in particular to a method and device for generating security-oriented Internet of Things firmware fuzzy test seeds. Background Art
[0002] This section is intended to provide a background or context to the embodiments of the invention recited in the claims. No admission is made that the description herein is prior art by inclusion in this section.
[0003] Firmware is the core software running in IoT devices, which is responsible for managing and controlling hardware operations. Firmware security functions are key security features provided by software in embedded systems, which may include secure boot, firmware encryption, secure update mechanisms, debug interface locking, and secure storage and processing of sensitive information. These security features are used to protect devices and data from unauthorized access, tampering, or destruction, and their effectiveness may depend on external factors, such as hardware security features, operating system security policies, network environment, etc.
[0004] In order to evaluate the security of IoT devices, it is necessary to conduct penetration testing on the firmware to ensure that its security functions are correctly implemented and there are no security vulnerabilities. Fuzz testing is a widely used vulnerability mining technology that discovers potential security vulnerabilities by generating unexpected inputs (i.e. seeds) and monitoring the abnormal responses of the target program.
[0005] Existing fuzz testing tools usually use coverage-guided strategies to identify security vulnerabilities in software. The core mechanism is to record the code coverage of the input seed and continuously optimize the seed to improve the coverage, thereby increasing the possibility of discovering vulnerabilities. However, the security function of the firmware is sparse, which means that in firmware fuzz testing based on coverage-guided strategies, even if the seed has a high code coverage, some key security functions may be missed, and the vulnerabilities of the security function functions cannot be effectively discovered. Summary of the invention
[0006] The embodiment of the present invention provides a method for generating fuzzy test seeds for IoT firmware for security functions, which can further improve the coverage of fuzzy test seeds for IoT firmware, thereby effectively mining vulnerabilities of security function functions. The method includes:
[0007] Generate an intent file based on the IoT firmware security function test purpose. The intent file includes operation type, key security information type, test variables, and test variable assignments.
[0008] Parse the intent file line by line, match the security function code template according to the operation type and key security information type in the parsing result, assemble the matched security function code template, and obtain the security function call code template; the security function call code template creates a security function call vector for each line of the intent file, which is used to record the call information, used variable information and code inspection information in the fuzz test;
[0009] According to the test variables in the parsing results, write the test variable assignments in the parsing results into the security function calling code template to obtain an initial seed set;
[0010] Using a prompt word template, generating a fuzzy test seed generation command set with prompt words according to an initial seed set, inputting the fuzzy test seed generation command set into a large language model, guiding the large language model to mutate the initial seed set, and outputting a new seed set; the prompt word template includes pre-designed prompt words;
[0011] The similarity between the new seed set and the initial seed set is calculated. If the similarity meets the preset conditions, the new seeds in the new seed set are used as fuzzy test seeds.
[0012] The embodiment of the present invention also provides a device for generating fuzzy test seeds for IoT firmware for security functions, which is used to further improve the coverage of fuzzy test seeds for IoT firmware, thereby effectively mining vulnerabilities of security function functions. The device includes:
[0013] The intent file generation module is used to generate an intent file according to the IoT firmware security function test purpose. The intent file includes operation type, key security information type, test variables, and test variable assignments;
[0014] The intent file parsing module is used to parse the intent file line by line, match the security function code template according to the operation type and key security information type in the parsing result, assemble the matched security function code template, and obtain the security function call code template; the security function call code template creates a security function call vector for each line of the intent file, which is used to record the call information, used variable information and code check information in the fuzz test;
[0015] An initial seed generation module is used to write the test variable assignment in the parsing result into the security function call code template according to the test variable in the parsing result to obtain an initial seed set;
[0016] A new seed generation module is used to use a prompt word template to generate a fuzzy test seed generation command set with prompt words according to an initial seed set, input the fuzzy test seed generation command set into a large language model, guide the large language model to mutate the initial seed set, and output a new seed set; the prompt word template includes pre-designed prompt words;
[0017] The similarity evaluation module is used to calculate the similarity between the new seed set and the initial seed set. If the similarity meets the preset conditions, the new seeds in the new seed set are used as fuzzy test seeds.
[0018] An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned security-oriented IoT firmware fuzz test seed generation method when executing the computer program.
[0019] An embodiment of the present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the method for generating fuzzy test seeds for IoT firmware oriented to security functions is implemented.
[0020] An embodiment of the present invention also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the above-mentioned security-oriented IoT firmware fuzz test seed generation method.
[0021] Compared with the technical solution of using coverage-guided strategy to identify security vulnerabilities in software in the prior art, in the embodiment of the present invention, according to the purpose of IoT firmware security function testing, a preset security function code template is used to generate an initial seed set that meets the test purpose, and the powerful semantic understanding and reasoning capabilities of a large language model are used to mutate and update the initial seed set, and batch generate new seeds that meet the test purpose. Then, a feedback mechanism based on a similarity evaluation algorithm is introduced to promptly discover whether there is a code tight coupling problem in the new seed (i.e., generated test code) set, which can further improve the coverage of IoT firmware fuzzy test seeds, avoid incomplete testing due to the sparsity of firmware security function functions, and effectively explore the vulnerabilities of security function functions. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0023] Figure 1 It is a processing flow chart of a method for generating security function-oriented IoT firmware fuzzy test seeds in an embodiment of the present invention;
[0024] Figure 2 A schematic diagram of an example of the content format of an intent file in an embodiment of the present invention;
[0025] Figure 3 A flowchart of generating an initial seed set in an embodiment of the present invention;
[0026] Figure 4 A schematic diagram of a tree structure for maintaining a security function code template in an embodiment of the present invention;
[0027] Figure 5 is a flow chart of a similarity evaluation algorithm in an embodiment of the present invention;
[0028] Figure 6 It is a schematic diagram of the overall framework of the method for generating security function-oriented IoT firmware fuzz testing seeds in an embodiment of the present invention;
[0029] Figure 7 Schematic diagram of a device for generating fuzzy test seeds for security functions of IoT firmware in an embodiment of the present invention. DETAILED DESCRIPTION
[0030] To make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0031] First, the relevant technical terms in the embodiments of the present invention are introduced:
[0032] Large Language Model (LLM): A complex machine learning model with billions to hundreds of billions of parameters, usually built with deep neural networks, and showing strong capabilities in semantic understanding and code generation. Large language models are pre-trained on large-scale datasets, learn rich language knowledge and programming patterns, understand complex contextual information, and generate coherent, logical, and high-quality code.
[0033] Prompt: The initial text input provided to the large language model to guide the large language model to generate a specific type of response or complete a task.
[0034] Prompt word engineering: In Natural Language Processing (NLP), the technology of improving the performance of models on various tasks (such as text generation, translation, programming, and conversation) by designing and optimizing prompt words. The core of prompt word engineering is to understand the capabilities and limitations of the model and stimulate the potential of the model through carefully designed prompt words, which includes providing clear task instructions, relevant context, example references, human input, and specific output requirements. In actual code generation scenarios, prompt word engineering can help developers and researchers interact with large language models more effectively and improve the usability and practicality of the model. By continuously experimenting and optimizing prompt words, the optimal output of the model can be discovered.
[0035] Tight coupling problem: Traditional machine learning algorithms (such as Markov chain models, convolutional neural network models, etc.) learn the semantic information of input data and generate seeds. The test code in the generated seeds is prone to tight coupling problems. That is, the generated seeds are too similar to the reference semantic information, resulting in a large number of highly repeated seeds (test cases).
[0036] As mentioned above, in the firmware security function test, the firmware security function is sparse, that is, the code related to the security function may not be executed continuously, or some security function functions may only be called under certain conditions. Most of the current fuzz testing methods use coverage guidance strategies. Even if the generated seed (i.e., test case) has a high code coverage rate, this seed may not have the conditions to execute the security function, so it is impossible to effectively discover the vulnerabilities of the security function.
[0037] To solve the above problems, an embodiment of the present invention provides a method for generating IoT firmware fuzzy test seeds for security functions, which can further improve the coverage of IoT firmware fuzzy test seeds, thereby effectively mining vulnerabilities of security function functions. Figure 1 FIG. 1 is a processing flow chart of a method for generating a security-oriented IoT firmware fuzz test seed according to an embodiment of the present invention. Figure 1 As shown, the method includes:
[0038] Step 101: Generate an intent file according to the IoT firmware security function test purpose, where the intent file includes an operation type, a key security information type, a test variable, and a test variable assignment;
[0039] Step 102, parsing the intent file line by line, matching the security function code template according to the operation type and key security information type in the parsing result, assembling the matched security function code template, and obtaining the security function call code template; the security function call code template creates a security function call vector for each line of the intent file, which is used to record the call information, used variable information and code check information in the fuzz test;
[0040] Step 103: According to the test variables in the parsing result, write the test variable assignments in the parsing result into the security function calling code template to obtain an initial seed set;
[0041] Step 104: using the prompt word template, according to the initial seed set, generating a fuzzy test seed generation command set with prompt words, inputting the fuzzy test seed generation command set into the large language model, guiding the large language model to mutate the initial seed set, and outputting a new seed set; the prompt word template includes pre-designed prompt words;
[0042] Step 105: Calculate the similarity between the new seed set and the initial seed set. If the similarity meets a preset condition, use the new seeds in the new seed set as fuzzy test seeds.
[0043] When conducting IoT firmware security assessments based on security standards, accurately capturing the purpose of the test can improve the efficiency of the security assessment, because security standards often list specific security function requirements, and the test objectives of the tester will directly reflect these security function requirements, so that the generated fuzz test code can be developed around the security functions required by the security standards. In the existing fuzz testing methods that use coverage-guided strategies, the initial seed is usually generated randomly; compared to the existing methods, the inventors proposed an intent file template that contains information in four dimensions: operation type, key security information type, test variables, and test variable assignments. The use of the intent file template can clearly capture the purpose of the test, so that high-quality initial seeds can be generated based on the test purpose in the future.
[0044] In an embodiment of the present invention, an intent file is generated according to the purpose of the IoT firmware security function test, and the intent file includes an operation type, a key security information type, a test variable, and a test variable assignment. Figure 2 The following is an example diagram of the content format of an intent file in an embodiment of the present invention.
[0045] For example, according to the tester's needs to complete the IoT firmware security function test purpose, after writing the test intent according to the four dimensions of operation type, key security information type, test variable, and test variable assignment specified in the intent file template, an intent file is generated, such as Figure 2 As shown in the figure, the operation type and key safety information type are used to describe the safety function.
[0046] In order to quickly generate an initial seed that meets the test purpose based on the intent file, security function code templates corresponding to different operation types under different key security information types are pre-set. By assembling the code templates according to the parsing results of the intent file, the code template used to generate the initial seed can be obtained. Figure 3 FIG. 1 is a flow chart of generating an initial seed set in an embodiment of the present invention. Figure 3 As shown, the steps to generate the initial seed set are as follows:
[0047] Step 301, parsing the intent file line by line to obtain parsing results;
[0048] Step 302: Use the parsing result and the key security information template to match the security function code template, assemble the matched security function code template, and obtain the security function call code template;
[0049] Step 303: Use the parsing result and the security function call code template to generate an initial seed set.
[0050] In an embodiment of the present invention, the intent file is parsed line by line, and the security function code template is matched according to the operation type and the key security information type in the parsing result, and the matched security function code template is assembled to obtain a security function call code template; the security function call code template creates a security function call vector for each line of the intent file, which is used to record the call information, used variable information and code check information in the fuzz test. Figure 3 Step 301 and step 302 shown can be implemented by this embodiment.
[0051] In one embodiment, an intent file row template is used to parse the intent file line by line; a key safety information template is used to match the security function code template according to the operation type and the key safety information type in the parsing result; the matched security function code template is assembled to obtain a security function call code template; wherein the intent file row template describes the basic information of each line of the intent file; and the key safety information template contains a mapping relationship between the key safety information type and the security function code template.
[0052] In one embodiment, the safety function code template is maintained through a tree structure; the tree structure takes the template line information as the root node, the intent file line template and the key safety information template are the successor nodes of the root node, and the safety function code template is the successor node of the key safety information template.
[0053] In the embodiment of the present invention, according to the test variables in the parsing result, the test variable assignment in the parsing result is written into the security function call code template to obtain the initial seed set. Figure 3 The step 303 shown can be implemented by this embodiment.
[0054] For example, use the intent file line template to parse the intent file line by line, and then use the intent file line template to fill in specific information such as operation type, key safety information type, test variables, and test variable assignment (i.e., parsing results). Match the security function code template corresponding to the intent file line information through the key safety information template, assemble the matched security function code template to obtain the security function call code template, and then write the test variable assignment in the parsing result into the security function call code template to obtain the initial seed. By traversing the intent file line information, the initial seed set is automatically generated. Among them, the security function code template provides a basic code snippet for the initial seed generation.
[0055] In order to improve the maintainability of each safety function code template, the template line information is set, and then the template line information, the intent file line template, the key safety information template, and each safety function code template are constructed into a tree structure. Figure 4 It is a schematic diagram of a tree structure for maintaining a security function code template in an embodiment of the present invention.
[0056] For example, in a key security information template, the key security information types may include secure storage (files), keys, and security policies. Figure 4 The tree structure shown specifically includes: the template row information is the root node; the intent file row template and the key security information template are the successor nodes of the root node; the secure storage template, the key template, and the policy template are the three successor nodes of the key security information template; the successor nodes of the secure storage template include creating a storage call template, reading a storage call template, and writing a storage call template, and the successor nodes of the key template include creating a key template, reading a key template, and deleting a key template; the successor nodes of the security policy template include creating a policy template, reading a policy template, and deleting a policy template.
[0057] For example, the security function call code template will create a security function call vector for each line of the intent file. During fuzz testing, the security function call information, the used variable information, and the code check information will be recorded in the corresponding security function call vector to track the call process.
[0058] In order to generate diversified fuzz test seeds and effectively explore the vulnerabilities of security function functions, the embodiments of the present invention utilize the powerful semantic understanding and reasoning ability of large language models, and generate new seeds that meet the test purpose in batches based on the initial seed set. In addition, through the prompt word engineering, the large language model can better understand the task of how to mutate the initial seed set. It is not necessary to update the weights of the large language model, but through the adjustment of external input, it is possible to achieve batch generation of high-quality new seeds that meet the test purpose. In order to ensure that the prompt words can stimulate the potential of the large language model, the prompt word template is designed in advance through experiments. Using the pre-designed prompt word template, the fuzzy test seed generation command can be automatically generated.
[0059] In an embodiment of the present invention, a prompt word template is used to generate a fuzzy test seed generation command set with prompt words according to an initial seed set, and the fuzzy test seed generation command set is input into a large language model to guide the large language model to mutate the initial seed set and output a new seed set; the prompt word template includes pre-designed prompt words.
[0060] In one embodiment, the prompt word template includes test purpose, test context, format, and optimization prompt; using the prompt word template, the initial seed in the initial seed set is used as an example to generate a fuzzy test seed generation command set with test purpose, test context, example, format, and optimization prompt. In this embodiment, the fuzzy test seed generation command with prompt words such as test purpose, test context, example, format, and optimization prompt is generated.
[0061] The following examples describe each prompt word in detail:
[0062] For example, the test objectives may include different types of security function tests: internal storage, protected storage, symmetric encryption and asymmetric encryption, remote authentication, etc.
[0063] For example, the test context provides descriptions of the test code background, security function requirements, etc., helping large language models generate more accurate test code;
[0064] For example, using the initial fuzz testing seed code as an example, a large language model is guided to learn its code style and security function semantics;
[0065] For example, the format mainly describes information such as programming language style, class structure or module division;
[0066] For example, optimization hints mainly describe information related to code mutation and generation, which is used to stimulate large language models to explore and generate updated fuzz test seeds.
[0067] According to the above description, it can be seen that by using a large language model to mutate the initial seed set, new seeds that meet the test purpose can be generated in batches. However, there may still be a tight coupling problem that is easy to occur in traditional machine learning between the test code of the initial seed and the test code of the mutated new seed. In this regard, the embodiment of the present invention introduces a feedback mechanism based on a similarity evaluation algorithm, which can effectively discover the tight coupling problem in the test code of the generated seed.
[0068] In the embodiment of the present invention, the similarity between the new seed set and the initial seed set is calculated, and if the similarity meets a preset condition, the new seeds in the new seed set are used as fuzzy test seeds.
[0069] In one embodiment, the variables and constants in the new seed set and the initial seed set are defined as nodes, and the operators and assignment relationships in the new seed set and the initial seed set are defined as edges of the nodes, so as to obtain the edge set and edge point set of the new seed, as well as the edge set and edge point set of the initial seed; the similarity between the edge set of the new seed and the edge set of the initial seed is calculated using the Jaccard similarity algorithm to obtain the edge similarity; the similarity between the edge point set of the new seed and the edge point set of the initial seed is calculated using the Jaccard similarity algorithm to obtain the edge point similarity; if the edge similarity is greater than the preset edge similarity, or the edge similarity is less than the preset edge similarity but the edge point similarity is greater than the preset edge point similarity, the new seed set is discarded; otherwise, the new seeds in the new seed set are used as fuzzy test seeds.
[0070] Figure 5 is a flow chart of the similarity evaluation algorithm in an embodiment of the present invention. For example, after a large language model mutates the initial seed set, Figure 5 As shown in Figure 1, read the new seed set output by the large language model. In the output new seed set, variables and constants are defined as nodes, and operators and assignment relationships are defined as edges connecting these nodes. All edges in the new seed set constitute the edge set E of the new seed set. S1 , all nodes and edges in the new seed set constitute the edge point set N of the new seed set S1 , E S1 and N S1 Together, we construct the code semantic structure S1. Similarly, the edge set of the initial seed set is E S2 , the edge point set is N S2 , using the initial seed set to construct a similar reference semantic structure S2. Then, Figure 5 In the calculation of the similarity between the new seed set and the initial seed set, the Jaccard similarity algorithm is used in this embodiment to evaluate whether the current large model generation code has a tight coupling problem. Sim E (S1,S2) is the edge similarity between S1 and S2, SimN (S1, S2) is the edge similarity between S1 and S2, and the calculation formula is as follows:
[0071]
[0072] like Figure 5 As shown, when the similarity S between S1 and S2 E (S1, S2) is greater than the preset edge similarity θ E When, or when S E (S1, S2) similarity is less than θ E But the similarity S between the edges of S1 and S2 N (S1, S2) is greater than the preset edge point similarity θ N When the generated new seed set is judged to be too similar to the initial seed set, the new seed set is discarded; otherwise, the new seeds in the new seed set are used as fuzzy test seeds and added to the new seed library. Through this feedback mechanism, the tight coupling problem of machine learning algorithms can be effectively discovered.
[0073] Figure 6 Schematic diagram of the overall framework of the method for generating security-oriented IoT firmware fuzz testing seeds in an embodiment of the present invention. Figure 6 The overall framework of the IoT firmware fuzz test seed generation method for security functions in the above embodiment is shown, including: in the test purpose input 100 link, receiving the test purpose input by the tester; generating the intent file 100a according to the received test purpose; in the initial seed generation 300 link, generating the initial seed set according to the intent file 101 and the security function code template 200, and the implementation method of the initial seed generation 300 link can be referred to Figure 3 ; The initial seed set is combined with the prompt word template 400 to obtain a seed generation command, which guides the large language model mutation initial seed 500 link; the new seed set output by the large language model mutation initial seed 500 link is input into the similarity evaluation 600 link. The implementation method of the similarity evaluation 600 link can be referred to Figure 5 Based on the evaluation results, feedback is given to the tester, initial seed generation 300 is performed, or the new seed set is added to the new seed library for fuzz testing.
[0074] To sum up: the IoT firmware fuzz test seed generation method for security functions in the embodiment of the present invention captures the IoT firmware security function test purpose through the intent file template, and then uses the preset security function code template to generate an initial seed set that meets the test purpose, and uses the powerful semantic understanding and reasoning capabilities of the large language model to mutate and update the initial seed set, batch generate new seeds that meet the test purpose, and then introduces a feedback mechanism based on the similarity evaluation algorithm to promptly discover whether there is a code tight coupling problem in the new seed (i.e., the generated test code) set, which can further improve the coverage of the IoT firmware fuzz test seeds, thereby effectively mining the vulnerabilities of security function functions.
[0075] The embodiment of the present invention also provides a device for generating seeds for fuzzy testing of IoT firmware for security functions, as described in the following embodiments. Since the principle of solving the problem by the device is similar to the method for generating seeds for fuzzy testing of IoT firmware for security functions, the implementation of the device can refer to the implementation of the method for generating seeds for fuzzy testing of IoT firmware for security functions, and the repeated parts will not be repeated.
[0076] Figure 7 FIG. 1 is a schematic diagram of a face recognition system anti-pseudo-presentation attack testing device according to an embodiment of the present invention. Figure 7 As shown, the device comprises:
[0077] The intent file generation module 701 is used to generate an intent file according to the IoT firmware security function test purpose, and the intent file includes an operation type, a key security information type, a test variable, and a test variable assignment;
[0078] The intent file parsing module 702 is used to parse the intent file line by line, match the security function code template according to the operation type and key security information type in the parsing result, assemble the matched security function code template, and obtain the security function call code template; the security function call code template creates a security function call vector for each line of the intent file, which is used to record the call information, used variable information and code check information in the fuzz test;
[0079] An initial seed generation module 703 is used to write the test variable assignment in the parsing result into the security function call code template according to the test variable in the parsing result to obtain an initial seed set;
[0080] A new seed generation module 704 is used to generate a fuzzy test seed generation command set with prompt words according to an initial seed set using a prompt word template, input the fuzzy test seed generation command set into a large language model, guide the large language model to mutate the initial seed set, and output a new seed set; the prompt word template includes pre-designed prompt words;
[0081] The similarity evaluation module 705 is used to calculate the similarity between the new seed set and the initial seed set. If the similarity meets the preset conditions, the new seeds in the new seed set are used as fuzzy test seeds.
[0082] In one embodiment, the intent file parsing module 702 is specifically used to:
[0083] Use the intent file line template to parse the intent file line by line; use the key safety information template to match the safety function code template according to the operation type and key safety information type in the parsing result; assemble the matched safety function code template to obtain the safety function call code template;
[0084] Among them, the intent file line template describes the basic information of each line of the intent file; the key safety information template contains the mapping relationship between the key safety information type and the safety function code template.
[0085] In one embodiment, the security function code template in the intent file parsing module 702 is maintained through a tree structure; the tree structure takes the template row information as the root node, the intent file row template and the key safety information template are the successor nodes of the root node, and the security function code template is the successor node of the key safety information template.
[0086] In one embodiment, the prompt word template includes test purpose, test context, format, and optimization prompts;
[0087] The new seed generation module 704 is specifically used for:
[0088] Using the prompt word template, the initial seed in the initial seed set is used as an example to generate a fuzz test seed generation command set with test purpose, test context, example, format, and optimization prompts.
[0089] In one embodiment, the similarity evaluation module 705 is specifically used for:
[0090] The variables and constants in the new seed set and the initial seed set are defined as nodes, and the operators and assignment relations in the new seed set and the initial seed set are defined as edges of the nodes, so as to obtain the edge set and edge point set of the new seed, and the edge set and edge point set of the initial seed;
[0091] Using the Jaccard similarity algorithm, the similarity between the edge set of the new seed and the edge set of the initial seed is calculated to obtain the edge similarity;
[0092] Using the Jaccard similarity algorithm, the similarity between the edge point set of the new seed and the edge point set of the initial seed is calculated to obtain the edge point similarity;
[0093] If the edge similarity is greater than the preset edge similarity, or the edge similarity is less than the preset edge similarity but the edge point similarity is greater than the preset edge point similarity, the new seed set is discarded; otherwise, the new seeds in the new seed set are used as fuzzy test seeds.
[0094] An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned security-oriented IoT firmware fuzz test seed generation method when executing the computer program.
[0095] An embodiment of the present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the method for generating fuzzy test seeds for IoT firmware oriented to security functions is implemented.
[0096] An embodiment of the present invention also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the above-mentioned security-oriented IoT firmware fuzz test seed generation method.
[0097] Compared with the technical solution of the prior art that adopts the coverage guidance strategy to identify security vulnerabilities in software, the embodiment of the present invention captures the purpose of the IoT firmware security function test through the intent file template, and then uses the preset security function code template to generate an initial seed set that meets the test purpose, and utilizes the powerful semantic understanding and reasoning capabilities of the large language model to mutate and update the initial seed set, batch generate new seeds that meet the test purpose, and then introduces a feedback mechanism based on the similarity evaluation algorithm to timely discover whether there is a code tight coupling problem in the new seed (i.e., the generated test code) set, which can further improve the coverage of the IoT firmware fuzzy test seeds, thereby effectively mining the vulnerabilities of the security function function.
[0098] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0099] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0100] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0101] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0102] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for generating security-oriented IoT firmware fuzz testing seeds, characterized in that: include: Generate an intent file based on the IoT firmware security function test purpose. The intent file includes operation type, key security information type, test variables, and test variable assignments. Parse the intent file line by line, match the security function code template according to the operation type and key security information type in the parsing result, assemble the matched security function code template, and obtain the security function call code template; The security function call code template creates a security function call vector for each line of the intent file, which is used to record the call information, used variable information, and code inspection information in the fuzz test; According to the test variables in the parsing results, write the test variable assignments in the parsing results into the security function calling code template to obtain an initial seed set; Using a prompt word template, generating a fuzzy test seed generation command set with prompt words according to an initial seed set, inputting the fuzzy test seed generation command set into a large language model, guiding the large language model to mutate the initial seed set, and outputting a new seed set; the prompt word template includes pre-designed prompt words; The similarity between the new seed set and the initial seed set is calculated. If the similarity meets the preset conditions, the new seeds in the new seed set are used as fuzzy test seeds.
2. The method according to claim 1, characterized in that Parse the intent file line by line, match the security function code template according to the operation type and key security information type in the parsing result, assemble the matched security function code template, and obtain the security function call code template, including: Use the intent file line template to parse the intent file line by line; use the key safety information template to match the safety function code template according to the operation type and key safety information type in the parsing result; assemble the matched safety function code template to obtain the safety function call code template; Among them, the intent file line template describes the basic information of each line of the intent file; the key safety information template contains the mapping relationship between the key safety information type and the safety function code template.
3. The method according to claim 2, characterized in that The safety function code template is maintained through a tree structure; the tree structure takes the template row information as the root node, the intent file row template and the key safety information template are the successor nodes of the root node, and the safety function code template is the successor node of the key safety information template.
4. The method according to claim 1, characterized in that The prompt word template includes test purpose, test context, format, and optimization tips; Using the prompt word template, a fuzz test seed generation command set with prompt words is generated according to the initial seed set, including: Using the prompt word template, the initial seed in the initial seed set is used as an example to generate a fuzz test seed generation command set with test purpose, test context, example, format, and optimization prompts.
5. The method according to claim 1, characterized in that Calculate the similarity between the new seed set and the initial seed set. If the similarity meets the preset conditions, the new seeds in the new seed set are used as fuzzy test seeds, including: The variables and constants in the new seed set and the initial seed set are defined as nodes, and the operators and assignment relations in the new seed set and the initial seed set are defined as edges of the nodes, so as to obtain the edge set and edge point set of the new seed, and the edge set and edge point set of the initial seed; Using the Jaccard similarity algorithm, the similarity between the edge set of the new seed and the edge set of the initial seed is calculated to obtain the edge similarity; Using the Jaccard similarity algorithm, the similarity between the edge point set of the new seed and the edge point set of the initial seed is calculated to obtain the edge point similarity; If the edge similarity is greater than the preset edge similarity, or the edge similarity is less than the preset edge similarity but the edge point similarity is greater than the preset edge point similarity, the new seed set is discarded; otherwise, the new seeds in the new seed set are used as fuzzy test seeds.
6. A device for generating seeds for fuzzy testing of IoT firmware for security functions, characterized in that: include: The intent file generation module is used to generate an intent file according to the IoT firmware security function test purpose. The intent file includes operation type, key security information type, test variables, and test variable assignments; The intent file parsing module is used to parse the intent file line by line, match the security function code template according to the operation type and key security information type in the parsing result, assemble the matched security function code template, and obtain the security function call code template; The security function call code template creates a security function call vector for each line of the intent file, which is used to record the call information, used variable information, and code inspection information in the fuzz test; An initial seed generation module is used to write the test variable assignment in the parsing result into the security function call code template according to the test variable in the parsing result to obtain an initial seed set; A new seed generation module is used to use a prompt word template to generate a fuzzy test seed generation command set with prompt words according to an initial seed set, input the fuzzy test seed generation command set into a large language model, guide the large language model to mutate the initial seed set, and output a new seed set; the prompt word template includes pre-designed prompt words; The similarity evaluation module is used to calculate the similarity between the new seed set and the initial seed set. If the similarity meets the preset conditions, the new seeds in the new seed set are used as fuzzy test seeds.
7. The device according to claim 6, characterized in that The intent file parsing module is specifically used for: Use the intent file line template to parse the intent file line by line; use the key safety information template to match the safety function code template according to the operation type and key safety information type in the parsing result; assemble the matched safety function code template to obtain the safety function call code template; Among them, the intent file line template describes the basic information of each line of the intent file; the key safety information template contains the mapping relationship between the key safety information type and the safety function code template.
8. The device according to claim 7, characterized in that The safety function code template is maintained through a tree structure; the tree structure takes the template row information as the root node, the intent file row template and the key safety information template are the successor nodes of the root node, and the safety function code template is the successor node of the key safety information template.
9. The device according to claim 6, characterized in that The prompt word template includes test purpose, test context, format, and optimization tips; The new seed generation module is specifically used for: Using the prompt word template, the initial seed in the initial seed set is used as an example to generate a fuzz test seed generation command set with test purpose, test context, example, format, and optimization prompts.
10. The device according to claim 6, characterized in that The similarity assessment module is specifically used for: The variables and constants in the new seed set and the initial seed set are defined as nodes, and the operators and assignment relations in the new seed set and the initial seed set are defined as edges of the nodes, so as to obtain the edge set and edge point set of the new seed, and the edge set and edge point set of the initial seed; Using the Jaccard similarity algorithm, the similarity between the edge set of the new seed and the edge set of the initial seed is calculated to obtain the edge similarity; Using the Jaccard similarity algorithm, the similarity between the edge point set of the new seed and the edge point set of the initial seed is calculated to obtain the edge point similarity; If the edge similarity is greater than the preset edge similarity, or the edge similarity is less than the preset edge similarity but the edge point similarity is greater than the preset edge point similarity, the new seed set is discarded; otherwise, the new seeds in the new seed set are used as fuzzy test seeds.
11. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
13. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Cited By
Operating system kernel directional fuzzy testing method based on LLM auxiliary system call inference
CN121234377A