Method and system for constructing a multi-language symbolic execution framework based on bytecode emulation
By using a multilingual symbolic execution framework based on bytecode simulation, the problem of adapting symbolic execution processes for different languages is solved, and the isolation of operations and states of the target language in the same execution process is achieved, thereby improving execution efficiency and consistency.
Patent Information
- Application Number
- CN202611673636.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-28
- Publication Date
- 2026-11-27
AI Technical Summary
In existing technologies, a lot of adaptation work is required between instruction processing of different languages and execution flow of shared symbols, which can easily lead to the problem of repeated implementation of execution logic.
By employing a multilingual symbolic execution framework based on bytecode simulation, a unified instruction object is used to bind instruction parameters and instruction implementation. A unified calling interface and a shared simulated value representation and a shared program state representation are used to handle instruction semantics of different target languages. Furthermore, program state isolation is maintained through object identifiers and object mapping tables, reducing redundant implementations during language adaptation.
It implements specific operations and symbolic expression construction for different target languages in the same execution flow, reduces redundant implementation during language adaptation, improves the efficiency of state isolation during program state replication, and ensures state consistency between execution paths.
Smart Images

Figure CN123178239A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer program analysis, specifically to a method and system for constructing a multilingual symbolic execution framework based on bytecode simulation. Background Technology
[0002] Symbolic execution represents program input using symbolic values, records path constraints during execution, and generates test input through constraint solving. It can be used for software testing, vulnerability discovery, and reverse engineering. With the application of languages or bytecode environments such as Lua, Move, and WebAssembly, program analysis tools need to adapt to different instruction formats and runtime semantics.
[0003] Some symbolic execution tools are developed for specific languages, binary programs, or execution platforms. When extended to other languages, additional implementations of instruction processing, data types, and runtime behavior are required. Multi-language frameworks using intermediate representations can reuse analysis functions, but still require the development of bytecode converters and handling of semantic conversions for data types, function calls, and exception behavior. Implementing symbolic execution by modifying the interpreter or writing formal semantic rules also requires continuous maintenance of the correspondence with the target language, increasing adaptation work.
[0004] Path exploration requires copying multiple program states. Full copying of mutable objects increases time and storage overhead; when using object sharing or copy-on-write, it is also necessary to handle duplicate references, circular references, and post-copy reference updates to avoid modifications between different paths affecting each other.
[0005] Hybrid symbolic execution relies on specific inputs to re-execute the program, while static symbolic execution continues exploration from the existing state. Since their state progression methods differ, it is necessary to unify the relationship between the solution results and subsequent execution, and to separately verify the input assignments and the actual execution path. Summary of the Invention
[0006] To address the shortcomings of existing technologies, this invention provides a method and system for constructing a multilingual symbolic execution framework based on bytecode simulation. This solves the problem that existing technologies still require a lot of adaptation work between instruction processing of different languages and shared symbolic execution processes, and that execution logic is easily repeated.
[0007] To achieve the above objectives, the present invention provides the following technical solution: The first aspect of this invention provides a method for constructing a multilingual symbolic execution framework based on bytecode simulation, comprising the following steps: Obtain the target language and bytecode specification, prepare the instruction implementation of the target language according to the bytecode specification, parse the target language bytecode program, bind the instruction parameters and instruction implementation into a unified instruction object, and establish the program structure and execution record; The execution entry point is determined based on the program structure. The execution environment, preset execution strategy, and preset input value range are obtained. Based on the execution entry point and execution environment, a mapping table of simulated values, program states, and objects is established using shared simulated value representation and shared program state representation. Initial path constraints are established based on the input value range. The instruction implementation of the unified instruction object is invoked, the simulated value is read from the program state as the operand, the symbolic expression is constructed when the operand contains a symbolic value, and the execution result and the applicable conditional expression are generated. Conditional expressions are processed according to the execution strategy. During normal execution, the execution result is submitted. Program state isolation is maintained through an object mapping table. Execution paths are formed and written to the execution record based on changes in program state. Candidate paths are constructed based on the execution path and initial path constraints. The path constraints are solved and verified. The program state is generated according to the execution strategy and the exploration continues. After the exploration is completed, the analysis results are generated based on the execution records.
[0008] Furthermore, the instruction implementation receives program status and instruction parameters through a unified API call, generating an execution result that includes the status modification content and the subsequent position. The unified instruction object maintains the binding relationship between instruction parameters and instruction implementations, passing the program status and instruction parameters to the corresponding instruction implementation during execution.
[0009] The instruction implementations of different target languages read operands and perform calculations according to their respective instruction semantics, and use a shared analog value representation and a shared program state representation to save the calculation data. Condition processing determines the actual execution direction, and when the execution result is submitted, the corresponding state modification content and subsequent position are selected, so that the language-adapted instruction implementations can participate in the shared execution process.
[0010] Furthermore, the input variables are determined based on the execution entry point, preset symbolic variables are read, symbolic variable identifiers are assigned to the symbolic variables, and simulated values of the symbolic variables are established using symbolic values. The remaining input variables use specific values. These remaining input variables are those that were not selected as symbolic variables.
[0011] The hybrid symbolic execution strategy establishes a mapping between input variables and concrete values, as well as a mapping between symbolic variables and symbolic values. When all operands are concrete values, concrete operations are performed; when operands include symbolic values, symbolic expressions are constructed, and concrete values are simultaneously computed under the hybrid symbolic execution strategy. Concrete values are used to determine the actual execution direction, while symbolic expressions are used to form conditional expressions and path constraints. The static symbolic execution strategy retains symbolic expressions for subsequent computation and determines the satisfiability of candidate directions based on path constraints.
[0012] Symbolic variable identifiers are used to identify symbolic variables, and these identifiers are reused when the program state is recreated. Input assignments and values at the current storage location are saved separately. Local variable updates do not overwrite input assignments, ensuring that subsequent constraint solving and specific input generation still correspond to the input variables at the time of initialization.
[0013] Furthermore, the copying process replicates mutable data within the execution environment. Objects are registered according to their object identities, and their internal data is then copied. Repeated and circular references reuse registered objects. Object identifiers are assigned to the copied objects, and an object mapping table is established based on the correspondence between object identifiers and objects. References are used to store both object identifiers and objects.
[0014] Establish a state queue, an end state set, and candidate path records. When copying program states, maintain references, storage locations, and object mapping tables separately, sharing objects that have not yet been written. Each program state updates its own object mapping table, and objects that have not yet been written maintain reference relationships by retaining object identifiers.
[0015] Before writing, the system checks the state queue, end state set, candidate path records, and the object mapping table in the program state retained by the current instruction. If there are other program states outside the current program state that associate the same object identifier with the same object identity, copy-on-write is used to retain the object identifier, update the object mapping table of the current program state, and then write the object. If no such sharing relationship exists, the system directly writes the object accessed by the current program state.
[0016] During access, the object mapping table is queried by object identifier. If the object identity stored in the reference does not match the query result, delayed reference repair is performed. When the reference is located inside a shared object, the object carrying the reference and its references are copied, the object mapping table of the current program state is updated, and then the reference is repaired.
[0017] An object identifier is used to identify an object, and an object mapping table is used to determine the object accessed by the current program state. Copy-on-write retains the object identifier and only changes the object corresponding to the object identifier in the current program state; lazy reference repair updates the reference based on the object mapping table, allowing the current program state to access the copied object, while other program states continue to access the objects in their respective object mapping tables.
[0018] Furthermore, after the program state ends and path verification passes, the hybrid symbolic execution strategy combines the initial path constraints with the path prefix before the target branch and the negation of the actual symbolic conditions to form the path constraints in the target direction. Conditions after the target branch are not included in this combination.
[0019] The static symbolic execution strategy preserves the program state before the symbolic condition is determined. It extracts the path prefix from the execution path and combines the pre-determination path constraints with the branch conditions and their negations to form the target direction. If runtime check conditions exist, they are negated to form a target direction that terminates abnormally. Normally executed target directions combine runtime check conditions with applicable branch conditions. The conditions corresponding to each target direction are combined with the pre-determination path constraints to obtain the path constraints of the candidate path.
[0020] The branch positions are determined from the execution path. Deduplication is performed based on the branch position, ordered path prefixes, and target direction. Candidate paths are saved to a candidate path record, and path constraints and ordered conditions corresponding to the target direction are associated. A hybrid symbolic execution strategy is used to associate the execution environment, while a static symbolic execution strategy is used to associate the program state before the decision and a copy of the execution result.
[0021] Both execution strategies read and solve the path constraints from the candidate path records. The hybrid symbolic execution strategy saves the execution environment and target conditions required for re-execution, while the static symbolic execution strategy saves copies of the program state and execution results required to generate the subsequent state, providing a basis for the generation of the subsequent program state.
[0022] Furthermore, the path constraints in the candidate path records are read, and the two execution strategies use the SMT solver to solve and obtain the satisfiability results.
[0023] When the satisfiability result is satisfactory, a specific value is assigned. Missing values for symbolic variables are filled in according to the input value range, while unsymbolized input variables retain their initial specific values. The assigned specific values are substituted into the complete path constraints. If all constraints are satisfied, the assigned specific values and the verification results of the successful assignments are written into the candidate path record.
[0024] Furthermore, when the assignment verification passes, the specific value is restored to the specific input.
[0025] The hybrid symbolic execution strategy recreates the program state using concrete inputs and the execution environment, rebuilding concrete value mappings, symbolic value mappings, and object mapping tables, while retaining the symbolic variable identifiers. The recreated program state begins execution from the entry point, with initialization data in the execution environment used to restore the program state, and concrete inputs used to determine the specific values of the symbolic variables.
[0026] The static symbolic execution strategy copies the program state associated with candidate paths, preserves the simulation state, associates specific inputs without replacing symbol values, and updates the execution path and path constraints according to the target direction. Specific inputs are used to record the input assignments corresponding to the path constraints, while symbol values in the simulation state continue to participate in subsequent symbolic execution.
[0027] Associate candidate paths with program status. Submit execution results when execution is normal. Add to the status queue when execution can continue. Do not submit status changes for normal execution when execution ends abnormally. Add the terminated program status to the termination status set.
[0028] Furthermore, the hybrid symbol execution strategy concatenates the path prefix with the ordered conditions corresponding to the target direction to form the expected path prefix. The input range constraints in the initial path constraints are used for specific input verification and are not included in the path verification sequence.
[0029] Upon re-execution, the branch positions, jump directions, and number of conditions are checked against the expected path prefix. For symbolic conditions, the conditional expressions are also checked. Once the check is complete or the program state ends, the verification status is "verified." If all conditions match, the verification result is "passed"; otherwise, the verification result is "failed."
[0030] The verification status and verification results are associated with the candidate path and program status to form a path verification record. The assignment verification judges whether the specific value assignment meets the complete path constraints, and the path verification judges whether the order of conditions for re-execution and the target direction are consistent with the expected path prefix. The two types of verification results are recorded respectively.
[0031] Furthermore, analysis results are generated based on the execution paths in the execution records and the path constraints in the candidate path records, and the path verification records are associated with them.
[0032] The second aspect of this invention provides a system for constructing a multilingual symbolic execution framework based on bytecode simulation, applied to the method for constructing a multilingual symbolic execution framework based on bytecode simulation provided in the first aspect of this invention, comprising: The language adaptation module is used to prepare instruction implementations according to the target language and bytecode specifications, parse the target language bytecode program, bind instruction parameters and instruction implementations into a unified instruction object, and establish program structure and execution records. The state management module is used to determine the execution entry point based on the program structure, obtain the execution environment, preset execution strategy and preset input value range, establish a mapping table of simulated values, program states and objects based on the execution entry point and execution environment using shared simulated value representation and shared program state representation, and establish initial path constraints based on the input value range. The simulation execution module is used to call the instruction implementation of the unified instruction object, read the simulated value as the operand, construct the symbolic expression when the operand contains a symbolic value, generate the execution result and the applicable conditional expression, submit the execution result during normal execution, maintain the program state isolation through the object mapping table, form the execution path according to the changes in the program state and write it into the execution record; The symbolic execution module is used to process conditional expressions according to the execution strategy, construct candidate paths based on the execution path and initial path constraints, solve path constraints and perform assignment verification, and generate program states according to the execution strategy. The exploration and analysis module is used to schedule program status and candidate paths and continuously explore them. After the exploration is completed, analysis results are generated based on the execution records.
[0033] This invention provides a method and system for constructing a multilingual symbolic execution framework based on bytecode simulation. It has the following beneficial effects: 1. This invention achieves this by binding instruction parameters and instructions to a unified instruction object, using a unified calling interface and shared simulated value representation and shared program state representation, enabling different target languages to access the same execution flow. It completes specific calculations, symbolic expression construction and execution result submission while preserving the semantics of the target language instructions, reducing the repetitive implementation of symbolic execution flow during language adaptation.
[0034] 2. This invention determines the objects accessed in the current program state by using object identifiers and object mapping tables. Combined with copy-on-write and delayed reference repair, it restricts the writing of variable values to the current program state and maintains the association relationship of repeated references and circular references, thereby achieving state isolation between different execution paths and reducing the repeated copying of shared objects that have not yet been written during the program state copying process.
[0035] 3. This invention connects the constraint solving, assignment verification, and program state generation processes of two execution strategies through candidate path records. It promotes execution by recreating the program state and copying the program state, respectively. The actual conditions are verified against the expected path prefix through path verification, so that the correspondence between specific value assignment, specific input and execution path can be verified, which is convenient for tracking the verification status of candidate paths. Attached Figure Description
[0036] Figure 1 This is a system architecture diagram of the present invention; Figure 2 This is a flowchart of the method of the present invention; Figure 3 This is a flowchart illustrating the language adaptation and bytecode parsing process of this invention. Figure 4 This is a flowchart illustrating the execution conditions determination and program state initialization of the present invention. Figure 5 This is a flowchart illustrating the instruction execution and program state isolation of the present invention; Figure 6 This is a flowchart of the condition processing and subsequent state generation of the present invention; Figure 7 A flowchart is generated based on the ongoing exploration and analysis results of this invention; Figure 8This is a comparison chart showing the number of array element copies in a state isolation simulation of an application embodiment of the present invention. Detailed Implementation
[0037] The technical solutions in 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.
[0038] Please see the appendix Figure 1 This invention provides a system for building a multilingual symbolic execution framework based on bytecode simulation, comprising: The language adaptation module is used to prepare the bytecode loader, instruction implementation, and standard library function implementation, parse the target language bytecode program, bind instruction parameters and instruction implementations into a unified instruction object, and establish the program structure.
[0039] The state management module is used to verify the execution configuration, establish simulated values and initial path constraints, create a program state and object mapping table, and initialize the state queue and exploration record.
[0040] The simulation execution module is used to invoke instructions, calculate and submit execution results, and repair and maintain program state isolation through object mapping tables, copy-on-write, and lazy references.
[0041] The symbolic execution module is used to process conditional expressions, register and solve candidate paths, complete assignment verification, recreate or copy program states according to preset execution strategies, and associate path verification records.
[0042] The exploration and analysis module is used to schedule program states and candidate paths so that subsequent states can continue to execute. After the exploration is completed, the unfinished analysis scope is sorted out, analysis results are generated, and verification records are associated.
[0043] See appendix Figure 2 This invention provides a method for constructing a multilingual symbolic execution framework based on bytecode simulation, comprising the following steps: S1, the language adaptation module prepares the bytecode loader, instruction implementation and standard library function implementation, parses the target language bytecode program, binds the instruction parameters and instruction implementation into a unified instruction object, and establishes the program structure.
[0044] S2, the state management module verifies the execution configuration, establishes simulated values and initial path constraints, creates a program state and object mapping table, and initializes the state queue and exploration record.
[0045] S3 simulates the execution of module call instructions, calculates and submits execution results, and repairs and maintains program state isolation through object mapping tables, copy-on-write, and lazy references.
[0046] S4, the symbolic execution module processes conditional expressions, registers and solves candidate paths, completes assignment verification, recreates or copies program states according to the execution strategy, and associates path verification records.
[0047] S5 explores and analyzes the status and candidate paths of the module scheduler, enabling subsequent states to continue execution; after the exploration is completed, it organizes the unfinished analysis scope, generates analysis results, and associates them with verification records.
[0048] The technical solutions in the embodiments of the present invention will be further explained below in conjunction with the specific processing procedures.
[0049] See appendix Figure 3 In this embodiment, step S1 is executed through the language adaptation module, and specifically includes the following sub-steps: S101, the language adaptation module obtains the target language, bytecode specification, and preset bytecode version range, establishes an execution record, determines the target bytecode type based on the identifier data specified in the bytecode specification, prepares the bytecode loader and instruction implementation, registers the bytecode loader to the project factory, and establishes the bytecode loader mapping relationship. During registration, it checks whether the same version of the same target bytecode type corresponds to different bytecode loaders. If a conflict exists, the reason for the failure is written to the execution record, and the registration for that item is stopped.
[0050] The bytecode specification clarifies the target language semantics, instruction semantics, and runtime checking requirements. Operand access rules specify the storage location and reading method corresponding to instruction parameters; arithmetic rules specify the arithmetic type, integer bit width, sign attribute, and overflow handling; condition judgment rules specify the truth value determination of specific conditions and the construction method of sign conditions.
[0051] The instruction implementation uses a unified calling interface to receive program status and instruction parameters, generate execution results to be submitted, and save the calculated values, status modifications, successor positions, and applicable conditional expressions. Status modifications record the modification position and value; function calls record the function identifier and operands; runtime checks record normal execution conditions and abnormal termination conditions; when branching conditions exist, the successor positions and status modifications for true and false branches are saved respectively. Status modifications are not submitted during execution result generation; the program state before the decision is retained. Execution result submission rules stipulate: Update variable values and other storage locations, maintain program frames and call contexts, update applicable concrete value mappings and symbolic value mappings, and then update the program counter and execution log.
[0052] Determine whether to enter the loop body corresponding to the loop entry based on the actual submitted position, and update the loop count; the same entry is counted only once.
[0053] The bytecode version range is based on the version settings that the bytecode loader can parse and the instruction implementation can support.
[0054] For the registration of plug-ins in the project factory, those skilled in the art can use the registry to save the corresponding relationship. The registration operation is a well-known technology in this field and will not be described in detail here.
[0055] S102, the language adaptation module obtains the standard library function requirements, prepares the standard library function implementations according to the standard library function identifiers, and establishes the standard library function mapping relationship. The standard library function requirements specify the operand types, return value types, status modification requirements, and methods for reading data from external calls.
[0056] The standard library functions receive operands and program state, and read external call data from the execution environment according to the standard library function identifier and calling order, as required by the standard library functions. The read position is stored in the program state, and the progress of the read position is first saved to the state modification result, and updated when the execution result is committed; the state is inherited when copied, and reset when the program state is recreated; the execution environment used for initialization is not modified with each call.
[0057] When a concrete value is involved in the operation, the return value is calculated. When a symbolic value exists, the corresponding operation and operands of the function are combined into a symbolic expression according to the implemented symbolic operation relationships. The mixed symbolic execution strategy calculates the corresponding concrete value simultaneously. Unimplemented symbolic processing is treated as unsupported operations. When conditional judgments are involved, a conditional expression is generated, and the return value and status modification result are saved to the execution result to be submitted.
[0058] The operations covered by the summary instruction implementation and standard library function implementation are used to form the operation support range. Operations required by the bytecode specification but not yet implemented, as well as the handling of uncovered symbol values, are written into the unsupported operation record for execution checks.
[0059] S103, the language adaptation module receives the target language bytecode program, uses bytecode parsing to read the file header, version and format, reads the identification data from the file header, identifies the target bytecode type through the project factory based on the identification data, and matches a bytecode loader that matches the target bytecode type and the version belongs to the corresponding bytecode version range according to the bytecode loader correspondence.
[0060] The system checks whether the version falls within the bytecode version range, whether the identifier data and format conform to the bytecode specification, and whether the data range exceeds the file length, generating a verification result for the load check. If the match is successful and the verification result is passed, the system parses the program data, constant table, function definitions, and instruction sequences, and checks whether constants and function references point to valid locations.
[0061] When the target language is Lua, sub-function prototypes are recursively parsed according to the number of sub-functions recorded in the function prototype record, parent-child relationships are saved, and a function prototype tree is built. When the target language is Move, modules and structs are parsed, function prototypes are built according to function definitions, and the association between modules and structs, as well as the association between modules and functions, are saved. If matching fails, validation fails, or parsing fails, the reason for failure and the reason for termination are written to the execution record, and loading ends.
[0062] S104, the language adaptation module parses the instruction parameters according to the instruction encoding, matches the corresponding instruction implementation, and binds the instruction parameters and instruction implementation into a unified instruction object; unmatched operations are written into the unsupported operation record, and the corresponding unified instruction object still saves the instruction encoding and instruction parameters, retains the original instruction position, and terminates the program state when the execution check finds that the operation is not supported, without calling the instruction implementation.
[0063] An instruction list is created according to the original instruction order. The instruction list and constant list are associated with the function prototypes, and the function identifiers are saved. Lua generates function identifiers according to their positions in the function prototype tree, while Move generates function identifiers according to the positions of modules and function definitions, ensuring that the function identifiers are unique in the program structure.
[0064] A unified instruction object that has been matched retains the original instruction parameters and the corresponding instruction implementation. During execution, the instruction parameters and program state are passed to the instruction implementation. Different target languages use their own operand access rules and arithmetic rules, but share the same analog value representation and program state representation.
[0065] The branch jump target is determined according to the bytecode specification: for absolute jumps, the target location is read; for relative jumps, the offset is converted to the specified unit and added to the base location. A correspondence is established between the original instruction location and the instruction list location, converting the branch jump target into a location in the instruction list for use by the program counter. If the target location does not correspond to a valid instruction, the failure reason and termination reason are saved, and loading ends.
[0066] Based on program data and structures, data types and field information are determined, and the field order and type are saved. Control flow analysis is used to establish the succession relationship of instructions, identify loop bodies and record loop entry points, and save the corresponding control flow relationships for identifying initial entry and re-entry caused by bounces; re-entry is also counted in the loop count. Lua's function prototype tree and instruction list are summarized into the program structure; Move's modules, structures, and relationships are summarized into the program structure, and the instruction list of each function is saved for use in finding execution entry points and executing instructions.
[0067] See appendix Figure 4 In this embodiment, step S2 is executed through the state management module, and specifically includes the following sub-steps: S201, the state management module obtains the execution entry identifier and execution environment, reads the execution strategy, preset symbolic variables, preset input value range and preset analysis target, and summarizes the preset execution instruction number limit, preset path number limit, preset loop count limit, preset recursion depth limit and preset analysis time limit to form exploration constraints.
[0068] Match the function identifier with the execution entry identifier to determine the execution entry point and input variables. Read global variables, heap objects, captured variables, external call data and specific values from the execution environment. Check whether the initialization information meets the data requirements of the function prototype and instructions, whether the symbolic variables belong to the input variables, and whether the execution strategy is selected as a mixed symbolic execution strategy or a static symbolic execution strategy.
[0069] Numeric inputs read preset lower bounds, preset upper bounds, and preset interval types. Discrete inputs read preset value sets, checking whether the boundaries and value sets conform to the data type and allow non-empty values. For open boundaries of integer intervals, the lower bound is incremented by 1 or the upper bound is decremented by 1; closed boundaries retain their original values. Conversions are performed using integer calculations not limited by the target integer bit width, and the intersection with the value range of the target data type is calculated. The minimum value after conversion must not exceed the maximum value. For floating-point intervals, only representable values that satisfy the boundary checks in the target floating-point format are allowed. Each input range check is combined using a logical AND relation to form initial path constraints.
[0070] The analysis target reads preset judgment fields, preset comparison operators, preset comparison values, and preset logical combinations. When vulnerability detection is involved, it reads preset vulnerability detection conditions with the same expression. It checks whether the judgment fields and comparison methods are applicable to the execution record. The analysis target uses information generated during the exploration period; it cannot determine whether to end the exploration solely based on analysis results generated after the analysis is completed. If any configuration check fails, the verification result and termination reason are saved, and initialization is stopped.
[0071] The execution strategy and symbolic variables are selected based on the analysis task. The range of input values and their boundaries, interval types and value sets are set based on the data type and input conditions. The analysis targets and vulnerability detection conditions are set based on the inspection requirements. The exploration limits are set based on computing resources and analysis time. The quantity and depth limits are set using positive integers, and the analysis time limits are set using positive numbers.
[0072] In S202, the state management module determines the supported data type range based on the simulated value representation method, checks the input data type, and establishes a simulated value and type flag if it passes; otherwise, it saves the verification result and termination reason, and stops initialization. Data is represented using immutable values, undefined values, mutable values, and references. Lua tables use untyped arrays and untyped associative arrays, Move structures use typed arrays, field access rules determine the access position according to field order, and function closures associate function prototypes and captured variables.
[0073] Boolean logic is used to represent symbolic Boolean values, bit vector theory is used to represent symbolic integers while preserving the integer bit width and symbolic attributes, floating-point theory is used to represent symbolic floating-point numbers while preserving the floating-point format, and string theory is used to represent symbolic strings; symbolic arrays and symbolic associative arrays store symbolic values, and index access rules and key access rules are determined based on the semantics of the target language.
[0074] Open intervals must be greater than the lower bound and less than the upper bound; closed intervals must be no less than the lower bound and no greater than the upper bound; left-open and right-closed intervals must be greater than the lower bound and no greater than the upper bound; left-closed and right-open intervals must be no less than the lower bound and no greater than the upper bound; discrete inputs must belong to the set of values.
[0075] The hybrid symbolic execution strategy checks that the concrete values are complete and satisfy the initial path constraints. The concrete value mapping associates the input variables and concrete values, and the symbolic value mapping associates the symbolic variables and symbolic values to form concrete inputs. The symbolic variables used for initialization use the corresponding symbolic values, and their concrete values are retained through concrete value mapping for use in concrete operations and condition determination.
[0076] The static symbolic execution strategy uses symbolic values to represent symbolic variables, and the remaining inputs use verified concrete values. When all inputs are concrete values, concrete inputs are formed.
[0077] In the initial path constraints, the range judgment of symbolic variables is retained as a symbolic expression, and the remaining inputs are substituted with fixed specific values.
[0078] Symbolic variables are assigned fixed symbolic variable identifiers, which are used when the program state is recreated; input assignments and values at the current storage location are saved separately, and local variable updates do not overwrite the original input assignments. When input validation fails, the validation result and termination reason are saved, and initialization is stopped.
[0079] In S203, the state management module creates a program frame based on the execution entry point and simulated values, storing local variables, operand stack, program counter, and execution object. The execution object is associated with function prototypes and applicable function closures. Lua register locations correspond to local variables, the Move operand uses the operand stack, and the program counter points to the first instruction at the execution entry point.
[0080] The program frame is added to the program frame stack. Global variables, heap objects, and the program frame stack are saved by simulating the state. The program state is created in combination with the initial path constraints. The calling context is formed according to the function identifiers and call positions in the program frame stack, and the existing specific inputs are associated.
[0081] When copying mutable data, global variables, heap objects, input and captured variables share the same copy mapping. The copy mapping is established according to the object identity. The copied object is registered first, and then the internal data is copied. Repeated references and circular references use the registered object.
[0082] An object identifier is set for the copied mutable value, and the object identifier and object are associated through an object mapping table. References store the object identifier and the accessed object, while array references also store the access location. Related references in program frames, global variables, heap objects, and captured variables are replaced with references to the copied object, preserving the access location of array references. New mutable values created during execution are also assigned unused object identifiers. New objects and their registered contents during the execution result generation phase are temporarily stored in the execution result. Upon commit, they are first registered in the object mapping table of the target program state, and then reference writing and other state modifications are performed.
[0083] State copying and copy-on-write preserve object identifiers. The object pointed to by a reference is identified by the object identifier, and the position pointed to by an array reference is identified by both the object identifier and the access position. Reference comparisons are processed according to the semantics of the target language and are not judged based on the identity of the object after copy-on-write.
[0084] S204, the state management module establishes a state queue, an end state set, and a candidate path record, sets the initial execution path to empty, establishes the association between the program state and the execution record, adds the initial program state to the state queue, reads the time and saves the analysis start time, and initializes the number of executed instructions, the number of paths, the number of iterations of each loop, and the recursion depth to 0.
[0085] The hybrid symbolic execution strategy writes the initial path constraints into the existing constraint set, and initializes the new constraint set to empty. The expected path prefix for the first execution is empty, and the path verification status is recorded as verified and the verification result as passed. A sub-expression cache and a solution result cache are established. The branch checking rules compare the branch position and jump direction item by item, and check the number of conditions. Specific conditions are checked according to their corresponding branch positions and jump directions. Symbolic conditions also need to compare the operation type, type semantics, operands, and symbolic variable identifiers of the conditional expression, but not the storage address of the expression object.
[0086] When copying a program state, program frame data, references, path constraints, call context, and object mapping tables are maintained separately. The storage locations of global variables, concrete value mappings, symbolic value mappings, existing constraint sets, new constraint sets, and path verification progress in the simulation state are also copied separately. Modifiable storage locations cannot be shared with other program states. Execution paths and loop counts are inherited, and objects not yet written are shared and their identifiers are retained. Object mapping table updates are limited to the current program state. Execution records save execution strategies and input representation methods.
[0087] See appendix Figure 5 In this embodiment, step S3 is executed by the simulation execution module, and specifically includes the following sub-steps: S301, the simulation execution module retrieves the program state from the state queue and determines a unified instruction object based on the program counter and instruction list. The static symbolic execution strategy copies the program state and executes one instruction at a time, while the hybrid symbolic execution strategy executes instructions sequentially along the direction determined by the specific value.
[0088] Before execution, update the recursion depth according to the maximum number of repeated calls to the same function in the program frame stack, and update the analysis time by subtracting the analysis start time from the current time. Write the current number of executed instructions, number of paths, number of loops, recursion depth, and analysis time into the execution record, and then check the analysis target according to the comparison method in step S501.
[0089] If the analysis objective is not met and the number of executed instructions, loop count, recursion depth, and analysis time all fall below their respective limits, check if the operation falls within the scope of operation support. Before calling the instruction, copy and retain the program state before the decision. If it passes, call the instruction, record the instruction location and program state of this call in the execution record, and update the number of executed instructions. The record of this call is supplemented upon subsequent submissions, abnormal terminations, or interruptions, without duplicate recording of instruction calls.
[0090] The loop count is updated when the execution result is submitted. Unsupported operations are written to the unsupported operation record, the reason for incomplete analysis is saved, and the program state is terminated; when the exploration conditions are not met, the program state and the reason for the exploration ending are saved, and the exploration ends. Interrupted program states, their execution paths, path constraints, and reasons are associated with the execution record, but are not added to the termination state set as completed program states.
[0091] S302, the simulation execution module queries the object mapping table of the current program state based on the object identifier to determine the object to be accessed. If the object identity stored in the reference is inconsistent with the query result, a delayed reference is used to repair and update the reference; if the reference is located inside a shared object, the object carrying the reference and its references are copied, the object mapping table of the current program state is updated, and then the reference is repaired.
[0092] Check the state queue, end state set, candidate path record, and object mapping table in the program state retained by the current instruction. If there are program states other than the current program state that associate the same object identifier with the same object identity, use copy-on-write; otherwise, use direct write.
[0093] Array access uses index access rules, associative array access uses key access rules, and structure access uses field information and field access rules to determine the access location. The specific index or key directly determines the access location; symbolic indexes or keys are only processed within the scope where corresponding symbol read and write operations have been implemented.
[0094] For type-compatible, limited access positions, construct indices or conditions where the key equals each position. During reading, this forms a symbolic expression to select the corresponding element; during writing, it forms a conditional expression that retains the original value or adopts the value to be written. If no position is matched, generate a default result or an exception condition according to the target language semantics. When reading a non-existent key in a Lua table, generate a simulated value representing nil. If the default result cannot be incorporated into the implemented symbolic representation, or if the symbolic key addition operation has not yet been implemented, treat it as an unsupported operation.
[0095] All other cases are treated as unsupported operations. When it is necessary to check the validity of access, runtime check conditions are generated. If the check fails, invalid locations are not read. When an object mapping query fails, the exception information, the reason for the incomplete analysis, and the program status are saved, and the analysis of the program status is terminated. Missing object mappings within the framework are not directly recorded as an exception occurring in the program.
[0096] Save the write method, object identifier, access location, and simulated value to be written to the execution result, without committing the status modification in advance.
[0097] S303, the simulated execution module is implemented through instructions. It reads operands according to operand access rules and generates calculated values based on type markers and operation rules. When all operands are concrete values, concrete operations are performed; when symbolic values exist, symbolic expressions are constructed. A hybrid symbolic execution strategy maps concrete values to their corresponding values while simultaneously calculating concrete values; a static symbolic execution strategy preserves the symbolic expressions. Pops from the operand stack and other state modifications are recorded in the execution result and executed upon submission.
[0098] Integer arithmetic preserves the integer bit width and sign attribute. Taking integer addition requiring overflow checking as an example, the operands are interpreted as integers according to their sign attribute, the uncrunted sum is calculated, and compared with the value range of the corresponding type. Calculating 2 raised to the power of its integer bit width: for unsigned integers, the lower bound is 0, and the upper bound is the value minus 1; for signed integers, the value is divided by 2, with the lower bound being the opposite of the quotient and the upper bound being the quotient minus 1.
[0099] For signed integer addition requiring overflow checking, extend both operands by one bit: zero extension for unsigned integers and sign extension for signed integers. Summate within the extended bit width and compare the result with the range of values within the same extended bit width. Do not submit the truncated result until the check passes; after passing the check, save the calculated value according to the target integer bit width. Integer operations not requiring overflow checking are processed according to the target language semantics.
[0100] Standard library function calls match the standard library function implementation based on the standard library function identifier, and incorporate the return value and status modification results into the execution result. Function calls obtain the function identifier from the function closure or the function definition specified by the instruction, determine the function prototype through the function prototype tree or the association between the module and the function, save the call content to be submitted, and for closure calls, save the corresponding function closure at the same time. When a match fails, save the reason for the incomplete analysis and terminate the program state.
[0101] The successor position and branch conditions are generated based on the instruction semantics. Normal execution conditions are generated based on runtime check requirements. The inverse of these conditions is used as an exception termination condition. Applicable conditional expressions are saved to the execution result.
[0102] S304, the simulated execution module submits the execution result for instructions without runtime check conditions and without branch conditions according to the execution result submission rules. The remaining instructions are transferred to condition processing. The execution result for the normal execution direction is submitted after the judgment.
[0103] Upon submission, based on the actual direction or target direction of the candidate path, select the corresponding successor position and status modification content, then review the object sharing situation. When writing, copy the object and its references, retaining the object identifier of internal references, and update the object mapping table of the current program state before writing; when writing directly, modify the queried object. Other program states retain their own object mapping tables, and references within the same program state access the updated object through object identifiers and delayed references.
[0104] According to the function call rules, the successor position after the return is saved, a program frame is created and operands are written, the closure call associates the corresponding function closure with the execution object of the new program frame, and the program frame stack and calling context are updated; according to the function return rules, the heap object that is still referenced by the function closure is retained, the program frame is popped, the return value is written to the caller and the successor position is restored.
[0105] Closure creation saves captured variables and their storage location relationships according to the closure variable capture rules. Value capture saves simulated values. Reference capture searches for established array references based on the storage location in the current program frame. If they exist, they are reused; otherwise, the captured variables are saved as a single-element untyped array and registered as a heap object. The correspondence between storage location and array reference is saved in the program frame data.
[0106] Local variables and function closures access the same location through the same array reference, maintaining the reference association when both capture the same storage location.
[0107] Update the applicable specific value mapping and symbolic value mapping, then update the program counter, add the current instruction position, successor position and calling context to the execution path, and associate it with the information generated by condition processing as the information of the same instruction execution; the information of actually entering the loop entry point is also saved.
[0108] The execution path, function calls, and state changes are written to the execution record. State changes save the modification location and copies of the values before and after the modification, without directly referencing objects that will be modified later.
[0109] When the program frame corresponding to the entry point returns, the applicable path is verified using the branch check rules, the normal termination condition is recorded, and the program state is added to the termination state set; the remaining program states continue to execute or are added to the state queue according to the execution strategy.
[0110] See appendix Figure 6 In this embodiment, step S4 is executed by the symbolic execution module, and specifically includes the following sub-steps: S401, the symbolic execution module processes conditional expressions according to conditional judgment rules. The hybrid symbolic execution strategy maps conditions to specific values. If runtime checks exist, it first checks the normal execution condition; if successful, it determines the applicable branch condition; otherwise, it terminates due to an exception. When a condition is true, it is used; when false, its negation is used. Symbolic conditions are retained. The branch position is determined by the function identifier, the position of the instruction list within the function, and the calling context. The actual used condition, branch position, and jump direction are written into the execution path. The actual used condition is combined with the current path constraints using a logical AND relationship.
[0111] When re-executing, the path prefix is checked according to the branch check rules. Matching conditions are not repeated and are written into the new constraint set. Conditions generated after the check are written into the new constraint set. If there is a discrepancy, the program state is terminated and the reason for the verification failure is saved.
[0112] For normal execution, the execution result is submitted according to the execution result submission rules. For abnormal termination, the applicable path is checked, the exception record is saved and added to the termination status set.
[0113] The static symbolic execution strategy applies the same order to specific conditions, but if there are still undetermined symbolic conditions for the same instruction, it does not submit the execution result. Instead, it retains the program state before the determination and constructs candidate paths based on the determined specific conditions. If all conditions are specific conditions and pass normally, it submits the execution result only once. Program states that can continue execution are either allowed to continue execution according to the execution strategy or added to the state queue.
[0114] S402, after the program state of the hybrid symbolic execution strategy ends and the path verification is passed, the symbolic execution module selects the symbolic conditions that have not yet been registered in the reverse target direction, retains the path prefix before the target branch, only negates the actual conditions recorded in the execution path, discards subsequent conditions, and combines them with the initial path constraints according to the logical AND relationship.
[0115] The static symbolic execution strategy extracts the adopted conditions, branch positions, and jump directions sequentially from the execution path of the program state before the decision, forming a path prefix, and determines the current branch position in the same way as the hybrid symbolic execution strategy.
[0116] Combine the path constraints before the decision with the branch conditions and their negation conditions respectively; when there are runtime check conditions, construct the target direction corresponding to the abnormal termination condition, as well as the target direction of the combination of the normal execution condition and the applicable branch conditions; when there are no branch conditions, only combine the normal execution conditions.
[0117] Deduplication is performed based on branch position, ordered path prefix, and target direction. If no match is found and the number of paths is less than the path limit, candidate paths are registered. The candidate path record stores the branch position, path prefix, target direction, path constraints, and the ordered conditions corresponding to the target direction.
[0118] The hybrid symbolic execution strategy only saves the inverted target conditions and does not save conditions that already belong to the path prefix again. The static symbolic execution strategy saves the conditions corresponding to the target direction according to the decision order of this instruction. At runtime, it checks the conditions before the branch conditions and associates the branch position and jump direction of each condition. The processing status is pending, and the number of paths is updated.
[0119] The hybrid symbolic execution strategy is associated with the execution environment, while the static symbolic execution strategy is associated with the program state before the judgment and the subsequent position. The execution results are copied separately, and the references and newly created variable values that have not yet been registered are copied. Existing objects are still accessed through object identifiers, and symbolic expressions are kept shared. When committing, the relevant references are resolved based on the object mapping table of the target program state.
[0120] When the path limit is reached, no new candidate paths will be registered. Unprocessed target directions and the reasons for the limitation will be written into the execution record. The registered candidate paths and generated program states will continue to be processed. When the exploration ends, these target directions will be included in the scope of incomplete analysis.
[0121] In S403, the symbolic execution module updates the analysis time and checks exploration limitations. If continued is allowed, constraint independence partitioning is used, grouping constraints that directly or indirectly share symbolic variables, depend on the same symbolic array, or symbolic associative array into the same independent subset of constraints. Conditions without symbolic variables are directly evaluated; if false, the satisfiability result is recorded as unsatisfiable, saved to the candidate path record, and the process moves to unsatisfiable result handling, without executing cached queries or SMT solutions.
[0122] The type semantics are determined based on the type marker and the target language semantics, and the constraint content is formed by combining the expression and symbolic variable identifiers. The definition relations on which the expression depends and the array read and write relations are also included in the constraint content.
[0123] When subexpressions and type semantics are consistent, the subexpression cache is reused. First, the solution result cache of the complete path constraint is queried. If a match is found, the corresponding satisfiability result is set. If satisfiable, the specific value is obtained, assigned, and the complete path constraint is checked without further item-by-item solving. If no match is found, the solution result cache of the independent subset constraint is queried separately. The complete path constraint and the independent subset constraint are queried and written separately, using the same constraint unit.
[0124] When a cache miss occurs, the time is reread and the analysis time is updated before each SMT solver call. The solution duration is then limited by subtracting the analysis time limit from the analysis time limit. If no time remains, the exploration ends and the reason is saved. When checking exploration limits, the path number limit is only used for candidate path registration and does not prevent the solution of registered candidate paths.
[0125] If any set is unsatisfiable, the satisfiability result is marked as unsatisfiable; if all sets are satisfiable, the satisfiability result is marked as satisfiable, and the specific values are merged and assigned. If all conditions are true and there are no independent subsets of constraints, the satisfiability result is also marked as satisfiable. Only when the satisfiability result is satisfiable is the assignment completed and validated: symbolic variables not appearing in the constraints are filled with a value of a type that can be represented within the input value range; the remaining inputs retain their initial specific values, are substituted into the complete path constraints, and if all conditions are met, the assignment validation is recorded as passed. Assignment validation is not performed when the result is unsatisfiable or the solution is incomplete.
[0126] The cache assignment uses the same validation, caching successful assignments or unsatisfiable results according to the corresponding constraint unit. The cache for independent subset constraints only stores the solution results and corresponding assignments for that subset, without writing the overall result as the result for each subset. If the overall unsatisfiability is not yet determined, and there are timeout, failed, or unknown subsets, the processing status is recorded as "incomplete solution"; if the overall unsatisfiability is determined, the unsatisfiable result is retained. A failed assignment validation is recorded as a solution result validation failure, and the solution result, satisfiability result, specific value assignment, processing status, and validation result are saved to the candidate path record.
[0127] S404, when the satisfiability result is satisfiable and the assignment verification passes, the symbolic execution module reverts the specific values to the specific inputs according to the input variables and data types. Unsymbolized inputs retain their initial specific values.
[0128] The hybrid symbolic execution strategy determines the specific value of the symbolic variable with the newly generated specific input, restores the remaining initialization data from the execution environment, recreates the program state according to the initialization method of steps S202 and S203, rebuilds the specific value mapping, symbolic value mapping and object mapping table, resets the loop count, sets the new constraint set to empty, and retains the symbolic variable identifier of the symbolic variable.
[0129] The initial path constraints, path prefixes, and negation conditions are written into the existing constraint set. Input range constraints are used for input validation. The path prefixes in the candidate path records are concatenated with the ordered conditions corresponding to the target direction, and together with the branch positions and jump directions, the expected path prefixes are formed. Input range constraints are not included in the verification sequence. The path verification progress is initialized to 0, the path verification status is initialized to pending verification, the program counter points to the first instruction at the execution entry point, and the program status is added to the status queue. The number of executed instructions, the number of paths, the analysis start time and execution records, candidate path records, subexpression cache, and solution result cache remain unchanged in this analysis.
[0130] The static symbolic execution strategy copies the associated program state, preserving local variables, operand stacks, heap objects, call contexts, and loop counts. It associates the specific inputs without replacing symbol values and updates the execution path and path constraints. For normal execution directions, the corresponding successor position and state modification content are selected based on the target direction. The execution result is submitted according to the execution result submission rules and added to the state queue. For directions ending abnormally, the normal execution state modifications are not submitted; instead, the exception record is saved and added to the termination state set.
[0131] Associate candidate paths with program status, and process the status as "Generated Program". During subsequent execution of the generated program status, update the path verification record. Upon re-execution, only check the expected path prefixes. If all prefixes match, the verification status is "Verified" and the verification result is "Passed". If conditions are inconsistent or verification was incomplete at the end, it is "Verified but Passed". If the analysis objective is met, exploration is limited, or the operation is interrupted, it is "Pending Verification", and the reason for incomplete analysis is saved. If the objective cannot be met, the processing status is "Unsatisfied"; otherwise, the corresponding processing status and reason are retained.
[0132] See appendix Figure 7 In this embodiment, step S5 is executed through the exploration and analysis module, and specifically includes the following sub-steps: S501, the exploration and analysis module updates the number of executed instructions based on the number of records where instructions were actually called in the execution record, and updates the number of paths based on the number of duplicate entries in the candidate path record. It enters the record for the loop entry point in the execution path of the current program state to count the number of loops in each loop, and determines the recursion depth based on the maximum number of repeated calls to the same function in the program frame stack. The recursion depth is 0 when the program frame stack is empty. The analysis time is calculated by subtracting the analysis start time from the current time. The updated statistics are written to the execution record for use in determining the analysis target.
[0133] The execution record is read according to the judgment field of the analysis target. The corresponding information is compared with the comparison value according to the comparison operator, and then the check status is generated according to the logical combination relationship. If the information required for the judgment is not generated, the check status is recorded as unsatisfied.
[0134] If the analysis objective is not met and the number of executed instructions, loop count, recursion depth, and analysis time have not reached their respective limits, the program states in the state queue are prioritized for scheduling. If the state queue is empty, candidate paths with pending processing status are scheduled in the order of registration for path constraint solving and program state generation. Even when the number of paths reaches the path limit, already registered content can still be processed. After processing, the execution record and candidate path record are updated, the exploration conditions are rechecked, and candidate paths that have not been solved or have failed verification are not rescheduled.
[0135] S502, the exploration and analysis module terminates its exploration when the analysis objective is met, the state queue and the set of candidate paths yet to be processed are empty, or any of the following limits are reached: number of executed instructions, number of loops, recursion depth, and analysis time. The reason for termination is saved. Target directions not registered due to path quantity limitations are retained in the incomplete analysis scope.
[0136] By combining the state queue, the set of ending states, the candidate path record, and the execution record, we organize the unprocessed program states, candidate paths, and target directions. Based on the processing status, verification status, and verification results, we distinguish between incomplete solution, failed assignment verification, failed path verification, and incomplete path verification. We also include interruptions caused by unsupported operations in the scope of incomplete analysis.
[0137] When loading or initialization terminates, the reason for the end of the exploration and the scope of incomplete analysis are determined based on the reason for termination. Only the established execution records and status management information are read, and the status queue, end status set or candidate path record that has not yet been established are not accessed. When the content to be processed is empty, the existing failure and incomplete records are still retained.
[0138] S503, the exploration and analysis module generates input conditions once the input value range and initial path constraints have been established. When the end state set has been established, it checks the specific inputs associated with each execution path, substitutes these specific inputs into the input conditions and final path constraints, and uses the corresponding specific inputs if the verification passes; otherwise, it saves the verification results. If loading or initialization terminates and the corresponding information has not yet been formed, it only outputs the existing reasons and the incomplete analysis range.
[0139] When there are symbolic variables but no valid specific input, update the analysis time. If there is remaining analysis time, process the final path constraints according to the overall cache lookup, independent subset constraint solution, value completion, and complete path constraint verification process in step S403. Unsymbolized inputs are not changed by value completion. If the cache is missed, call the SMT solver and limit the solution time by subtracting the analysis time limit from the analysis time limit.
[0140] When the satisfiability result is satisfiable, specific values are assigned using either the overall cache or by merging independent subset constraints. The assignment is then completed and verified according to step S403. Unsymbolized inputs remain unchanged. Once verification passes, specific inputs are formed. Records are saved for cases of unsatisfiability, timeout, failure, unknown, or verification failure. The solution is not started if there is no remaining analysis time. In all the above situations where no valid specific input is obtained, the corresponding execution path is included in the incomplete analysis scope.
[0141] Associate valid specific inputs, execution environment, and execution path with test cases, and save the input conditions and final path constraints; when no valid specific input is obtained, retain the execution path, path constraints, and corresponding reasons, and do not generate test cases.
[0142] Instruction execution relationships are formed based on instruction location and execution sequence, and function call relationships are formed based on function call and return records. Common prefixes of execution paths are compared according to instruction location, conditional expressions, jump direction, and call context. Corresponding nodes in the symbolic execution tree are merged, and different target directions are connected at branch points. Nodes store the state changes of each program state, and the ending position is associated with normal or abnormal termination records. Instruction execution relationships, function call relationships, path constraints, and state changes are linked to the program structure to form reverse analysis results.
[0143] Before vulnerability detection, based on the execution strategy, input representation, and the completeness of the execution log, the path that completes the execution using full and specific input is identified. It is then verified whether the specific input meets the final path constraints and whether the termination condition is consistent with the program frame return or exception record. If associated candidate paths exist, it is also necessary to verify whether the actual conditions match their path prefix and target direction. If no associated candidate paths exist during the first execution, verification is completed based on the specific input, actual conditions, and the final path constraints.
[0144] Upon completion of the verification, the verification status of the specific execution verification is marked as "verified," and the verification result is either "pass" or "fail." Paths that only completed symbolic execution or were not fully executed are marked as "pending verification." The verification status, verification result, and corresponding execution path are saved as a specific execution verification record for subsequent vulnerability detection and analysis result summarization. Assignment verification does not replace specific execution verification.
[0145] When vulnerability detection is involved, the corresponding information is read according to the vulnerability detection conditions. The specific execution path is represented by the specific inputs substituted into the symbolic expression. Other paths that pass the assignment verification are represented by the specific values substituted into the expression. The check results are generated according to the comparison operators, comparison values, and logical combination relationships. When the conditions are met, the vulnerability detection results and the corresponding execution path are saved, and the specific inputs or specific value assignments and specific execution verification records are associated with them. When the judgment information is missing, the reason for the incomplete analysis is saved and included in the scope of incomplete analysis, but no conclusion of no vulnerability was generated based on this.
[0146] The generated test cases, input conditions, path constraints, instruction execution relationships, function call relationships, symbolic execution trees, reverse analysis results, and applicable vulnerability detection results are summarized into analysis results, and associated with various verification records, exploration termination reasons, and updated incomplete analysis scope.
[0147] To further aid in understanding the technical solutions of the embodiments of the present invention, a specific application example is given below.
[0148] The target language is Lua, with the bytecode version limited to 5.4. The execution entry point identifier corresponds to the entry function. Input variables x and y are both integers and are used as symbolic variables, with a lower bound of 0 and an upper bound of 15, and the interval type is a closed interval. The initial specific input for the hybrid symbolic execution strategy is x = 3 and y = 4, while the static symbolic execution strategy uses the same input value range.
[0149] The number of executed instructions is limited to 100,000, the number of paths is limited to 32, the number of loops is limited to 16, the recursion depth is limited to 8, and the analysis time is limited to 60 seconds. The judgment field for the analysis target is the number of records that have ended normally, the comparison operator is equal, and the comparison value is set to 4.
[0150] The target language bytecode program sequentially checks whether the sum of x and y is not less than 16, and whether x plus 1 equals y, recording the results and returning normally. The language adaptation module establishes a unified instruction object, the state management module establishes initial path constraints, the simulation execution module generates conditional expressions, and the symbolic execution module constructs and solves candidate paths. The initial specific inputs correspond to the following judgment results: false and true, respectively. After inverting the second condition, x becomes 3 and y becomes 5, satisfying the corresponding path constraints. The hybrid symbolic execution strategy recreates the program state and checks the path prefix accordingly, while the static symbolic execution strategy copies the program state before the judgment and submits the execution results in the target direction.
[0151] Verification employs exhaustive input calculation and state isolation simulation. For each of the 256 input groups, calculations are performed, and the number of inputs with the following results—false-false, false-true, true-false, and true-true—are 128, 8, 113, and 7 respectively. These results are used to verify path constraints and the generated test cases.
[0152] State isolation simulation generates four program states from the same initial object set. Each variable value stores 16 array elements, and each program state modifies only one variable value. In contrast, the control method copies all variable values when creating a program state; this method maintains separate object mapping tables, shares unwritten objects, and copies the corresponding variable values when writing. Only the array elements copied during program state creation and each write operation are counted, ignoring the creation of the initial object set. After writing 1, 2, 3, and 4 to the four program states respectively, each stores its corresponding value, and the initial object remains 0. Both methods pass the write isolation check.
[0153] See appendix Figure 8 The comparison method uses solid lines with circular markers, corresponding to 256, 512, 1024, and 2048; this method uses dashed lines with circular markers, all corresponding to the value 64, without color differentiation.
[0154] The above verification shows that, under the condition that only one variable value is written to each program state in this embodiment, this scheme maintains write isolation, and the total number of copied array elements remains at 64 as the number of variable values increases, which is 75% to 96.875% less than the control method. This result demonstrates the effect of combining object mapping tables with copy-on-write to reduce array element copying.
[0155] While specific embodiments of the present invention have been described above, those skilled in the art should understand that these specific embodiments are merely illustrative. Those skilled in the art can omit, substitute, and modify the details of the above methods and systems in various ways without departing from the principles and essence of the present invention. For example, combining the above method steps to perform substantially the same function and achieve substantially the same result using substantially the same method falls within the scope of the present invention.
Claims
1. A method for constructing a multilingual symbolic execution framework based on bytecode simulation, characterized in that, Includes the following steps: Obtain the target language and bytecode specification, prepare the instruction implementation of the target language according to the bytecode specification, parse the target language bytecode program, bind the instruction parameters and the instruction implementation into a unified instruction object, and establish the program structure and execution record; The execution entry point is determined based on the program structure. The execution environment, preset execution strategy, and preset input value range are obtained. Based on the execution entry point and the execution environment, a mapping table of simulated values, program states, and objects is established using a shared simulated value representation and a shared program state representation. Initial path constraints are established based on the input value range. The instruction implementation of the unified instruction object is invoked, the simulated value is read from the program state as an operand, a symbolic expression is constructed when the operand contains a symbolic value, and the execution result and applicable conditional expression are generated; The conditional expression is processed according to the execution strategy. The execution result is submitted during normal execution. The program state isolation is maintained through the object mapping table. An execution path is formed according to the changes in the program state and written into the execution record. Candidate paths are constructed based on the execution path and the initial path constraints. The path constraints are solved and verified by assignment. The program state is generated according to the execution strategy and the exploration continues. After the exploration is completed, the analysis results are generated based on the execution records.
2. The method for constructing a multilingual symbolic execution framework based on bytecode simulation according to claim 1, characterized in that, The steps of binding instruction parameters to the instruction implementation into a unified instruction object include: The instruction implementation receives the program status and instruction parameters through a unified calling interface, and generates an execution result that includes the status modification content and the subsequent position.
3. The method for constructing a multilingual symbolic execution framework based on bytecode simulation according to claim 2, characterized in that, The step of reading the simulated value as an operand from the program state includes: The input variables are determined based on the execution entry point, the preset symbolic variables are read, symbolic variable identifiers are assigned to the symbolic variables, the simulated values of the symbolic variables are established with symbolic values, and the remaining input variables adopt specific values; The hybrid symbolic execution strategy establishes a concrete value mapping between the input variables and concrete values, and a symbolic value mapping between the symbolized variables and symbolic values. When all operands are specific values, specific operations are performed; when the operands include symbolic values, a symbolic expression is constructed and the specific values are calculated simultaneously.
4. The method for constructing a multilingual symbolic execution framework based on bytecode simulation according to claim 3, characterized in that, The steps for maintaining program state isolation through the object mapping table include: Copy the variable data in the execution environment, register the copied objects according to their object identities, then copy the internal data, reuse the registered objects by repeated references and circular references, assign object identifiers and associate them with the objects to establish the object mapping table, and save the object identifiers and the objects by reference; Establish a state queue, an end state set, and a candidate path record. When copying the program state, maintain the reference, storage location, and object mapping table respectively, and share objects that have not yet been written. Before writing, check the state queue, the end state set, the candidate path record, and the object mapping table in the program state retained by the current instruction. If other program states are still associated with the same object, copy and retain the object identifier during writing, update the object mapping table of the current program state, and then write; otherwise, write directly. When accessing, the object mapping table is queried according to the object identifier. If the object identity stored in the reference is inconsistent with the query result, delayed reference repair is performed. If the reference is located inside a shared object, the object carrying the reference and its references are copied, the object mapping table of the current program state is updated, and the reference is repaired.
5. The method for constructing a multilingual symbolic execution framework based on bytecode simulation according to claim 4, characterized in that, The steps of constructing candidate paths based on the execution path and the initial path constraints include: After the program state ends and the path verification is successful, the hybrid symbolic execution strategy combines the initial path constraints with the path prefix before the target branch and the inverse of the actual symbolic conditions to form the path constraints for the target direction. The static symbolic execution strategy preserves the program state before the symbolic condition is determined, extracts the path prefix from the execution path, and combines the path constraints before the determination with the branch conditions and their negation conditions to form the target direction. When runtime check conditions exist, the runtime check conditions are inverted to form the target direction for abnormal termination, and the target direction for normal execution combines the runtime check conditions and applicable branch conditions. The branch position is determined from the execution path, and duplicates are removed according to the branch position, the ordered path prefix and the target direction and saved to the candidate path record. The path constraints and the ordered conditions corresponding to the target direction are associated. The hybrid symbolic execution strategy is associated with the execution environment, while the static symbolic execution strategy is associated with the program state before the determination and a copy of the execution result.
6. The method for constructing a multilingual symbolic execution framework based on bytecode simulation according to claim 5, characterized in that, The steps for solving path constraints and performing assignment verification include: The path constraints in the candidate path record are read, and the two execution strategies use the SMT solver to solve and obtain the satisfiability results. The satisfiability result is obtained by assigning a specific value when it is satisfiable, filling in the missing values of the symbolic variables according to the input value range, keeping the unsymbolized input variables unchanged, substituting the complete path constraints, and writing the specific value assignment and the verification result of the assignment pass into the candidate path record when all are true.
7. The method for constructing a multilingual symbolic execution framework based on bytecode simulation according to claim 6, characterized in that, The steps for generating program state according to the execution strategy include: When the assignment verification passes, the specific value is restored to the specific input. The hybrid symbolic execution strategy recreates the program state using the specific input and the execution environment, rebuilds the specific value mapping, the symbolic value mapping, and the object mapping table, and retains the symbolic variable identifier; The static symbolic execution strategy copies the program state associated with the candidate path, preserves the simulation state, associates the specific input without replacing the symbol value, and updates the execution path and the path constraints according to the target direction. Associating the candidate path with the program state, the execution result is submitted when execution is normal, and added to the state queue when execution can continue. When an abnormal execution occurs, the normal execution state modification is not submitted, and the terminated program state is added to the termination state set.
8. The method for constructing a multilingual symbolic execution framework based on bytecode simulation according to claim 7, characterized in that, The step of generating the program state according to the execution strategy further includes: The hybrid symbol execution strategy concatenates the ordered conditions corresponding to the path prefix and the target direction to form the expected path prefix, and the input range constraints in the initial path constraints are not included in the verification sequence; When re-executed, the branch position, jump direction and number of conditions are checked against the expected path prefix. The symbolic conditions are also checked against the conditional expressions. When the check is completed or the program state ends, the verification status is "verified". If all are consistent, the verification result is "passed"; otherwise, the verification result is "failed". The verification status and the verification result are associated with the candidate path and the program status to form a path verification record.
9. The method for constructing a multilingual symbolic execution framework based on bytecode simulation according to claim 8, characterized in that, The steps for generating analysis results based on the execution records after the exploration is completed include: The analysis results are generated based on the execution path of the execution record and the path constraints of the candidate path record, and are associated with the path verification record.
10. A system for constructing a multilingual symbolic execution framework based on bytecode simulation, applied to the method for constructing a multilingual symbolic execution framework based on bytecode simulation as described in any one of claims 1-9, characterized in that, include: The language adaptation module is used to prepare instruction implementations according to the target language and bytecode specifications, parse the target language bytecode program, bind the instruction parameters and the instruction implementations into a unified instruction object, and establish the program structure and execution records. The state management module is used to determine the execution entry point according to the program structure, obtain the execution environment, the preset execution strategy and the preset input value range, establish a mapping table of simulated values, program states and objects based on the execution entry point and the execution environment using a shared simulated value representation and a shared program state representation, and establish initial path constraints according to the input value range. The simulation execution module is used to call the instruction implementation of the unified instruction object, read the simulation value as an operand, construct a symbolic expression when a symbolic value is included, generate the execution result and the applicable conditional expression, submit the execution result during normal execution, maintain program state isolation through the object mapping table, form an execution path according to the changes in the program state and write it into the execution record; The symbolic execution module is used to process the conditional expression according to the execution strategy, construct candidate paths according to the execution path and the initial path constraints, solve the path constraints and perform assignment verification, and generate program state according to the execution strategy. The exploration and analysis module is used to schedule the program state and candidate paths and continuously explore them. After the exploration is completed, the analysis results are generated based on the execution records.
