Correction device

The modification device addresses the challenge of modifying regular expressions for string extraction by using constraint expressions to ensure correct substring extraction and avoidance of ReDoS vulnerabilities, achieving effective and secure regular expression modification.

WO2025074500A1PCT designated stage expired Publication Date: 2025-04-10NIPPON TELEGRAPH & TELEPHONE CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
PCT/JP2023/036025
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-10-03
Publication Date
2025-04-10

AI Technical Summary

Technical Problem

Existing techniques fail to modify regular expressions for string extraction to simultaneously satisfy all conditions, including avoiding ReDoS vulnerabilities, while ensuring the regular expressions correctly extract specified substrings from given strings.

Method used

The modification device employs a first constraint expression to ensure the regular expression accepts specific strings and rejects others, and a second constraint expression to guarantee syntax that avoids ReDoS vulnerabilities, using a decision unit to determine if the regular expression meets these constraints.

Benefits of technology

This approach allows for the modification of regular expressions to effectively avoid ReDoS vulnerabilities while ensuring they correctly extract specified substrings, thus addressing the limitations of prior art.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure JP2023036025_10042025_PF_FP_ABST
    Figure JP2023036025_10042025_PF_FP_ABST
Patent Text Reader

Abstract

A correction device (100) constructs a first constraint expression for restricting a regular expression for character string extraction so that the regular expression for character string extraction receives a first set of character strings and rejects a second set of character strings, and a second constraint expression for satisfying a condition of syntax that does not include, in the regular expression, vulnerability related to pattern processing of the regular expression. The correction device (100) determines whether or not the regular expression for character string extraction satisfies the constructed first constraint expression and second constraint expression.
Need to check novelty before this filing date? Find Prior Art

Description

correction device

[0001] The present invention relates to a correction device.

[0002] Regular expressions are used as a notation to represent string patterns. Regular expressions are primarily used for two purposes: checking string patterns and extracting strings that match a pattern (hereafter referred to as "string extraction"). In either of these applications, errors can occur when creating a regular expression that represents the intended pattern. In addition, in recent years, the ReDoS (Regular Expressions DoS) vulnerability has become a problem, exploiting the behavior of regular expression engines, which are programs that perform pattern matching using regular expressions.

[0003] Therefore, a technique is known that uses examples, which are positive examples (hereinafter sometimes simply referred to as "positive examples"), which are a set of strings accepted by a regular expression, and negative examples (hereinafter sometimes simply referred to as "negative examples"), which are a set of strings rejected by a regular expression, and receives only the examples or a regular expression and the examples, and outputs a regular expression that satisfies the examples (see, for example, Non-Patent Documents 1 to 3). Another technique is known that outputs a regular expression that satisfies all the examples and does not have a ReDoS vulnerability (see, for example, Non-Patent Document 4). Another technique is known that uses a genetic algorithm to synthesize a regular expression for an extraction task from examples, such as synthesizing a regular expression that satisfies as many examples as possible (see, for example, Non-Patent Documents 5 and 6). Another technique is known that uses the above-mentioned examples to modify a regular expression (hereinafter sometimes referred to as a "regular expression for string extraction") used to extract a specific substring from a given string (see, for example, Non-Patent Document 7).

[0004] M.Lee et al., Synthesizing Regular Expressions from Examples for Introductory Automata Assignments, In Proc. GPCE’ 16.R.Pan et al., Automatic Repair of Regular Expressions, In Proc. OOPSLA’ 19.Y.Li et al., FlashRegex: Deducing Anti-ReDoS Regexes from Examples, In Proc. ASE’20.N.Chida and T. Terauchi, Repairing DoS Vulnerability of Real-World Regexes, In Proc. S&P’22.A.Bartoli et al., Automatic Synthesis of Regular Expressions from Examples, Computer.A.Bartoli et al., Inference of Regular Expressions for Text Extraction from Examples, IEEE Transactions on Knowledge and Data Engineering.N. CHIDA, T. TERAUCHI, Repairing Regular Expressions for Extraction, Proc. ACM Program. Lang., Vol. 7, No. PLDI, Article 173. Publication date: June 2023.

[0005] However, the above-mentioned conventional technology has a problem in modifying a regular expression for string extraction so that it does not contain ReDoS vulnerabilities. For example, the conventional technology can individually modify a regular expression so that it does not contain ReDoS vulnerabilities, modify a regular expression so that it satisfies all examples, and modify a regular expression for string extraction that extracts parts to be extracted from a string, but it is not possible to modify the regular expression so that it satisfies all of the above-mentioned modification conditions at once. Therefore, the conventional technology cannot modify an input regular expression for string extraction so that it satisfies all examples and does not contain ReDoS vulnerabilities.

