An automated method for derandomizing network protocol programs

By using an automated network protocol program derandomization method and leveraging a large language model to identify and eliminate randomness issues in the network protocol program, the stability and efficiency of fuzz testing are improved, ensuring the consistency and reproducibility of test results and reducing the cost of manual intervention.

CN121864654BActive Publication Date: 2026-06-30NAT UNIV OF DEFENSE TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NAT UNIV OF DEFENSE TECH
Filing Date
2025-08-13
Publication Date
2026-06-30

Smart Images

  • Figure CN121864654B_ABST
    Figure CN121864654B_ABST
Patent Text Reader

Abstract

This invention proposes an automated method for derandomizing network protocol programs, belonging to the field of fuzzing technology. The method includes: a code analysis phase: analyzing the target network protocol program by constructing a prompt-guided large language model to identify and classify randomness issues; an adaptive query generation phase: dynamically generating adaptive queries for each type of deterministic issue to locate the random code involved; a deterministic transformation phase: generating deterministic patches containing deterministic constraints based on the random code; a patch verification phase: verifying the effectiveness of the deterministic patches through path consistency detection and fuzzing performance evaluation; and a toolchain integration phase: integrating the generated deterministic patches into a fuzzing framework for continuous verification and subsequent optimization. This invention can identify and eliminate randomness issues in programs, significantly improving the stability and effectiveness of fuzzing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of fuzz testing technology, and in particular relates to an automated method for derandomizing network protocol programs. Background Technology

[0002] Fuzz testing of network protocols is an important method for discovering potential vulnerabilities in protocol implementations, but its effectiveness is severely limited by the randomness inherent in the target program. Randomness causes programs to produce different execution paths and states under the same input, making fuzz test results difficult to reproduce and resulting in low testing efficiency. Currently, addressing randomness issues in network protocol programs mainly relies on manually writing patches for localized modifications, lacking systematic and automated solutions.

[0003] In the existing technology, the ProFuzzBench benchmark test set uses manually written patch files to derandomize the test target program. This method has the following disadvantages: (1) Lack of systematicity: It only modifies local randomness problems and cannot fully cover all sources of randomness. (2) Low degree of automation: It relies heavily on manual intervention, which is time-consuming and difficult to scale. (3) Poor generalization ability: It cannot be directly applied to programs outside the test dataset, which limits its practicality.

[0004] Existing methods for handling randomness in network protocol programs have the following significant drawbacks: (1) Limited coverage, only able to handle explicit random number generation calls (such as the rand() function), unable to identify implicit randomness (such as UUID generation, temporary file paths, etc.); (2) Basically ineffective for environment-dependent randomness (such as network configuration, hardware entropy sources) and control flow randomness (such as thread scheduling); studies show that existing methods can only eliminate an average of 38.7% of key randomness factors. (3) Low degree of automation, completely relying on security experts to manually analyze the code, each program requires an average of 15-20 hours of manual auditing, the patch generation process requires modifying the source code line by line, cannot achieve batch processing, and the modification cycle for large code bases (such as OpenSSL) is as long as 2-3 weeks. (4) Fragmented technical solutions, lacking a unified theoretical framework, different researchers adopt their own temporary solutions, and existing tools (such as the deterministic mode of AFL) are only effective for specific types of randomness, the solutions are incompatible with each other, and it is difficult to form a complete toolchain; poor maintainability, manual patching is strongly coupled with the source code version, and the program needs to be modified again after upgrading. (5) It is impossible to establish a continuous monitoring mechanism for randomness issues. Updates of third-party libraries often cause existing patches to become invalid. Furthermore, there is insufficient verification methods and a lack of a systematic verification framework. The effect is only confirmed through limited test cases. It is impossible to quantitatively evaluate the improvement in path consistency after de-randomization. There is a lack of objective measurement standards for improving the efficiency of fuzz testing. Summary of the Invention

[0005] This invention proposes an automated network protocol program derandomization scheme, aiming to address the shortcomings of existing technologies.

[0006] The first aspect of this invention proposes an automated method for derandomizing network protocol programs, the method comprising:

[0007] Step S1, Code Analysis Phase: Analyze the target network protocol program by constructing a prompt-guided large language model, identify randomness issues, and classify these randomness issues.

