Large language model assisted security protocol symbol model generation method and device
Converting natural language documents into symbolic models through semantic analysis and static analysis has solved the problem of automated synthesis of symbolic models in the existing technology, and achieved efficient and accurate generation of security protocol symbolic models, which has lowered the threshold for the use of analysis tools.
Patent Information
- Application Number
- CN202411975582.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2044-12-30
AI Technical Summary
The prior art is difficult to automatically and correctly synthesize symbol models from natural language documents of secure protocols, and large language models are prone to make mistakes when processing complex protocol documents, making it difficult to guarantee the accuracy and correctness of the synthesis results.
The natural language document is parsed into an intermediate representation of domain-specific language representations through a semantic parser, and the problem is fixed through static analysis and user interaction, converted to the Sapic+ specification, and finally compiled into a symbolic model directly accepted by the verification tool, and ensure the correctness of the transformation between models through manual proof.
The symbolic model of classic security protocols is realized automatically and correctly synthesized, which lowers the threshold for using protocol analysis tools and improves the verification and deployment efficiency of security protocols.
Smart Images

Figure CN119917068A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of security protocol technology, and in particular to a method and device for generating a security protocol symbol model assisted by a large language model. Background Art
[0002] Security protocols are programs designed to protect communications over secure networks (such as the Internet) through cryptographic primitives. Security protocols are ubiquitous and are widely used in e-commerce (such as the TLS protocol for https: / / URLs), banking transactions, mobile communications, WiFi networks (such as the WPA2 encryption protocol), and other security-critical scenarios. However, the design of security protocols is prone to errors (such as the famous Needham-Schroeder public key protocol), and these security errors may lead to serious consequences. Therefore, it is crucial to ensure the security and correctness of protocol design.
[0003] Common software testing methods often fail to detect security errors because they only occur in the presence of malicious attacks. For example, protocol fuzzing technology can often find memory implementation errors in protocol implementation, but it is very difficult to find logical errors at the design level. Formal verification is a powerful tool to solve this problem, especially the compliance model analysis of the protocol, which is of great significance to ensure the correct design of the protocol. It can rigorously prove that such protocols are immune to specific attacks at the design level, and can also be used to discover potential hidden attack vectors. For decades, symbolic model verification of security protocols has always been a hot research issue, and various automated tools (ProVerif, Tamarin Prover, etc.) have emerged to help protocol developers verify protocols. Among them, the automated tools ProVerif and Tamarin Prover have achieved great success in actual cases. Taking the AKA authentication protocol of 5G communication as an example, Basin et al. extracted precise requirements from the 3GPP standard and identified missing security goals. Using the security protocol verification tool Tamarin, they conducted a comprehensive and systematic security assessment of the model for 5G security goals. Through automated analysis, the minimum security assumptions required to achieve each security goal were determined, and some key security goals were found to be unachievable.
[0004] The formal verification of the protocol generally consists of the following steps:
[0005] 1. Protocol developers or experts manually model the specific implementation of the protocol and the security properties they want to verify by reading protocol documents (such as IETF Request For Comments, RFC).
[0006] 2. Use the formal language of verification tools (such as Tamarin Prover and ProVerif) to describe the established model and convert the model into an input form that the verification tool can accept.
[0007] 3. Model the security properties that the protocol needs to meet (such as privacy, data integrity, authentication) using logical formulas (such as first-order logic, FOL).
[0008] 4. The verification tool (semi-)automatically constructs a formal proof for the model to verify whether the protocol model satisfies the security properties. It can be seen that protocol verification relies heavily on manual specification extraction and proof construction.
[0009] Different protocol verification tools use different input languages. While each tool has its own strengths and weaknesses, from a usability perspective, they all have one thing in common: the input language is difficult for non-expert users. In the symbolic model, cryptographic primitives are considered perfect and modeled by function symbols in a term algebra (such as the function senc for symmetric encryption), and their semantics is given by a series of equations. Messages are terms based on these cryptographic primitives, and attackers can only use these primitives (and the equations that model them) to symbolically compute new terms. In particular, an attacker can only decrypt encrypted terms if he obtains the corresponding key. The default attack model is the Dolev-Yao model, where the attacker is assumed to have complete control over the network: he can monitor, delete, replace, copy and delay messages sent by both communicating parties, and can insert messages of his own choice on the public channel.
[0010] In addition to the complexity of using the tool itself, security protocols involve many fields (such as access control, encryption and authentication, etc.). An actual security protocol is often domain-specific, that is, different security protocols may involve very different domain knowledge and require different modeling options. These problems increase the cost of protocol verification and make the threshold of protocol verification high. For using tools to analyze protocols, reading protocol documents and modeling are the starting points of the entire security protocol analysis (such as Figure 1 Therefore, if we can automate the entire modeling and verification process based on the protocol text, it will greatly reduce the threshold for using protocol analysis tools, which will be of great significance to the verification and deployment of security protocols.
[0011] There are many works in the field of software engineering that process natural language text to extract specifications and even generate code. For example, Jdoctor, C2S, etc. use word alignment methods to process Javadoc documents to generate corresponding executable specifications, thereby guiding the generation of program test cases. Tellina, TreeGen, etc. use end-to-end machine translation models to generate bash commands or Python codes from natural language descriptions through encoding and decoding. In recent years, the emergence and rapid development of large language models have made these tasks easier. Due to the rich source of training data, large language models have achieved excellent performance in these tasks and can generate these programs with obvious structure and not complex semantics with high quality. However, for protocols, it is difficult to align their input documents and corresponding verifiable symbol models, which leads to a lack of high-quality data to train or fine-tune large language models. In addition, since the synthesis results are used for formal verification, how to ensure or explain the correctness of the synthesis results is also crucial. Therefore, it is not appropriate to simply model the protocol symbol model synthesis task as an end-to-end code generation problem. In terms of effect, the quality of the synthesis results cannot be guaranteed. In terms of correctness, the black box working mechanism of the large language model cannot provide a guarantee for credibility. Summary of the invention
[0012] In order to solve the above technical problems, the present invention provides a method and device for generating a security protocol symbol model assisted by a large language model.
[0013] The objective of the present invention is achieved through the following technical solutions:
[0014] In a first aspect, a method for generating a security protocol symbol model assisted by a large language model is provided, wherein the method for generating a security protocol symbol model assisted by a large language model comprises the following steps:
[0015] Parsing a natural language document based on a security protocol into a parsing result represented in a domain-specific language by a semantic parser, and using the parsing result as an intermediate representation, wherein the semantic parser is constructed based on a combined category grammar driven by a large language model;
[0016] Fixing problems in the intermediate representation by static analysis and allowing user interaction to formally normalize the intermediate representation;
[0017] converting the formally normalized intermediate representation to a Sapic+ specification by a converter;
[0018] Compile the standardized Sapic+ process language into a symbolic model directly accepted by verification tools Tamarin Prover, DeepSec and ProVerif through a compiler;
[0019] Prove the correctness of transformations between different models.
[0020] In some embodiments, the domain specific language is based on the natural language document and instantiates the parameters of key predicates through specific items, and is simplified in the form of lambda expressions and defines clear grammatical rules to form a protocol document;
[0021] The grammatical rules include a combination of event sequences, conditional control structures, and termination representations of protocols.
[0022] In some embodiments, the semantic parser includes: a parsing algorithm part for parsing a natural language document and a prompt word part for guiding the parsing algorithm to parse the natural language document.
[0023] In some embodiments, the parsing algorithm part includes: dividing the input protocol document into multiple sub-blocks, using a sliding window to move on the sub-blocks in turn, and using adjacent sub-blocks and corresponding parsing results as context to help parse the next word block.
[0024] In some embodiments, the prompt word part includes: a first part, a second part and a third part, wherein the first part is to specify a role for the large language model, and set the role as a parsing expert of a combined category grammar; the second part is to interpret the designed domain-specific language in natural language to inform the large language model of the grammatical rules that the output needs to meet; and the third part is to add actual sample examples.
[0025] In some embodiments, problems existing in the intermediate representation are fixed by static analysis and allowing user interaction to formally normalize the intermediate representation, including:
[0026] First, a large language model is used to verify the parsing results' consistency with the protocol document's specifications, and unreadable messages are formatted into readable form. Next, the unbound variables in the parsing results are analyzed, and a graphical message sequence chart of the protocol is generated. The user is then allowed to make corrections in an interactive environment by combining the unbound variable set and the graphical message sequence chart until the parsing results have no unbound variables, and finally a readable domain-specific language expression that conforms to the protocol specification is generated, namely a domain-specific language program, or intermediate representation.
[0027] In some embodiments, converting the formally normalized intermediate representation to a Sapic+ specification by a converter includes:
[0028] First, a set of conversion rules is determined to convert the repaired domain-specific language program into the local process of each role in the protocol, and the conversion rules process various events in the domain-specific language program in a recursive manner;
[0029] Then, based on the signature of the local process and combined with the hints of the large language model, the large language model is used to generate the top-level process of the protocol through few-shot learning;
[0030] Finally, the local process is combined with the top-level process to form a complete Sapic+ specification.
[0031] In some embodiments, proving the correctness of transformations between different models includes:
[0032] First, establish the trajectory inclusion relationship between different models;
[0033] We then prove that any security property that passes verification on the verification tool also applies to the DSL model and the Sapic+ model.
[0034] In a second aspect, a large language model-assisted security protocol symbol model generation device is provided, the large language model-assisted security protocol symbol model generation device comprising a memory and one or more processors, the memory storing executable code, characterized in that when the processor executes the executable code, it is used to implement the large language model-assisted security protocol symbol model generation method as described in any one of the first aspects.
[0035] The beneficial effects of the present invention are:
[0036] 1. The complexity of protocol documents may make large language models that lack domain-specific knowledge more prone to errors. At the same time, protocol documents are often very long (hundreds or even thousands of tokens), which will affect the accuracy of the output of large language models. Existing large language models often pay less attention to relevant information in the middle part of the input, resulting in insufficient robustness in the use of the provided context. The semantic parser constructed based on the combined category grammar driven by the large language model in the present invention can better process the protocol document input.
[0037] 2. The semantic characteristics of the intermediate representation of existing work are not rich enough (for example, it can only represent the semantics of a single sentence but cannot represent the contextual information of the sentence). The existing intermediate representation language is expanded or constructed to improve the accuracy of the extraction model while reducing the difficulty of subsequent conversion to the modeling language of the verification tool.
[0038] 3. The process from the intermediate representation to modeling languages such as ProVerif and Tamarin Prover cannot be simply regarded as a language translation model. An analysis-based conversion tool is required to ensure that the semantics of the protocol model extracted before and after the conversion do not change and are equivalent and consistent. The present invention constructs a manual proof to prove the path inclusion relationship of the protocol model before and after the conversion.
[0039] 4. The present invention proposes a method for synthesizing symbolic models from a protocol natural language document, which can automatically and correctly synthesize symbolic models of some classic security protocols and can be successfully verified. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0041] Figure 1 It is a schematic diagram of the overall process of a method for generating a security protocol symbol model assisted by a large language model provided in one embodiment of the present invention;
[0042] Figure 2 It is a schematic diagram of the structure of a large language model-assisted security protocol symbol model generation device provided in one embodiment of the present invention. DETAILED DESCRIPTION
[0043] In order to better understand the technical solution of the present application, the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0044] like Figure 1 In one embodiment, a method for generating a security protocol symbol model assisted by a large language model is provided. The method for generating a security protocol symbol model assisted by a large language model includes the following steps:
[0045] Parse the natural language document based on the security protocol into a parsing result represented by a domain-specific language through a semantic parser, and use the parsing result as an intermediate representation, wherein the semantic parser is built based on a combinatorial category grammar driven by a large language model;
[0046] In some embodiments, the present invention introduces a domain specific language (DSL) for specifying security protocols in an intuitive way, so that it is easier to be generated by a large language model (LLM). In essence, the designed DSL is a special lambda expression. From the perspective of lambda calculus, it can be observed that a sentence in a protocol document is usually an application, that is, the parameters of key predicates are instantiated through specific items (such as role names, clear messages). Intuitively, a lambda expression describes some operations performed by a role from a global perspective at a certain point in time. For simplicity, the application sxy(λx, ye(x, y)at) is abbreviated as e(a, t), which is called an event E. The syntax of the DSL is shown below, where e is the name of the event E, f and a are the names of the function and the subject, respectively, and t is an item in T: ⊥ represents a termination statement. P represents a program block, E; P represents a recursively defined sequential expression, condαP else Q represents a branch statement, where cond and else are keywords, α represents a judgment condition, P is the program executed when α is satisfied, and Q is the program executed when it is not satisfied. E represents time, ⊥ represents a termination statement, where A = {t∈T|t:agent} is a set of protocol entity names. e represents a symbol set, including gen (generate random numbers), send (send messages), recv (receive messages), knows (initialization), and op (local operations).
[0047] P::=E;P|condαP else Q
[0048] E: :=e(a,t)|⊥,a∈A,t∈T
[0049] e::=gen|send|recv|knows|op
[0050] A type msg is defined for each term, that is, for all terms t∈T, they have type msg. Furthermore, two subtypes of msg are defined: the term representing the protocol entity name is classified as agent, denoted by t:agent; the term representing the newly generated random number is classified as nonnce, denoted by t:agent. The basic event set is denoted by Ev g=E(A, T(N)), where A={t∈T|t:agent} is the set of protocol entity names. In the present invention, only the symbol set e given in the above grammar is considered, and these symbol sets can be extended to other event symbols. The event gen(a, n) indicates that the protocol entity a generates a new random number n. The interaction events send(a, m) and recv(a, m) respectively indicate that the subject a sends and receives message m through a public channel. The event know(a, t) indicates that the subject a initially knows the item t, that is, t is in the initial knowledge set of a. op(a, t) is a special event, indicating that the subject a has performed some local operations, such as binding an item to a variable or declaring the confidentiality of a locally generated random number.
[0051] In some embodiments, Semantic Parser (LCCG): parses a natural language document into a designed domain specific language.
[0052] CCG: Combinatory Categorial Grammar (CCG) is a rule system that combines syntax and semantics. It can take natural language sentences as input and output corresponding lambda expressions. Here, a large language model is used as a CCG parser. Since it has been pre-trained on massive language data, including various protocol-related technical documents, the model itself already has the ability to understand the document, and there is no need to manually construct the semantics and grammatical rules of the CCG system. In this part, the main design includes two parts: 1) parsing algorithm and 2) design of prompt words for parsing documents.
[0053] The present invention constructs a slicing parsing algorithm, which first divides the input protocol document into multiple sub-blocks, uses a sliding window to move on the sub-blocks in turn, and uses the adjacent sub-blocks and the corresponding parsing results as context to help the parsing of the next word block. In terms of prompt word design, the design method of few-sample context learning is combined.
[0054] The prompt words are divided into three parts: (1) specifying a role for the large language model, setting it as a CCG parsing expert; (2) explaining the designed DSL in natural language, telling the large language model the grammatical rules that the output needs to meet; (3) adding actual sample examples (few-shot), using the parsing process of an actual small protocol as an example. In this way, the parsing process of the initial text input is completed, and a DSL program fragment that follows the grammar defined above is obtained.
[0055] Fix problems in the intermediate representation by static analysis and allowing user interaction to formally normalize the intermediate representation;
[0056] In some embodiments, the model generated by LCCG needs to be normalized and consistent with the natural language document before conversion to the Sapic+ specification.
[0057] However, initial models are often problematic for a variety of reasons, the main issues being:
[0058] 1) Inconsistency: Due to the hallucination phenomenon and randomness of the large language model (LLM), the initial model may be inconsistent with the natural language description. For example, in the description of a certain protocol document, the server should use the hash value of the key hash(k) to respond to the client's request, but the large language model sometimes mistakenly generates incorrect messages. Similarly, a message that should have been sent by role A may be mistakenly attributed to role B by LLM;
[0059] 2) Ambiguity: Since ambiguity is common in natural language documents, it is crucial to adopt methods to reduce errors and ensure clarity. According to the observation, large language models often map unclear natural language descriptions into incorrect expressions with unbound variables, that is, variables that are used but not declared;
[0060] 3) Unreadability: Natural language describes the behavior and messages of the protocol from a global perspective. However, the message in the "receive" event is presented from a local perspective, specifically showing what the receiver should expect. In the symbolic model of the protocol, the form of the incoming message should be readable to a specific role, that is, the variables should be accessible. In the protocol validator, pattern matching is based on the form of the message. Although the validator can still accept incoming messages containing inaccessible variables, this unexpected pattern matching may break the semantics.
[0061] In order to solve the above problems, a repair algorithm is proposed, as described in Algorithm 1 below. The input includes the natural language description N of the protocol and the parsing result P. In order to solve the inconsistency problem caused by the hallucination and randomness of the large language model, the present invention introduces a self-verification method, which guides the large language model to carefully review the specifications of the given protocol description without introducing additional information, and find and correct the errors generated in the parsing stage. In order to solve the unreadability of the received message, a set of examples are encoded using the diff format;
[0062] Algorithm 1 fixes the parsing result:
[0063] Input: protocol document N, parsing result P
[0064] Output: The repaired DSL expression P
[0065] 1. Prompt the large language model (LLM) to verify the parsing result: P←Validate(P, N)
[0066] 2. LLM modifies the received message into a readable form: P←Readable(P)
[0067] 3. WHILE true DO
[0068] 4. Analyze the program to obtain the set of unbound variables: V←Analyze(P, N)
[0069] 5. If the variable collection is empty:
[0070] 6. Return variable collection: Return V
[0071] 7. Extract the message sequence diagram of the protocol to assist in interactive modification: msc←Graphviz(P), where msc represents the message sequence diagram and Graphviz represents the extraction process
[0072] 8. Allow users to directly modify: P←Interact(msc, P), where interact represents the interaction process;
[0073] 9. Finally, return to the repaired program: Return P
[0074] It demonstrates step by step how the large language model transforms the message into the correct form in the role specification step (line 2). When implementing the framework as a tool, a semi-automatic repair method is used (lines 4-9 of Algorithm 1). In this case, the user can directly repair the program P. The repair hints provided to the user include a graphical message sequence chart (MSC, see line 8) of the protocol and the unbound variable results from the analysis.
[0075] Convert the formally normalized intermediate representation to the Sapic+ specification via a converter;
[0076] Sapic+ is a protocol verification platform that allows users to efficiently verify security protocols using three major protocol verification tools: ProVerif, Tamarin, and DeepSec. The core features of the platform include:
[0077] Unified Input Language: Sapic+ is designed with a common input language that can be used as input to multiple tools, including ProVerif, Tamarin, and DeepSec, eliminating the need to select a specific tool and making these tools more accessible and easier to use.
[0078] Automated Translation: Sapic+ can automatically translate protocol specifications into the input format of each tool, so that users can verify the security properties of the protocol through a single Sapic+ file.
[0079] Proven Correctness: Sapic+ proves the correctness of the translation process, meaning that results proven with one tool can be used with another, leveraging the respective strengths of each tool.
[0080] The goal of Sapic+ is to leverage the strengths of each tool to improve the efficiency and accessibility of protocol verification while maintaining the consistency and correctness of verification results.
[0081] Proposed by Cheval et al. and published at the top security conference Usenix.
[0082] Cheval V, Jacomme C, Kremer S, et al. {SAPIC+}: protocol verifiers of the world, unite! [C] / / 31st USENIX Security Symposium(USENIX Security 22).2022: 3935-3952.
[0083] Link address: https: / / www.usenix.org / system / files / sec22-cheval.pdf
[0084] In some embodiments, a complete Sapic+ protocol can be expressed as: r P r ∪P t , where r is the protocol entity name, P r represents the corresponding local process, and P t It represents the top process, which is related to the initialization of the protocol (such as key configuration). In the present invention, a set of conversion rules are first defined to convert the repaired DSL program P into a local process. The rules are defined as:
[0085]
[0086] The three parameters of T represent the program P, the role r, and the corresponding knowledge set, M. Rule (1) indicates that the repaired program P is rewritten into Sapic+ process algebra. The transformation result of DSL program P is a mutually exclusive set of rewritten results of all role specifications extracted from P. Rule (2) indicates that the branch structure condαP else Q is rewritten into ifαthen P in the process. Symbols indicate before and after rewriting.
[0087] Rules (3)-(8) describe the process of deriving local processes from role specifications by recursively applying transformation rules T. Specifically, rule (3) converts the knows event into the signature of the local process let r(t)=P, where r represents the role name; rule (4) indicates that the event gen(r, n) statement in the program is rewritten into the new n statement in the process, and the event gen(r, m) indicates that the protocol entity r generates a new random number; rule (5) indicates that the send(r, n) statement in the program is rewritten into the out(n) statement in the process, and the event send(r, m) indicates that the subject r sends the message m through the public channel; rule (6) indicates that the recv(r, m) statement in the program is rewritten into the in(m) statement in the process, and recv(r, m) indicates that the subject r receives the message m through the public channel; rule (7) indicates that the op(r, f(t)) statement in the program is rewritten into the signal statement eventf(t) in the process, and op(r, f(t)) is a special event, indicating that the subject r performs some local operations f(t), where f is the operation name.
[0088] Rules (5)-(6) define the message input / output in the process; rules (7)-(8) convert op events into corresponding let bindings and signal events. The rewrite rules are defined under the default assumptions. Specifically, the assumptions are as follows: (i) The threat model is the classic Dolev-Yao model, where attackers can inject, modify, and intercept messages in the network; (ii) Message communication between different roles is transmitted asynchronously through a public channel; (iii) The initial knowledge set of the role is an empty set. In order to obtain a complete Sapic+ specification, it is necessary to further synthesize the top-level process P t First, collect all local processes ∪ r P r Then, we use few-shot learning to design prompt words to prompt the large language model to generate top-level specifications. Once the complete process U is obtained r P r ∪P t , it can be compiled into the corresponding Tamarin Prover, DeepSec and ProVerif symbolic models using the compiler.
[0089] Compile the standardized Sapic+ process language into a symbolic model directly accepted by verification tools Tamarin Prover, DeepSec and ProVerif through a compiler;
[0090] Sapic+ is designed as a general-purpose security protocol modeling specification language and is integrated into Tamarin Prover. Users can provide a protocol specification, which is then automatically translated into three different provers by the Sapic+ compiler. The correctness of the compilation process has been guaranteed by constructing a manual proof. This part of the proof is used in the present invention as part of the proof of the correctness of the entire framework.
[0091] Prove the correctness of transformations between different models.
[0092] In the present invention, the main focus is on the trace property of the protocol, so the correctness described here mainly refers to: the security property that is finally verified by the prover is still satisfied on the generated DSL protocol model. The proof idea is: first establish the trace inclusion relationship between different models. Then prove that any security property that has passed the verification on the verification tool is also applicable to the DSL model and Sapic+ model defined in the present invention. The proof method is to establish a refinement relationship on the two models before and after the conversion (including T and the compilation process), respectively, to prove that the path set of the former is implied in the latter. The use of the following two lemmas demonstrates the correctness of the derivation from the DSL model to the verifiable symbolic model.
[0093] Lemma 1. (Correctness of transformation rule T). For the DSL protocol model And the SAPIC+ protocol obtained through T If the symbolic model in the SAPIC+ protocol Satisfy safety properties Right now Then we can also get That is, there is an implication relationship between the two path sets: in Express Perform rewrite operation T. Representation Model Satisfaction A collection of paths.
[0094] Lemma 2. (Correctness of compilation). For the symbolic model expressed by the Sapic+ specification The compiled symbolic model is So for Satisfactory safety properties exist The above is still satisfied, that is And vice versa. In summary, there is an equivalence relationship The symbol It represents an if and only if relationship.
[0095] Through the above two lemmas, we can obtain that the path set on the DSL model is contained in the generated rewrite rules.
[0096] Tool implementation. In the present invention, the above method is implemented as a tool with a Web front end, which is written using HTML, GoJS JavaScript library and JQuery. In order to obtain and process intermediate results at different stages, a back-end server is built using Flask. An editor is embedded in HTML to allow users to modify and edit the generated results.
[0097] The complexity of protocol documents may make large language models that lack domain-specific knowledge more prone to errors. At the same time, protocol documents are often very long (hundreds or even thousands of tokens), which will affect the accuracy of the output of large language models. Existing large language models often pay less attention to relevant information in the middle part of the input, resulting in insufficient robustness in the use of the provided context. The semantic parser constructed based on the combined category grammar driven by the large language model in the present invention can better process protocol document input.
[0098] The semantic characteristics of the intermediate representation of existing work are not rich enough (for example, it can only represent the semantics of a single sentence but cannot represent the contextual information of the sentence). The existing intermediate representation language is expanded or constructed to improve the accuracy of the extraction model while reducing the difficulty of subsequent conversion to the modeling language of the verification tool.
[0099] The process from intermediate representation to modeling languages such as ProVerif and Tamarin Prover cannot be simply regarded as a language translation model. An analysis-based conversion tool is required to ensure that the semantics of the protocol model extracted before and after the conversion do not change and are equivalent and consistent. The present invention constructs a manual proof to prove the path inclusion relationship of the protocol model before and after the conversion.
[0100] The present invention proposes a method for synthesizing symbolic models from a protocol natural language document, which can automatically and correctly synthesize symbolic models of some classic security protocols and can verify success.
[0101] Benchmark datasets and large language model selection
[0102] Before conducting case tests, a dataset containing natural language descriptions of protocols and their corresponding symbolic models is required. Although there are some examples of symbolic models in TAMARIN's GitHub repository, it is difficult to find the corresponding natural language descriptions. Therefore, a standardized benchmark is first constructed to evaluate the effectiveness of symbolic model generation methods. Classic authentication protocols such as Needham-Schroeder and modern key exchange protocols such as SSH are selected, which are scalable, while large-scale protocols such as 5GAKA are not included. The original documents of these protocols, including IETF RFCs, research papers, and online informal texts, are carefully read, and the core parts corresponding to the models are extracted and reorganized. The dataset D is a set of tuples, i.e., D = {(N, P, R)}, where N is the natural language description, P is the Sapic+ specification, and R is the MSR rule verified by TAMARIN. The large language models used for experiments include GPT-3.5-turbo, GPT-4, and Google Gemini-pro, and the temperature parameters for semantic parsing and automatic repair are set to 0.4. To compile and verify the generated symbolic model, Tamarin Prover version 1.8.0 was used, which includes the Sapic+ platform.
[0103] (2) Comparative experimental setup
[0104] Since there is no related work on synthesizing protocol symbolic models from natural language, the present invention will use a small sample prompt generation method of a large language model as a comparative experiment, that is, given a small number of examples, prompt the large language model to directly synthesize the symbolic model from the natural language text. For each experimental case, it is synthesized 5 times in each method in turn, and the generation results are evaluated from the two perspectives of grammatical correctness and semantic correctness. Among them, 1) grammatical correctness means that the final synthesized symbolic model can be directly verified by the prover, and 2) semantic correctness is a more stringent requirement indicator, requiring that the symbolic model is not only grammatically correct and can be directly verified, but also semantically consistent with the reference model manually constructed in the data set, and correctly models the behavior of the protocol.
[0105] (3) Experimental results and analysis
[0106] Example: Evaluating the protocol model synthesis method using a constructed dataset.
[0107] The proposed method is evaluated using the benchmark constructed above, and the details are shown in Table V. The size of the input text varies from 51 to 639 tokens, and the number of lines of code (the number of lines of code for Sapic+ and the number of lines of code for Tamarin rewrite rules) ranges from 26 (37) to 134 (707), respectively.
[0108] Table 1 Datasets and synthesis results
[0109]
[0110] A series of basic security properties were verified, including confidentiality and authentication. The number of attributes is listed in the 4th column of Table 1. In this experiment, no user interaction was introduced, and the number of running iterations of each protocol was set to 5. The results show that 10 correct models can be automatically obtained in 18 cases, with a success rate between 2 / 5 and 5 / 5. In comparison, this method has a significant effect compared with the simple few-sample learning method. When using the same GPT-4 model, few-sample learning (3 samples) can successfully synthesize up to 4 semantically correct symbolic models, while the method of the present invention can synthesize 10 symbolic models.
[0111] See also Figure 2 A method for generating a security protocol symbol model assisted by a large language model is provided in an embodiment of the present invention, comprising a memory and one or more processors. An executable code is stored in the memory. When the processor executes the executable code, it is used to implement the method for generating a security protocol symbol model assisted by a large language model in the above embodiment.
[0112] The embodiment of the method for generating a security protocol symbol model assisted by a large language model of the present invention can be applied to any device with data processing capabilities, and the device with data processing capabilities can be a device or apparatus such as a computer. The device embodiment can be implemented through software, or through hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor of any device with data processing capabilities in which it is located reading the corresponding computer program instructions in the non-volatile memory into the memory and running them. From the hardware level, if Figure 2 As shown, it is a hardware structure diagram of any device with data processing capability in which the method for generating a security protocol symbol model assisted by a large language model of the present invention is used, except Figure 2 In addition to the processor, memory, network interface, and non-volatile memory shown, any device with data processing capabilities in which the apparatus in the embodiments is located may also include other hardware, generally based on the actual functions of the device with data processing capabilities, which will not be described in detail.
[0113] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.
[0114] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, in which the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the present invention. Ordinary technicians in this field can understand and implement it without paying creative work.
[0115] An embodiment of the present invention also provides a computer-readable storage medium having a program stored thereon. When the program is executed by a processor, the method for predicting molecules and olfactory body reactions based on a multimodal deep learning network in the above embodiment is implemented.
[0116] The computer-readable storage medium may be an internal storage unit of any device with data processing capability in any of the aforementioned embodiments, such as a hard disk or a memory. The computer-readable storage medium may also be an external storage device of any device with data processing capability, such as a plug-in hard disk, a smart media card (SMC), an SD card, a flash card, etc. equipped on the device. Furthermore, the computer-readable storage medium may also include both an internal storage unit and an external storage device of any device with data processing capability. The computer-readable storage medium is used to store computer programs and other programs and data required by any device with data processing capability, and may also be used to temporarily store data that has been output or is to be output.
[0117] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0118] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0119] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0120] The above description is merely a preferred embodiment of one or more embodiments of the present invention and is not intended to limit one or more embodiments of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present invention shall be included in the scope of protection of one or more embodiments of the present invention.
Claims
1. A method for generating a security protocol symbol model assisted by a large language model, characterized in that: The following steps are involved: Parsing a natural language document based on a security protocol into a parsing result represented in a domain-specific language by a semantic parser, and using the parsing result as an intermediate representation, wherein the semantic parser is constructed based on a combined category grammar driven by a large language model; Fix problems in the intermediate representation by static analysis and allowing user interaction to formally normalize the intermediate representation; The formally normalized intermediate representation is converted into a general process specification called Sapic+ through a converter. This specification can be verified by multiple tools at the same time, combining the advantages of different verification tools; Compile the standardized Sapic+ process language into a symbolic model directly accepted by verification tools Tamarin Prover, DeepSec and ProVerif through a compiler; Prove the correctness of transformation between different models.
2. The method for generating a security protocol symbol model assisted by a large language model according to claim 1, characterized in that: The domain specific language instantiates the parameters of key predicates through specific items based on the natural language document, and is simplified in the form of lambda expressions and defines clear grammatical rules; The grammatical rules include a combination of event sequences, conditional control structures, and termination representations of protocols.
3. The method for generating a security protocol symbol model assisted by a large language model according to claim 1, characterized in that: The semantic parser includes: a parsing algorithm part for parsing natural language documents and a prompt word part for guiding the parsing algorithm to parse the natural language documents.
4. The method for generating a security protocol symbol model assisted by a large language model according to claim 3, characterized in that: The parsing algorithm part includes: dividing the protocol document as input into multiple sub-blocks, using a sliding window to move on the sub-blocks in sequence, and using adjacent sub-blocks and corresponding parsing results as context to help parse the next word block.
5. The method for generating a security protocol symbol model assisted by a large language model according to claim 3, characterized in that: The prompt word part includes: the first part, the second part and the third part, wherein the first part is to specify a role for the large language model, and set the role as a parsing expert of a combined category grammar; the second part is to interpret the designed domain-specific language in natural language to inform the large language model of the grammatical rules that the output needs to meet; the third part is to add actual sample examples.
6. The method for generating a security protocol symbol model assisted by a large language model according to claim 3, characterized in that: Fix problems in the intermediate representation through static analysis and allowing user interaction to formally normalize the intermediate representation, including: First, a large language model is used to verify the parsing results' consistency with the protocol document's specifications, and unreadable messages are formatted into readable form. Next, the unbound variables in the parsing results are analyzed, and a graphical message sequence chart of the protocol is generated. The user is then allowed to make corrections in an interactive environment by combining the unbound variable set and the graphical message sequence chart until the parsing results have no unbound variables, and finally a readable domain-specific language expression that conforms to the protocol specification is generated, namely a domain-specific language program, or intermediate representation.
7. The method for generating a security protocol symbol model assisted by a large language model according to claim 1, characterized in that: The formally normalized intermediate representation is converted to the Sapic+ specification by a converter, including: First, a set of conversion rules is determined to convert the repaired domain-specific language program into the local process of each role in the protocol, and the conversion rules process various events in the domain-specific language program in a recursive manner; Then, based on the signature of the local process and combined with the hints of the large language model, the large language model is used to generate the top-level process of the protocol through few-shot learning; Finally, the local process is combined with the top-level process to form a complete Sapic+ specification.
8. The method for generating a security protocol symbol model assisted by a large language model according to claim 1, characterized in that: Prove the correctness of transformations between different models, including: First, establish the trajectory inclusion relationship between different models; We then prove that any security property that passes verification on the verification tool also applies to the DSL model and the Sapic+ model.
9. A device for generating a security protocol symbol model assisted by a large language model, comprising a memory and one or more processors, wherein the memory stores executable code, characterized in that: When the processor executes the executable code, it is used to implement the large language model-assisted security protocol symbol model generation method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Semantic-level protocol format inference method based on execution trace
CN103200203A
Formal verification method for facing design and accomplishment of wireless sensing network safety protocol
CN104135397A
Safety protocol formal verification method based on model detection
CN109150833A
Cross-platform method for security protocol modeling end and verification end, computer and storage medium
CN112506489A
System and method for source code generation
US20210089281A1