[0006] Therefore, in order to solve the above-mentioned problems and achieve the object, the correction device of the present invention is characterized by having: a construction unit that constructs a first constraint expression that constrains a regular expression for character string extraction so that the regular expression for character string extraction accepts a first set of character strings and rejects a second set of character strings; and a second constraint expression that satisfies a syntactic condition that the regular expression does not contain any vulnerability related to pattern processing of the regular expression; and a determination unit that determines whether the regular expression for character string extraction satisfies the first constraint expression and the second constraint expression constructed by the construction unit.

[0007] According to the present invention, it is possible to correct a regular expression for extracting a character string so that it does not contain a ReDoS vulnerability.

[0008] FIG. 1 is a diagram illustrating an overall image of processing by a correction device according to this embodiment. FIG. 2 is a diagram illustrating an example of a regular expression according to this embodiment. FIG. 3 is a diagram illustrating an example of a first reference technique. FIG. 4 is a diagram illustrating an example of the first reference technique. FIG. 5 is a diagram illustrating an example of a second reference technique. FIG. 6 is a diagram illustrating an example of the configuration of a correction device according to this embodiment. FIG. 7 is a diagram illustrating operators of regular expressions according to this embodiment. FIG. 8 is a diagram illustrating positive examples according to this embodiment. FIG. 9 is a diagram illustrating negative examples according to this embodiment. FIG. 10 is a flowchart illustrating an example of a correction processing procedure according to this embodiment. FIG. 11 is a diagram illustrating an example of correction processing according to this embodiment. FIG. 12 is a flowchart illustrating an example of an overall processing procedure by the correction device according to this embodiment. FIG. 13 is a diagram illustrating an example of a computer that executes correction processing according to this embodiment.

[0009] DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. Note that the embodiments are not limited to the following description.

[0010] 1 is a diagram illustrating an overall view of processing by the modification device 100 according to this embodiment. The modification device 100 shown in FIG. 1 is an example of a computer that provides a technology for determining whether a regular expression for extracting a string that matches a pattern (a regular expression for string extraction) satisfies constraints for satisfying positive examples and negative examples (hereinafter, sometimes simply referred to as "examples") and constraints for satisfying syntax that ensures that the regular expression does not contain vulnerabilities related to pattern processing of the regular expression (hereinafter, sometimes referred to as "ReDoS vulnerabilities"), and for outputting a regular expression for string extraction that satisfies the constraints based on the determination results.

[0011] In recent years, regular expressions have been used in some cases to check string patterns (hereinafter, sometimes referred to as "membership") and extract strings that match a pattern.

[0012] (Regular Expressions) Here, the above-mentioned regular expressions will be described. FIG. 2 is a diagram showing an example of a regular expression according to this embodiment. A regular language is expressed using a regular expression. For example, as shown in FIG. 2, the regular expression r follows a syntax defined using Backus-Naur form (BNF).

[0013] In this embodiment, the meaning of a regular expression may be one that is generally defined. That is, the language L(r) of regular expression r may be one defined as shown in FIG. 2. In addition to the definition shown in FIG. 2, range characters [C] and [^C] may also be used. Here, C is a set of characters, and L([C]) = C, L([^C]) = Σ\C. Here, "Σ" represents the set of all characters, and "\" represents the difference set.

[0014] Errors often occur when writing regular expressions for performing membership or character string extraction as described above. Furthermore, in recent years, ReDoS vulnerabilities, which are vulnerabilities that exploit the behavior of regular expression engines, which are programs that perform pattern matching using regular expressions, have become a problem. For this reason, a technology (reference technology) has been devised for writing regular expressions that express intended patterns and do not contain ReDoS vulnerabilities.

[0015] (Regarding the First Reference Technology) The reference technology will now be described. The first reference technology is a technology for correcting a regular expression using examples, i.e., positive examples, which are patterns of character strings that a system or the like wants to accept, and negative examples, which are patterns of character strings that a system or the like wants to reject. This first reference technology is a technology that receives as input a regular expression including real-world extension functions and examples, and outputs a regular expression that satisfies all examples while ensuring that the corrected regular expression does not contain ReDoS vulnerabilities.

[0016] 3 and 4 are diagrams illustrating an example of the first reference technique. As shown in FIG. 3, a regular expression r, positive examples P, and negative examples N are input to a correction device 10a in the first reference technique. The positive examples and negative examples are sets of character strings. The correction device 10a corrects the input regular expression so as to accept positive example character strings and not accept negative example character strings.

[0017] As shown in Fig. 3, the modifying device 10a modifies the input regular expression r to r'. The modified regular expression r' accepts "ab" and "c" but does not accept "d". * " is a regular expression that accepts a string of length 0 or greater that does not contain "d". Furthermore, r' is a regular expression that accepts positive example strings and does not accept negative example strings, and has the smallest edit distance from r.

[0018] 4 is a diagram illustrating edit distance. The edit distance between two regular expressions r1 and r2 is defined as follows: (1) Each regular expression is expressed as an Abstract Syntax Tree (AST). (2) The total number of different vertices between each AST is the edit distance.