[0008] Step S2, Adaptive Query Generation Stage: Dynamically generate adaptive queries for each type of deterministic problem to locate the randomness code involved in the randomness problem;

[0009] Step S3, Deterministic Transformation Stage: Generate a deterministic patch containing deterministic constraints based on the randomness code;

[0010] Step S4, Patch Verification Phase: Verify the effectiveness of the deterministic patch by performing path consistency checks and fuzzing performance evaluation;

[0011] Step S5, Toolchain Integration Phase: Integrate the generated deterministic patch into the fuzzing framework for continuous verification and subsequent optimization.

[0012] According to the method of the first aspect of the present invention, in step S1, the randomness problem in the target network protocol program includes three orthogonal dimensions: algorithm-level randomness, environment-dependent randomness, and control flow randomness; each dimension corresponds to a deterministic transformation strategy; wherein:

[0013] For algorithm-level randomness, it involves random number generators, time-related values, and randomization functions from third parties; in the corresponding deterministic transformation strategy, random seed solidification, random function replacement, and virtual time-series simulation mechanisms are used to ensure that the generated random number sequences and time-related values ​​are predictable and repeatable.

[0014] Regarding the randomness of environmental dependencies, which involves randomly generated unique identifiers, file system paths, and network configurations; in the corresponding deterministic transformation strategy, the impact of environmental uncertainty on the behavior of the target network protocol program is eliminated by fixing the identifiers, normalizing the file system, and staticizing the network configuration.

[0015] For control flow randomness, it involves conditional branching based on random numbers, multi-threaded scheduling, timeout and retry mechanisms; in the corresponding deterministic transition strategy, fixed branches, deterministic scheduling, and timeout control ensure that the control flow of the target network protocol program remains consistent during runtime.

[0016] According to the method of the first aspect of the present invention, in step S2, constructing the prompting project specifically includes: dynamically generating adaptive queries for deterministic problems by constructing a prompting project for a large language model.

[0017] Protocol semantic encoding: embedding domain knowledge of network protocols into prompts, annotating protocol-specific randomness features, and enhancing the ability of large language models to understand context-sensitive patterns;

[0018] Layered guidance for randomness issues: Using structured prompt templates and large language models to detect random sources, dynamic program attributes, and nondeterministic control flow;

[0019] Context enhancement: Enhances code semantic understanding by embedding topological features of function call graphs, annotating data flow trajectories of key variables, and providing stage marking information for protocol state machines.

[0020] According to the method of the first aspect of the present invention, step S3 specifically includes:

[0021] Iterative code exploration of random code: By constructing dynamic queries, combined with a targeted query mechanism and a progressive focusing strategy, random code is explored;

[0022] Dynamic context completion for detected random code: By using call chain-aware retrieval and data flow enhancement techniques, call chain breaks in cross-module analysis are repaired to complete the relevant context;

[0023] Deterministic patch generation based on complete context: Generates standardized modification suggestions and multimodal descriptions, provides code snippets, natural language descriptions, and patch verification test cases, enhancing the understandability and verifiability of deterministic patches.

[0024] According to the method of the first aspect of the present invention, in step S3, when generating a deterministic patch, a layered patch generation strategy is adopted to convert the normalized modification suggestions based on natural language into code patches that conform to the target language specifications, and to establish a patterned replacement rule base, thereby realizing cross-architecture portability.

[0025] According to the method of the first aspect of the present invention, in step S4, a multi-dimensional verification scheme is used, including execution path consistency detection and fuzzing performance evaluation, to verify the effectiveness of the deterministic patch; wherein, effectiveness refers to: the execution path remains consistent under the same input and the crash reproducibility rate reaches a preset value.

[0026] According to the method of the first aspect of the present invention, in step S5, the generated deterministic patch is integrated into the fuzzing framework, seamlessly connected with the fuzzing framework, a new deterministic intermediate representation conversion layer is added, protocol state-sensitive seed scheduling is performed, and a pipeline for continuous verification and subsequent optimization is constructed.

[0027] A second aspect of the present invention provides an automated network protocol program derandomization system, the system comprising a processing unit configured to:

[0028] During the code analysis phase: the target network protocol program is analyzed by constructing a prompt-guided large language model, identifying and classifying randomness issues;

[0029] During the adaptive query generation phase: dynamically generate adaptive queries for each type of deterministic problem to locate the random codes involved in random problems;

[0030] Executed during the deterministic transformation phase: Generate a deterministic patch containing deterministic constraints based on the randomness code;

[0031] During the patch verification phase: the effectiveness of deterministic patches is verified by performing path consistency checks and fuzzing performance evaluations.

[0032] During the toolchain integration phase, the generated deterministic patches are integrated into the fuzzing framework for continuous verification and subsequent optimization.

[0033] A third aspect of this invention discloses an electronic device. The electronic device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements an automated network protocol program derandomization method according to the first aspect of this disclosure.

[0034] A fourth aspect of this invention discloses a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements an automated network protocol program derandomization method according to the first aspect of this disclosure.

[0035] This invention proposes an automated method for derandomizing network protocol programs. Through a systematic derandomization framework, it identifies and eliminates randomness issues in programs, significantly improving the stability and effectiveness of fuzz testing. This invention achieves: comprehensive coverage of three types of randomness issues in network protocol programs; automated derandomization process, reducing manual intervention; and improved code coverage and crash detection rate in fuzz testing. Attached Figure Description

[0036] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0037] Figure 1 A flowchart illustrating an automated network protocol program derandomization method according to an embodiment of the present invention. Detailed Implementation

[0038] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0039] The definitions of key terms involved in this invention include:

[0040] DerandomPre: A systematic approach based on Large Language Model (LLM) that aims to improve the stability and effectiveness of fuzz testing by eliminating randomness issues in network protocol programs.

[0041] Randomness issues refer to code behaviors in network protocol programs that result in different execution paths and states under the same input. They mainly include three categories: algorithm-level randomness, environment-dependent randomness, and control flow randomness.

[0042] Deterministic constraints: Methods that use technical means to transform random behavior in a program into deterministic behavior, ensuring that the program produces a consistent execution path and state under the same input.

[0043] Fuzzing: An automated testing technique that triggers potential vulnerabilities by feeding a large amount of unexpected data into a target program.

[0044] The first aspect of this invention proposes an automated method for derandomizing network protocol programs, the method comprising:

[0045] Step S1, Code Analysis Phase: Analyze the target network protocol program by constructing a prompt-guided large language model, identify randomness issues, and classify these randomness issues.

[0046] Step S2, Adaptive Query Generation Stage: Dynamically generate adaptive queries for each type of deterministic problem to locate the randomness code involved in the randomness problem;

[0047] Step S3, Deterministic Transformation Stage: Generate a deterministic patch containing deterministic constraints based on the randomness code;

[0048] Step S4, Patch Verification Phase: Verify the effectiveness of the deterministic patch by performing path consistency checks and fuzzing performance evaluation;

[0049] Step S5, Toolchain Integration Phase: Integrate the generated deterministic patch into the fuzzing framework for continuous verification and subsequent optimization.

[0050] According to the method of the first aspect of the present invention, in step S1, the randomness problem in the target network protocol program includes three orthogonal dimensions: algorithm-level randomness, environment-dependent randomness, and control flow randomness; each dimension corresponds to a deterministic transformation strategy; wherein:

[0051] For algorithm-level randomness, it involves random number generators, time-related values, and randomization functions from third parties; in the corresponding deterministic transformation strategy, random seed solidification, random function replacement, and virtual time-series simulation mechanisms are used to ensure that the generated random number sequences and time-related values ​​are predictable and repeatable.

[0052] Regarding the randomness of environmental dependencies, which involves randomly generated unique identifiers, file system paths, and network configurations; in the corresponding deterministic transformation strategy, the impact of environmental uncertainty on the behavior of the target network protocol program is eliminated by fixing the identifiers, normalizing the file system, and staticizing the network configuration.

[0053] For control flow randomness, it involves conditional branching based on random numbers, multi-threaded scheduling, timeout and retry mechanisms; in the corresponding deterministic transition strategy, fixed branches, deterministic scheduling, and timeout control ensure that the control flow of the target network protocol program remains consistent during runtime.