[0019] However, the first reference technique has a problem in that it is not possible to specify in examples (e.g., positive examples) the portions to be extracted by capturing regular expressions. Moreover, even if it were possible to specify in examples the portions to be extracted by capturing, there is a problem in that the first reference technique does not guarantee that the specified portions will be properly extracted.

[0020] (Regarding the Second Reference Technique) The second reference technique is a technique for synthesizing a regular expression for an extraction task from examples. That is, the second reference technique is a technique for synthesizing a regular expression that satisfies as many examples as possible using a genetic algorithm.

[0021] 5 is a diagram illustrating an example of the second reference technique. In the second reference technique, as shown in FIG. 5, a portion to be extracted can be clearly specified as an example by capturing a regular expression. Specifically, the correction device 10b in the second reference technique outputs a regular expression including a capture such as "AB(C|D|E)" based on an example in which a portion to be extracted is clearly specified.

[0022] However, the second reference technique has a problem in that it aims to make corrections so as to satisfy as many examples as possible, but does not guarantee that the regular expressions resulting from the corrections will satisfy all examples.Furthermore, the second reference technique has a problem in that it does not guarantee that the corrections will not contain ReDoS vulnerabilities.

[0023] (Regarding the Third Reference Technique) The third reference technique is a technique for modifying a regular expression for extracting a string, which is used to extract a specific substring from a given string, using an example. In this third reference technique, information indicating the extraction location is added to the example of the second reference technique to specify the desired location to be extracted, and a regular expression for extracting that location is specified.

[0024] However, the third reference technique has a problem in that it is not guaranteed that the regular expressions for extracting character strings resulting from the correction do not contain ReDoS vulnerabilities.

[0025] Therefore, in order to solve the above-mentioned problems, the editing device 100 according to this embodiment constructs a constraint equation that constrains the regular expression for string extraction to be one that corresponds to all examples and specifies the parts to be extracted, and a constraint equation that satisfies Real-World Strong 1 Unambiguity (hereinafter, may be abbreviated as "RWS1U"), which guarantees that the syntax does not contain ReDoS vulnerabilities, and determines whether the input regular expression for string extraction contains ReDoS vulnerabilities based on whether the two constraint equations are satisfied.

[0026] Returning to Fig. 1 , a series of processing steps performed by the editing device 100 will now be described. For example, as shown in (1) of Fig. 1 , based on the received regular expression for character string extraction and the positive and negative examples, the editing device 100 constructs a first constraint that constrains the regular expression for character string extraction to accept positive examples (a first set of character strings) and reject negative examples (a second set of character strings), and a second constraint that satisfies RWS1U. Then, as shown in (2) of Fig. 1 , the editing device 100 determines whether the input regular expression for character string extraction satisfies the constructed first and second constraints.

[0027] The modification device 100 can output a regular expression for string extraction that is determined to satisfy both of the above-mentioned two constraints (i.e., the regular expression for string extraction has an answer that satisfies the constraints) as a regular expression for string extraction that does not contain a ReDoS vulnerability.

[0028] In this way, the modification device 100 according to the present embodiment uses RWS1U, which is a property that guarantees that a ReDoS vulnerability is not included, and positive and negative examples (examples), to determine whether an input regular expression for character string extraction satisfies the examples and whether a ReDoS vulnerability is included. This allows the modification device 100 to achieve the effect of specifying the parts to be extracted for the examples and guaranteeing that a regular expression for character string extraction that includes all examples does not include a ReDoS vulnerability.

[0029] <Description of Editing Device> Next, the configuration of the editing device 100 will be described. FIG. 6 is a diagram showing an example of the configuration of the editing device 100 according to this embodiment. As shown in FIG. 6, the editing device 100 has a communication unit 110, a storage unit 120, and a control unit 130. Although not shown in FIG. 6, the editing device 100 may also include an input unit such as a keyboard or a mouse for accepting input such as operations by a user or the like. The editing device 100 may also include a display unit such as a display for displaying to a user or the like regular expressions that satisfy the first constraint formula and the second constraint formula.

[0030] (Communication Unit 110) The communication unit 110 performs data communication related to input of regular expressions and examples for character string extraction, output of regular expressions that satisfy the first constraint equation and the second constraint equation, etc. The communication unit 110 is realized by a network interface card (NIC) or the like, and controls communication via electrical communication lines such as a local area network (LAN) or the Internet. The communication unit 110 is connected to a network via wired or wireless connection as necessary, and can transmit and receive information bidirectionally.

[0031] (Storage Unit 120) The storage unit 120 stores data and programs used for various processes by the control unit 130, as well as various data acquired through the operation of the control unit 130. The storage unit 120 is realized by a semiconductor memory element such as a RAM (Random Access Memory) or a flash memory, or a storage device such as a hard disk or optical disk. As shown in FIG. 6 , the storage unit 120 also has a template information DB 121.