[0054] According to the method of the first aspect of the present invention, in step S2, constructing the prompting project specifically includes: dynamically generating adaptive queries for deterministic problems by constructing a prompting project for a large language model.

[0055] Protocol semantic encoding: embedding domain knowledge of network protocols into prompts, annotating protocol-specific randomness features, and enhancing the ability of large language models to understand context-sensitive patterns;

[0056] Layered guidance for randomness issues: Using structured prompt templates and large language models to detect random sources, dynamic program attributes, and nondeterministic control flow;

[0057] Context enhancement: Enhances code semantic understanding by embedding topological features of function call graphs, annotating data flow trajectories of key variables, and providing stage marking information for protocol state machines.

[0058] According to the method of the first aspect of the present invention, step S3 specifically includes:

[0059] Iterative code exploration of random code: By constructing dynamic queries, combined with a targeted query mechanism and a progressive focusing strategy, random code is explored;

[0060] Dynamic context completion for detected random code: By using call chain-aware retrieval and data flow enhancement techniques, call chain breaks in cross-module analysis are repaired to complete the relevant context;

[0061] Deterministic patch generation based on complete context: Generates standardized modification suggestions and multimodal descriptions, provides code snippets, natural language descriptions, and patch verification test cases, enhancing the understandability and verifiability of deterministic patches.

[0062] According to the method of the first aspect of the present invention, in step S3, when generating a deterministic patch, a layered patch generation strategy is adopted to convert the normalized modification suggestions based on natural language into code patches that conform to the target language specifications, and to establish a patterned replacement rule base, thereby realizing cross-architecture portability.

[0063] According to the method of the first aspect of the present invention, in step S4, a multi-dimensional verification scheme is used, including execution path consistency detection and fuzzing performance evaluation, to verify the effectiveness of the deterministic patch; wherein, effectiveness refers to: the execution path remains consistent under the same input and the crash reproducibility rate reaches a preset value.

[0064] According to the method of the first aspect of the present invention, in step S5, the generated deterministic patch is integrated into the fuzzing framework, seamlessly connected with the fuzzing framework, a new deterministic intermediate representation conversion layer is added, protocol state-sensitive seed scheduling is performed, and a pipeline for continuous verification and subsequent optimization is constructed.

[0065] The first embodiment of the present invention will be described in detail below.

[0066] Code analysis phase: Customized prompts guide the large language model to scan the target network protocol program, identifying and classifying randomness issues. For example, if the program uses the rand() function to generate random numbers, it falls under the category of algorithmic randomness.

[0067] Adaptive query generation phase: Based on the preliminary analysis results, adaptive queries are dynamically generated to further pinpoint randomness. For example, the query "Does the use of the rand() function affect the program's execution path?" is generated.

[0068] Deterministic transformation phase: Based on the analysis results, a deterministic patch is generated. For example, rand() is replaced with a deterministic random number generation function based on a fixed seed.

[0069] Patch Verification Phase: The effectiveness of the patch is verified through execution path consistency checks and fuzzing performance evaluation. For example, it verifies whether the execution path consistency of the modified program under the same input meets expectations, and whether the crash reproducibility rate has improved to 100%.

[0070] Toolchain integration phase: Integrate the generated patches into mainstream fuzzing frameworks for continuous verification and optimization.

[0071] The second embodiment of the present invention will be described in detail below.

[0072] This embodiment proposes a network protocol program derandomization method, DerandomPre, based on Large Language Model (LLM). It aims to address the randomness problem in network protocol programs through a systematic derandomization framework, thereby significantly improving the stability and effectiveness of network protocol fuzzing. This method automatically analyzes the target program, identifies and classifies sources of randomness, and applies deterministic constraints to ensure that the program produces consistent execution paths and states under the same input.

[0073] The derandomization framework systematically defines the stochasticity problem in network protocol programs and provides targeted deterministic solutions for each type of problem. The framework categorizes the stochasticity problem in network protocol programs into three orthogonal dimensions: algorithmic stochasticity, environment-dependent stochasticity, and control flow stochasticity, and provides specific deterministic transformation strategies for each dimension.

[0074] Algorithm-level randomness: This includes random number generators, time-dependent values, and randomization functions from third-party libraries. To address this issue, methods such as random seed fixation, random function replacement, and virtual time-series simulation mechanisms are employed to ensure the predictability and repeatability of the generated random number sequences and time-dependent values.

[0075] Environmental dependency randomness: This involves randomly generated unique identifiers, file system paths, network configurations, etc. Methods such as fixing identifiers, normalizing file systems, and staticizing network configurations can eliminate the impact of environmental uncertainty on program behavior.

[0076] Control flow randomness includes random number-based conditional branching, multi-threaded scheduling, timeout and retry mechanisms, etc. By using methods such as fixed branching, deterministic scheduling, and timeout control, the program's control flow is ensured to remain consistent throughout runtime.

[0077] To guide Large Language Models (LLMs) in accurately understanding deterministic transformation frameworks and identifying stochastic code patterns, this invention designs a domain-specific hint engineering scheme. This scheme is constructed through the following core strategies:

[0078] Protocol semantic encoding: embedding domain knowledge of network protocols into prompts, annotating protocol-specific randomness features, and enhancing the model's ability to understand context-sensitive patterns.

[0079] Layered guidance for stochastic problems: Using structured prompt templates, the model is explicitly required to detect three types of problems: basic random sources, dynamic program properties, and nondeterministic control flow.

[0080] Context enhancement mechanism: Enhances code semantic understanding by embedding topological features of function call graphs, annotating data flow trajectories of key variables, and providing stage marking information of protocol state machines.

[0081] After completing the initial code analysis, the DerandomPre system uses dynamically generated adaptive queries to accurately locate random code. This mechanism achieves iterative optimization of the analysis process through the following three collaborative strategies:

[0082] Iterative code exploration: By constructing a dynamic query generation model, combined with a targeted query mechanism and a progressive focusing strategy, it achieves precise location of potentially random code.

[0083] Dynamic context completion: By using call chain awareness retrieval and data flow enhancement techniques, it solves the problem of broken call chains in cross-module analysis, improving the accuracy and efficiency of cross-module code analysis.

[0084] Deterministic Patch Description Generation: Generates standardized modification suggestions and multimodal descriptions for confirmed random code, providing code snippets, natural language descriptions, and patch verification test cases to enhance the understandability and verifiability of patches.

[0085] Based on the potential nondeterministic code location results output in the preliminary analysis stage, an automated deterministic transformation is performed. Its technical implementation includes the following three core steps:

[0086] Deterministic patch generation: A layered patch generation strategy is adopted to convert natural language modification suggestions into code patches that conform to the target language specifications, and a patterned replacement rule base is established to support cross-architecture portability.

[0087] Patch verification framework: Design a multi-dimensional verification scheme, including execution path consistency detection and fuzzing performance evaluation, to ensure that the behavior of the transformed program meets expectations and improve the key indicators of fuzzing.

[0088] Automated toolchain integration: Achieves seamless integration with mainstream fuzzing frameworks, adds a deterministic intermediate representation (DIR) transformation layer, supports protocol state-sensitive seed scheduling, and builds a continuous verification pipeline.

[0089] A second aspect of the present invention provides an automated network protocol program derandomization system, the system comprising a processing unit configured to:

[0090] During the code analysis phase: the target network protocol program is analyzed by constructing a prompt-guided large language model, identifying and classifying randomness issues;

[0091] During the adaptive query generation phase: dynamically generate adaptive queries for each type of deterministic problem to locate the random codes involved in random problems;

[0092] Executed during the deterministic transformation phase: Generate a deterministic patch containing deterministic constraints based on the randomness code;

[0093] During the patch verification phase: the effectiveness of deterministic patches is verified by performing path consistency checks and fuzzing performance evaluations.

[0094] During the toolchain integration phase, the generated deterministic patches are integrated into the fuzzing framework for continuous verification and subsequent optimization.

[0095] A third aspect of this invention discloses an electronic device. The electronic device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements an automated network protocol program derandomization method according to the first aspect of this disclosure.

[0096] A fourth aspect of this invention discloses a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements an automated network protocol program derandomization method according to the first aspect of this disclosure.