[0032] (Template Information DB 121) The template information DB 121 is a database that stores a set of syntax in regular expressions or templates. The syntax stored in the template information DB 121 is replaced with a range character or a hole in the process described below. For example, the template information DB 121 stores a list of syntax such as "□□, □ | □, □ * , (□) < \i, (? = □), (?!□), (? < = □), (? <!□)." Note that "□" is a hole.

[0033] Here, regular expression operators will be described with reference to FIG. 7. FIG. 7 is a diagram showing regular expression operators according to this embodiment. As shown in FIG. 7, in this embodiment, an operator called a hole is used in addition to the normal Backus-Naur form operators. A hole functions as a placeholder. Specifically, a portion represented by a hole represents a portion that is being corrected, and for example, a regular expression (template) in the correction process may contain a hole.

[0034] Furthermore, a hole may be replaced with a syntax that further includes a range character or a hole. In this embodiment, a template is an element included in a specific queue, and means that a hole (□) has been added to each operator of a regular expression added as an element to the queue.

[0035] (Control Unit 130) The control unit 130 has an internal memory for temporarily storing programs defining various processing procedures and the like of the correction device 100 and processing data, and is realized by electronic circuits such as a CPU (Central Processing Unit) and an MPU (Micro Processing Unit), and integrated circuits such as an ASIC (Application Specific Integrated Circuit) and an FPGA (Field Programmable Gate Array). As shown in FIG. 6 , the control unit 130 has a receiving unit 131, a generating unit 132, a constructing unit 133, a determining unit 134, a correcting unit 135, and an output unit 136.

[0036] (Reception Unit 131) The reception unit 131 receives regular expressions for character string extraction, positive examples, and negative examples (examples). The reception unit 131 can receive regular expressions for character string extraction, positive examples, and negative examples (examples) for which correction processing is to be performed, via an input unit such as a keyboard or a touch panel, or the communication unit 110 that communicates data with other information processing devices, etc.

[0037] (Generation unit 132) The generation unit 132 takes the input regular expression for character string extraction as an element and adds the element to a prioritized queue, which is a data structure that holds templates that are candidates for correction results. Then, the generation unit 132 obtains and extracts the template to which the element has been added from the prioritized queue.

[0038] (Construction unit 133) The construction unit 133 constructs a first constraint expression that constrains the regular expression for character string extraction so that the regular expression for character string extraction accepts positive examples and rejects negative examples. Specifically, the construction unit 133 constructs the first constraint expression as a constraint expression that accepts character strings included in input positive examples and rejects character strings included in negative examples, and constrains the regular expression for character string extraction to extract character strings to be captured from character strings included in positive examples.

[0039] Here, positive examples and negative examples of regular expressions for character string extraction according to this embodiment will be described. FIG. 8 is a diagram illustrating a positive example according to this embodiment. As shown in FIG. 8, the regular expression for character string extraction "ab(cd)1ef" includes a capture "(cd)1". Furthermore, a positive example may include a portion enclosed by a first symbol (a special left parenthesis (Unicode: U+2987)) and a subscripted second symbol (a special right parenthesis (Unicode: U+2988)). This portion is the character string to be captured. The subscript indicates the position (the number of the capture) of the capture that extracts the character string to be captured. Note that, here, "<" and ">" represent the first symbol and the second symbol, respectively. Furthermore, the first symbol, the second symbol, and the subscript may be referred to as annotations.

[0040] In this embodiment, the character string to be captured and the capture position are specified in the annotation of the positive example, and the editing device 100 then identifies the character string between the first symbol and the second symbol included in the positive example as the character string to be captured.

[0041] A regular expression for string extraction that accepts a positive example with specified capture strings and capture positions and extracts the specified string by capturing the specified positions satisfies the positive example. A regular expression for string extraction that does not accept a positive example with specified capture strings and capture positions does not satisfy the positive example. A regular expression for string extraction that accepts a positive example with specified capture strings and capture positions but does not extract the specified string by capturing the specified positions does not satisfy the positive example.

[0042] For example, as shown in Fig. 8, the correction device 100 accepts the positive example "ab<cd>1ef" for the regular expression "ab(cd)1ef" for character string extraction and extracts "cd" by the first capture. On the other hand, as shown in Fig. 8, the correction device 100 accepts the positive example "a<bcd>1ef" for the regular expression "ab(cd)1ef" for character string extraction, but does not extract "bcd" by the first capture.

[0043] Next, negative examples in this embodiment will be described with reference to FIG. 9 . FIG. 9 is a diagram illustrating negative examples according to this embodiment. A regular expression for extracting a character string that does not accept a negative example satisfies the negative example. Also, a regular expression for extracting a character string that accepts a negative example does not satisfy the negative example.