[0097] This invention proposes an automated method for derandomizing network protocol programs. Through a systematic derandomization framework, it identifies and eliminates randomness issues in programs, significantly improving the stability and effectiveness of fuzz testing. This invention achieves: comprehensive coverage of three types of randomness issues in network protocol programs; automated derandomization process, reducing manual intervention; and improved code coverage and crash detection rate in fuzz testing.

[0098] The network protocol program derandomization method (DerandomPre) based on the Large Language Model (LLM) and its systematic derandomization framework proposed in this invention can produce the following significant advantages compared with existing technologies:

[0099] First, this invention improves the stability of fuzz testing.

[0100] Consistent Execution Path: Through systematic derandomization processing, DerandomPre significantly improves the consistency of execution paths for network protocol programs under the same input. Experiments show that consistency is improved by an order of magnitude, making fuzz test results more reproducible and reducing fluctuations in test results caused by randomness.

[0101] Enhanced feedback mechanism: Improved stability makes the feedback mechanism of fuzzing more reliable, enabling it to guide input mutation strategies more efficiently, thereby improving testing efficiency and discovering potential vulnerabilities more quickly.

[0102] Second, this invention improves testing efficiency.

[0103] Significantly improved code coverage: Programs processed by DerandomPre show an average increase in code coverage of 30%. This indicates that derandomization can more comprehensively cover the program's execution path, improving the depth and breadth of testing.

[0104] Increased unique crash detection rate: DerandomPre increases the unique crash detection rate by 25%, enabling it to more effectively discover potential vulnerabilities in programs, improve the effectiveness of testing, and reduce security risks.

[0105] Third, this invention reduces the cost of manual intervention.

[0106] High degree of automation: Compared to traditional methods of manually fixing randomness issues, DerandomPre automates the entire process from code analysis, randomness identification, patch generation to verification. What used to take hours of manual work is now completed in minutes, greatly improving work efficiency.

[0107] High scalability: DerandomPre boasts excellent scalability, easily adapting to different types of network protocol programs without requiring a redesign of the solution for each program. This makes the method widely applicable to various network protocol fuzzing scenarios, reducing labor and time costs.

[0108] Fourth, this invention improves the reproducibility of test results.

[0109] Deterministic execution: By generating and applying deterministic patches, DerandomPre ensures consistent program behavior across different test runs. For example, enhanced controllability of crash triggering conditions significantly improves the reproducibility of test results, making it easier for developers to locate and fix vulnerabilities.

[0110] A robust verification mechanism is in place: This invention designs a multi-dimensional patch verification framework, including execution path consistency detection and fuzzing performance evaluation, to ensure the effectiveness and reliability of patches. This further improves the credibility and reproducibility of test results.

[0111] Fifth, this invention enhances the maintainability of the program.

[0112] Standardized Modification Suggestions: DerandomPre generates standardized modification suggestions for confirmed randomized code and provides multimodal descriptions, including code snippets, natural language descriptions, and patch verification test cases. This allows developers to more clearly understand the content and purpose of the patches, facilitating subsequent maintenance and updates.

[0113] Reduce false positive rate: Through adaptive query generation mechanism and dynamic context completion technology, the false positive rate is significantly reduced (from 12.1% to 4.4%), reducing unnecessary code modification and verification work and improving development efficiency.

[0114] Sixth, it has promoted the development of fuzz testing technology.

[0115] Innovative Theoretical Framework: The Derandomization Framework is the core theoretical foundation of this invention. It is the first to systematically define the randomness problem in network protocol programs and provides targeted solutions for each type of problem. This provides new theoretical support and technical approaches for the field of network protocol fuzzing.

[0116] Application of Large Language Models: This pioneering application of large language models to code stochasticity analysis achieves high-precision code understanding through innovative hint engineering. This not only improves the accuracy of identifying stochastic issues but also provides a new paradigm for the application of large language models in software testing.

[0117] In summary, this invention, through a systematic derandomization method and framework, significantly improves the stability, efficiency, and reproducibility of network protocol fuzzing, reduces the cost of manual intervention, enhances program maintainability, and promotes the development of fuzzing technology. These technical effects make DerandomPre an efficient, reliable, and widely applicable solution for derandomizing network protocol programs.

[0118] Please note that the technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments have been described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification. The above embodiments only illustrate several implementations of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention patent. It should be pointed out that for those skilled in the art, several modifications and improvements can be made without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of the present invention should be determined by the appended claims.

Claims

1. An automated method for derandomizing network protocol programs, characterized in that, The method includes: Step S1, Code Analysis Phase: Analyze the target network protocol program by constructing a prompt-guided large language model, identify randomness issues, and classify these randomness issues. Step S2, Adaptive Query Generation Stage: Dynamically generate adaptive queries for each type of deterministic problem to locate the randomness code involved in the randomness problem; Step S3, Deterministic Transformation Stage: Generate a deterministic patch containing deterministic constraints based on the randomness code; Step S4, Patch Verification Phase: Verify the effectiveness of the deterministic patch by performing path consistency checks and fuzzing performance evaluation; Step S5, Toolchain Integration Phase: Integrate the generated deterministic patch into the fuzzing framework for continuous verification and subsequent optimization; In step S1, the randomness problem in the target network protocol program includes three orthogonal dimensions: algorithm-level randomness, environment-dependent randomness, and control flow randomness; each dimension corresponds to a deterministic transformation strategy; wherein: For algorithm-level randomness, it involves random number generators, time-related values, and randomization functions from third parties; in the corresponding deterministic transformation strategy, random seed solidification, random function replacement, and virtual time-series simulation mechanisms are used to ensure that the generated random number sequences and time-related values ​​are predictable and repeatable. Regarding the randomness of environmental dependencies, which involves randomly generated unique identifiers, file system paths, and network configurations; in the corresponding deterministic transformation strategy, the impact of environmental uncertainty on the behavior of the target network protocol program is eliminated by fixing the identifiers, normalizing the file system, and staticizing the network configuration. For control flow randomness, it involves conditional branching based on random numbers, multi-threaded scheduling, timeout and retry mechanisms; in the corresponding deterministic transition strategy, fixed branches, deterministic scheduling, and timeout control are used to ensure that the control flow of the target network protocol program remains consistent during runtime. In step S2, adaptive queries for deterministic problems are dynamically generated by constructing a prompting project for the large language model. The construction of the prompting project specifically includes: Protocol semantic encoding: embedding domain knowledge of network protocols into prompts, annotating protocol-specific randomness features, and enhancing the ability of large language models to understand context-sensitive patterns; Layered guidance for randomness issues: Using structured prompt templates and large language models to detect random sources, dynamic program attributes, and nondeterministic control flow; Context enhancement: Enhances code semantic understanding by embedding topological features of function call graphs, annotating data flow trajectories of key variables, and providing stage marking information for protocol state machines; Specifically, step S3 includes: Iterative code exploration of random code: By constructing dynamic queries, combined with a targeted query mechanism and a progressive focusing strategy, random code is explored; Dynamic context completion for detected random code: By using call chain-aware retrieval and data flow enhancement techniques, call chain breaks in cross-module analysis are repaired to complete the relevant context; Deterministic patch generation based on complete context: Generates standardized modification suggestions and multimodal descriptions, provides code snippets, natural language descriptions, and patch verification test cases, enhancing the understandability and verifiability of deterministic patches.

2. The automated network protocol program derandomization method according to claim 1, characterized in that, In step S3, when generating deterministic patches, a layered patch generation strategy is adopted to convert the normalized modification suggestions based on natural language into code patches that conform to the target language specifications, and to establish a patterned replacement rule base, thereby achieving cross-architecture portability.

3. The automated network protocol program derandomization method according to claim 2, characterized in that, In step S4, a multi-dimensional verification scheme is used, including execution path consistency detection and fuzzing performance evaluation, to verify the effectiveness of the deterministic patch; where effectiveness refers to: the execution path remains consistent under the same input and the crash reproducibility rate reaches a preset value.

4. The automated network protocol program derandomization method according to claim 3, characterized in that, In step S5, the generated deterministic patch is integrated into the fuzzing framework for seamless integration. A new deterministic intermediate representation conversion layer is added, protocol state-sensitive seed scheduling is performed, and a pipeline for continuous verification and subsequent optimization is built.