[0044] For example, as shown in Fig. 9, the correction device 100 accepts the negative example "abcdef" for the regular expression "ab(cd)1ef" for extracting a character string. However, the negative example "abcdef" does not indicate that "cd" is extracted by the first capture. Also, as shown in Fig. 9, the correction device 100 rejects the negative example "abcd" for the regular expression "ab(cd)1ef" for extracting a character string.

[0045] Note that negative examples in which a character string to be captured and a capture position are specified are not input to the correction device 100. For example, such input is treated as an error. Note that positive examples in which a character string to be captured and a capture position are not specified may be input to the correction device 100. In such a case, it is intended to request the correction device 100 to use a regular expression that does not extract anything from that character string.

[0046] The construction unit 133 constructs a second constraint expression for satisfying a syntax condition (RWS1U) that the regular expression does not contain vulnerabilities related to regular expression pattern processing. Specifically, the construction unit 133 constructs the second constraint expression as a constraint expression for satisfying the RWS1U, which is a syntax condition of the regular expression that ensures that the regular expression does not contain ReDoS vulnerabilities. For example, the construction unit 133 constructs the second constraint expression that constrains the regular expression so that the target regular expression for character string extraction satisfies an RWS1U such as "lookaheads appearing in the regular expression do not include either repetitions or backreferences."

[0047] (Determination unit 134) The determination unit 134 determines whether the input regular expression for character string extraction satisfies the first constraint equation and the second constraint equation constructed by the construction unit 133. An example of the determination process by the determination unit 134 will be described later. The determination unit 134 can use a known technique such as SMT Solver to determine whether the regular expression for character string extraction satisfies the first constraint equation and the second constraint equation.

[0048] (Modification Unit 135) The modification unit 135 modifies the regular expression for character string extraction so that it satisfies the input example and does not contain the ReDoS vulnerability. Specifically, when the determination unit 134 determines that an element (template) included in a predetermined queue whose element is the regular expression for character string extraction does not satisfy the first constraint expression and the second constraint expression, the modification unit 135 changes the operator included in the element (template). On the other hand, when the determination unit 134 determines that the element satisfies the first constraint expression and the second constraint expression, the modification unit 135 replaces the first operator (hole), which indicates that the regular expression included in the element (template) is being modified, with a second operator indicating a range character. Note that an example of the modification process by the modification unit 135 will be described later.

[0049] (Output Unit 136) The output unit 136 outputs information about the regular expression for character string extraction based on the determination result by the determination unit 134. For example, when the determination unit 134 determines that the element satisfies the constraint, the output unit 136 outputs, as a regular expression for character string extraction, an element in which the modification unit 135 has replaced a hole included in the element with a character string that satisfies the constraint. Furthermore, when the determination unit 134 determines that the constraint is not satisfied, the output unit 136 may output information such as that the input regular expression for character string extraction does not satisfy the first constraint equation and the second constraint equation. Note that the output unit 136 can output the result to a user via a display unit such as a display provided in the modification device 100 or a communication unit 110 that performs data communication with other information processing devices, etc.

[0050] (Example of Correction Processing) Hereinafter, an example of the correction processing of a regular expression for character string extraction realized by the correction device 100 according to this embodiment will be described. Fig. 10 is a flowchart showing an example of the correction processing procedure according to this embodiment. Fig. 11 is a diagram showing an example of the correction processing according to this embodiment.

[0051] First, an example of the flow of the correction process will be described with reference to FIG. 10 . As shown in FIG. 10 , the correction device 100 receives input regular expressions for character string extraction, positive examples, and negative examples (S10). The correction device 100 adds the input regular expressions for character string extraction to a priority queue (S11). The correction device 100 acquires templates from the priority queue (S12). The correction device 100 constructs a first constraint equation for matching the templates with examples (positive examples and negative examples) (S13). The correction device 100 constructs a second constraint equation for the templates to satisfy RWS1U (S14). The correction device 100 determines whether the first and second constraint equations are satisfied (S15).

[0052] If the first constraint equation and the second constraint equation are not satisfied (No in S15), the editing device 100 adds the template with the modified shape to the priority queue (S16). Next, the editing device 100 acquires the template from the priority queue (S17). Then, the editing device 100 returns to the previous step and continues the process.

[0053] On the other hand, if the first and second constraint expressions are satisfied (Yes in S15), the modifying device 100 replaces the operator included in the template (S18), outputs the result (S19), and ends the process.

[0054] Next, an example of the processing in each step in the flowchart explained in FIG. 10 will be explained with reference to FIG.

[0055] (S10: Acceptance of regular expression for character string extraction, positive examples, and negative examples) First, the correction device 100 receives as input the regular expression for character string extraction "(. * ) 1 a" and the positive example "{ 1a}" and a negative example "{za}". Note that here, the "<" shown in the positive example means a special left parenthesis (Unicode: U+2987), and ">" means a special right parenthesis (Unicode: U+2988), and the same applies hereinafter.

[0056] (S11: Adding regular expression for string extraction to priority queue) The correction device 100 adds only the input regular expression for string extraction as an element to a priority queue, which is a data structure that holds templates that are candidates for correction results. For example, as shown in (1) of FIG. 11, the correction device 100 adds the regular expression for string extraction "(. * ) 1 a" and create a priority queue "Q = {(. * ) 1 a}" is constructed.

[0057] (S12: Obtaining an element from the priority queue) The modifying device 100 obtains the template t from the priority queue Q constructed in S12. For example, as shown in (2) of FIG. 11, the modifying device 100 obtains an element from the priority queue "Q={(. * ) 1 a}" to the template "t=(. * ) 1 Obtain "a".

[0058] (S13: Constructing a First Constraint Expression) The modifying device 100 constructs a first constraint expression as a constraint expression for a template (a regular expression for extracting a character string) to satisfy the conditions for a positive example and a negative example. For example, the modifying device 100 constructs a first constraint expression as a constraint expression for an input positive example "{ 1 As a constraint equation for satisfying the negative example "{za}" and the negative example "{za}", the first constraint equation "φ 1 =v 1 b ∧¬v 1 z " is constructed. Note that the first constraint "φ 1 =v 1 b ∧¬v 1 z " is "v 1 contains "b" and v 1 does not contain "z".

[0059] (S14: Construction of Second Constraint Expression) The modifying device 100 constructs a second constraint expression for the template t extracted from the priority queue Q to satisfy RWS1U. For example, the modifying device 100 constructs a second constraint expression for the input positive example "{ 1 As a constraint equation for satisfying the negative example "{za}" and the negative example "{za}" and for satisfying RWS1U, the second constraint equation "φ 2 =¬v 1 a " is constructed. Note that the second constraint "φ 2 =¬v 1 a " is "v 1 does not contain a.

[0060] (S15: Determining whether constraint equations are satisfied) The modifying device 100 determines whether the template t satisfies the first constraint equation established in S14 and the second constraint equation established in S15. For example, the modifying device 100 determines whether the template t "t=(. * ) 1 "(. a" * ) does not satisfy the first constraint because it contains a negative example “z” (i.e., φ 1 = false). Furthermore, the modifying device 100 determines that the template t "t=(. * ) 1 "(. a" * Since the input character string and the number of character strings are not limited and ambiguity is included, RWS1U is violated and the second constraint is not satisfied (i.e., φ 2 = false).

[0061] (S16: Modify the form of template and add to priority queue) When the modifying device 100 determines that the first constraint and the second constraint are not satisfied, it modifies the form of template t and adds it to the priority queue Q. For example, as shown in (6) of FIG. 11, the modifying device 100 modifies the form of template t "t=(. * ) 1 a" to "(□ * ) 1 a" or "(. *) 1 The shape of the template t is changed by changing the operator to a hole (□), such as "□", and added to the priority queue Q.

[0062] (S17 and S15: Determination of Satisfaction of Constraint Formula) Subsequently, the modifying device 100 acquires the template t again from the priority queue in which the shape of the template t has been changed. 1 ∧φ 2 = (v 1 b ∧¬v 1 z )∧¬v 1 a " is "v 1 a = false, v 1 b =true, v 1 z = false”. Based on the above conditions, the modifying device 100 performs a determination process.

[0063] (S18: Operator Replacement) When the modification device 100 determines that the changed template t satisfies the first constraint and the second constraint, it replaces the operator included in the template t. For example, as shown in (7) of FIG. 12, the modification device 100 replaces the hole (□) included in the template t with a range character ([C]). Then, the modification device 100 replaces the above-mentioned "φ 1 ∧φ 2 = (v 1 b ∧¬v 1 z )∧¬v 1 a " is "v 1 a = false, v 1 b =true, v 1 z = false”, the range character ([C]) is replaced with "[b]".

[0064] (S19: Output of Result) The modifying device 100 outputs the regular expression for character string extraction “([b] * )1 a" is output and the process ends.

[0065] (Overall Procedure of Processing by the Editing Device) Hereinafter, a procedure of processing for correcting a regular expression for character string extraction, which is realized by the editing device 100 according to this embodiment, will be described. Fig. 12 is a flowchart showing an example of the overall procedure of processing by the editing device 100 according to this embodiment.

[0066] The receiving unit 131 receives a regular expression for extracting a character string, a positive example, and a negative example (S101).

[0067] The construction unit 133 initializes the priority queue (S102), acquires a template from the priority queue (S103), and constructs a constraint equation based on the acquired template (S104).

[0068] The determination unit 134 determines whether the template has an answer that satisfies the first constraint equation and the second constraint equation (S105). If the template has an answer that satisfies the conditions (Yes in S106), the output unit 136 outputs the result (S107). Then, the editing device 100 ends the process.

[0069] On the other hand, if there is no answer that satisfies the condition (No in S106), the correcting unit 135 adds a template with a modified shape to the priority queue (S108).Then, the correcting device 100 returns to the previous step and continues the process.

[0070] (Effects) The effects of the modification device 100 according to this embodiment will now be described. The construction unit 133 of the modification device 100 according to this embodiment constructs a first constraint expression that constrains a regular expression for string extraction so that the regular expression for string extraction accepts positive examples and rejects negative examples, and a second constraint expression that satisfies RWS1U, which ensures that the regular expression has syntax that does not contain ReDoS vulnerabilities. The determination unit 134 of the modification device 100 then determines whether the regular expression for string extraction satisfies the first constraint expression and the second constraint expression constructed by the construction unit 133. Therefore, the modification device 100 according to this embodiment has the effect of being able to modify a regular expression for string extraction so that it does not contain ReDoS vulnerabilities.

[0071] Specifically, the construction unit 133 constructs a first constraint equation as a constraint equation that constrains a regular expression for string extraction that extracts a capture target string from the strings included in the positive examples while accepting strings included in the input positive examples and rejecting strings included in the negative examples. The construction unit 133 also constructs a second constraint equation as a constraint equation that satisfies RWS1U, a syntax condition of a regular expression that ensures that the regular expression does not contain a ReDoS vulnerability. In this way, the modification device 100 constructs two constraint equations based on elements included in the input regular expression for string extraction and the positive and negative examples. The modification device 100 then performs a determination using the constructed constraint equations, thereby achieving the effect of being able to modify the regular expression for string extraction so that it does not contain a ReDoS vulnerability.

[0072] Furthermore, when the determination unit 134 determines that an element included in a predetermined queue whose elements are regular expressions for string extraction does not satisfy the first and second constraint expressions, the modification unit 135 changes the operator included in the element. When the determination unit 134 determines that the element satisfies the first and second constraint expressions, the modification unit 135 replaces a hole, which indicates that the regular expression included in the element is being modified, with a range character. In this way, when the modification device 100 determines that an input template whose elements are only regular expressions for string extraction does not satisfy the constructed constraint expression, it changes the operator included in the template and repeats the determination process. Then, when the modification device 100 determines that the constraint expression is satisfied, it replaces the operator included in the template and outputs it as an answer. In this way, the modification device 100 is able to modify regular expressions for string extraction so that they do not contain ReDoS vulnerabilities.

[0073] As described above, the modification device 100 according to this embodiment facilitates the creation of intended regular expressions for extracting strings that do not contain ReDoS vulnerabilities in development situations that use regular expressions for extracting strings. Therefore, the modification device 100 has the effect of preventing security problems and bugs related to ReDoS vulnerabilities from being introduced into programs.

[0074] Furthermore, the modification device 100 according to this embodiment automatically constructs a constraint equation based on the input regular expression for string extraction and examples, and modifies the regular expression for string extraction so as to satisfy the constraint equation. While regular expressions for string extraction have previously been created one by one based on predetermined rules such as RWS1U, this allows for the automatic creation of regular expressions for string extraction that do not contain the ReDoS vulnerabilities desired by the user, thereby reducing the amount of computer processing and man-hours required.

[0075] <Modifications> Modifications realized by the repair device 100 according to this embodiment will be described below.

[0076] (Data, etc.) The string constraints, regular expressions, constraint expressions, template information, names of functional parts of the modification device 100, steps, processes, names of steps or processes, etc. used in the description of the above embodiment are merely examples and can be changed as desired.

[0077] (Flowcharts, etc.) The steps in a flowchart, etc. may be interchanged and performed as long as there is no contradiction, and some steps may not be performed. In addition, conjunctions such as "next," "continue," "further," "at this time," and "on this occasion" used in the description of a flowchart do not limit the order or timing of performing the processes in the flowchart.

[0078] (System) The information including the processing procedures, control procedures, specific names, various data and parameters shown in the above documents and drawings can be changed as desired unless otherwise specified.

[0079] Furthermore, the components of each device shown in the figure are conceptual functional components and do not necessarily have to be physically configured as shown. In other words, the specific form of distribution and integration of each device is not limited to that shown. In other words, all or part of the devices can be functionally or physically distributed or integrated in any unit depending on various loads, usage conditions, etc.

[0080] <Hardware Configuration> The components of each device shown in the figure are conceptual functional components and do not necessarily have to be physically configured as shown. In other words, the specific form of distribution and integration of each device is not limited to that shown, and all or part of them can be functionally or physically distributed and integrated in any unit depending on various loads, usage conditions, etc. Furthermore, all or any part of the processing functions performed by each device can be realized by a CPU and a program analyzed and executed by the CPU, or can be realized as hardware using wired logic.

[0081] Furthermore, among the processes described in this embodiment, all or part of the processes described as being performed automatically can also be performed manually using known methods. In addition, the information including the processing procedures, control procedures, specific names, various data, and parameters shown in the drawings can be changed as desired unless otherwise specified.

[0082] <Program> In one embodiment, the various devices constituting the correction device 100 can be implemented by installing a correction program as package software or online software on a desired computer. For example, by executing the above-described correction program on an information processing device, the various devices constituting the correction device 100 can function. The information processing device referred to here includes desktop and notebook personal computers. Furthermore, other information processing devices also include mobile communication terminals such as smartphones and mobile phones, as well as slate terminals such as PDAs (Personal Digital Assistants).

[0083] 13 is a diagram showing an example of a computer that executes the correction process according to this embodiment. The computer 1000 includes, for example, a memory 1010 and a CPU 1020. The computer 1000 also includes a hard disk drive interface 1030, a disk drive interface 1040, a serial port interface 1050, a video adapter 1060, and a network interface 1070. These components are connected by a bus 1080.

[0084] The memory 1010 includes a ROM (Read Only Memory) 1011 and a RAM 1012. The ROM 1011 stores a boot program such as a BIOS (Basic Input Output System). The hard disk drive interface 1030 is connected to a hard disk drive 1090. The disk drive interface 1040 is connected to a disk drive 1100. A removable storage medium such as a magnetic disk or optical disk is inserted into the disk drive 1100. The serial port interface 1050 is connected to a mouse 1110 and a keyboard 1120, for example. The video adapter 1060 is connected to a display 1130, for example.

[0085] The hard disk drive 1090 stores, for example, an OS 1091, an application program 1092, a program module 1093, and program data 1094. That is, a program that defines each process of the various devices that make up the modification device 100 is implemented as a program module 1093 in which computer-executable code is written. The program module 1093 is stored, for example, in the hard disk drive 1090. For example, a program module 1093 for executing processes similar to those of the functional configurations of the various devices that make up the modification device 100 is stored in the hard disk drive 1090. Note that the hard disk drive 1090 may be replaced with an SSD (Solid State Drive).

[0086] Furthermore, setting data used in the processing of the above-described embodiment is stored as program data 1094, for example, in the memory 1010 or the hard disk drive 1090. Then, the CPU 1020 reads the program module 1093 or the program data 1094 stored in the memory 1010 or the hard disk drive 1090 into the RAM 1012 as necessary, and executes the processing of the above-described embodiment.

[0087] The program module 1093 and program data 1094 are not limited to being stored in the hard disk drive 1090, but may also be stored in, for example, a removable storage medium and read by the CPU 1020 via the disk drive 1100 or the like. Alternatively, the program module 1093 and program data 1094 may be stored in another computer connected via a network (such as a LAN or a WAN (Wide Area Network)). The program module 1093 and program data 1094 may then be read by the CPU 1020 from the other computer via the network interface 1070.

[0088] Although the present embodiment has been described above, the present embodiment is not limited by the descriptions and drawings that form a part of the disclosure. In other words, other embodiments, examples, operational techniques, etc. that are made by those skilled in the art based on the present embodiment are all included in the scope of the present embodiment.

[0089] REFERENCE SIGNS LIST 100 Correction device 110 Communication unit 120 Storage unit 121 Template information DB 130 Control unit 131 Reception unit 132 Generation unit 133 Construction unit 134 Determination unit 135 Correction unit 136 Output unit

Claims

1. A correction device comprising: a construction unit that constructs a first constraint expression that constrains a regular expression for extracting a character string so that the regular expression for extracting a character string accepts a first set of character strings and rejects a second set of character strings, and a second constraint expression for satisfying a syntax condition that does not include a vulnerability related to pattern processing of the regular expression in the regular expression; and a determination unit that determines whether the regular expression for extracting a character string satisfies the first constraint expression and the second constraint expression constructed by the construction unit.

2. The correction device according to claim 1, further comprising a correction unit that changes an operator included in a specified queue whose elements are regular expressions for extracting strings when the judgment unit judges that the element does not satisfy the first constraint expression and the second constraint expression, and replaces a first operator indicating that the regular expression included in the element is being corrected with a second operator indicating a range character when the judgment unit judges that the element satisfies the first constraint expression and the second constraint expression.

3. The correction device described in claim 1 or 2, characterized in that the construction unit accepts strings included in the input first set of strings, does not accept strings included in the second set of strings, and constructs the first constraint equation as a constraint equation that constrains the regular expression for string extraction that extracts strings to be captured from among the strings included in the first set of strings.

4. The modification device according to claim 1 or 2, characterized in that the construction unit constructs the second constraint equation as a constraint equation for satisfying Real-World Strong 1 Unambiguity, which is a syntactic condition of the regular expression that ensures that the regular expression does not include a ReDoS vulnerability.

Citation Information

Patent Citations

  • ReDoS vulnerability detection method and system based on dynamic and static combination

    CN116614270A

  • Modification device, modification method, and modification program

    WO2022113308A1