# US 9,639,703 B2 · Method, system, and computer program product for automatically mitigating vulnerabilities in source code

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 9,639,703 B2
- Document ID: US9639703B2
- Status: Granted
- Kind: B2
- Application number: 14/845,281
- Filed: 2015-09-04
- Published: 2015-12-31
- Granted: 2017-05-02
- Earliest claimed: 2013-05-29
- Assignees: Lucent Sky Corporation
- Applicants: Lucent Sky Corporation
- Inventors: Jim Liu
- Web page: https://patentgrep.com/patent/US9639703B2

## CPC

- H04L 63/1433: {Vulnerability analysis}
- G06F 8/41: Compilation
- G06F 8/42: {Syntactic analysis}
- G06F 8/43: {Checking; Contextual analysis}
- G06F 21/53: by executing in a restricted environment, e.g. sandbox or secure virtual machine
- G06F 21/577: {Assessing vulnerabilities and evaluating computer system security}
- H04L 63/14: {for detecting or protecting against malicious traffic}
- H04L 63/1425: {Traffic logging, e.g. anomaly detection}
- H04L 63/1466: {Active attacks involving interception, injection, modification, spoofing of data unit addresses, e.g. hijacking, packet injection or TCP sequence number attacks}
- G06F 2221/033: Test or assess software
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method for automatically mitigating vulnerabilities in a source code of an application is provided in the present invention. The method includes the following steps. First, the source code is complied, and a path graph is built according to the compiled source code. The path graph includes a plurality of paths traversing from sources to sinks, and each of the paths includes a plurality of nodes. Then, at least one tainted path is identified by enabling a plurality of vulnerability rules. Each of the at least one tainted path corresponds to a vulnerability, and each of the at least one vulnerability corresponds to a sanitization method. Then, the at least one vulnerability is determined if it is mitigable. If the at least one vulnerability is mitigable, the at least one vulnerability is mitigated automatically. Furthermore, the method may be implemented as a system and a computer program product.

## Claims

### Claim 1

A method for automatically mitigating vulnerabilities in a source code of an application via static analysis comprising:
building a path graph according to the source code, wherein the path graph comprises a plurality of paths traversing from sources to sinks, and wherein each of the paths comprises a plurality of nodes;
identifying at least one tainted path from the path graph, wherein each of the at least one tainted path corresponds to a vulnerability;
locating a target node in each of the at least one tainted path based on an existence of a tainted object and a result of syntax analysis comprising:
obtaining a list of candidate nodes from each of the at least one tainted path based on the existence of the tainted object;
performing syntax analysis on each of the candidate nodes and accordingly evaluating a priority order for each of the candidate nodes; and
selecting the target node from the candidate nodes based on the priority orders comprising:
identifying and setting the candidate node with the highest priority order in each of the at least one tainted path as the target node, wherein when there exists more than one candidate node with the same highest priority order in each of the at least one tainted path, setting the node with the same highest priority order and closest to the sink in each of the at least one tainted path as the target node; and
mitigating at least one vulnerability in the target node in each of the at least one tainted path automatically.

### Claim 2 (depends on 1)

The method of claim 1, wherein before the step of building the path graph according to the source code, the method further comprises:
compiling the source code.

### Claim 3 (depends on 1)

The method of claim 1, wherein the step of identifying the at least one tainted path from the path graph comprising:
performing data flow analysis on the path graph; and
identifying the at least one tainted path by enabling a plurality of vulnerability rules.

### Claim 4 (depends on 1)

The method of claim 1, wherein the step of performing the syntax analysis on each of the candidate nodes and evaluating the priority order for each of the candidate nodes comprising:
determining whether each of the candidate nodes in each of the at least one tainted path contains at least one of predefined strings, symbols, tokens, operators, variables, methods, and functions; and
if so, changing the priority order of the corresponding candidate node.

### Claim 5 (depends on 1)

The method of claim 1, wherein the step of performing the syntax analysis on each of the candidate nodes and evaluating the priority order for each of the candidate nodes comprising:
determining whether each of the candidate nodes in each of the at least one tainted path does not contain at least one of predefined strings, symbols, tokens, operators, variables, methods, and functions; and
if so, changing the priority order of the corresponding candidate node.

### Claim 6 (depends on 1)

The method of claim 1, wherein the step of evaluating the priority order of each of the candidate nodes comprising:
applying an instant-fix call on the candidate nodes in each of the at least one tainted path based on the corresponding vulnerability rule;
determining whether amended source code corresponding to the instant-fix call is compilable; and
if not, setting the corresponding candidate node to the lowest priority order.

### Claim 7 (depends on 1)

The method of claim 1, wherein after the step of locating the target node in each of the at least one tainted path based on the existence of the tainted object and the result of the syntax analysis comprising:
determining whether the target node in each of the at least one tainted path corresponds to at least one other tainted path;
when the target node in each of the at least one tainted path corresponds to the at least one other tainted path, determining whether each same target node corresponds to different vulnerabilities; and
when the same target node does not correspond to different vulnerabilities, removing the at least one other tainted path; and
when the same target node corresponds to different vulnerabilities, applying multiple instant-fix calls on the different vulnerabilities in the same target node.

### Claim 8 (depends on 1)

The method of claim 1, wherein after the step of mitigating the at least one vulnerability in the target node in each of the at least one tainted path automatically, the method further comprises:
evaluating and storing a confidence score corresponding to each of the at least one tainted path.

### Claim 9

A computer system for automatically mitigating vulnerabilities in a source code of an application via static analysis comprising:
a memory;
a processor coupled to the memory and configured for:
building a path graph according to the source code, wherein the path graph comprises a plurality of paths traversing from sources to sinks, and wherein each of the paths comprises a plurality of nodes;
identifying at least one tainted path from the path graph, wherein each of the at least one tainted path corresponds to a vulnerability;
locating a target node in each of the at least one tainted path based on an existence of a tainted object and a result of syntax analysis comprising:
obtaining a list of candidate nodes from each of the at least one tainted path based on the existence of the tainted object;
performing syntax analysis on each of the candidate nodes and accordingly evaluating a priority order for each of the candidate nodes; and
selecting the target node from the candidate nodes based on the priority orders comprising:
identifying and setting the candidate node with the highest priority order in each of the at least one tainted path as the target node, wherein when there exists more than one candidate node with the same highest priority order in each of the at least one tainted path, setting the node with the same highest priority order and closest to the sink in each of the at least one tainted path as the target node; and
mitigating at least one vulnerability in the target node in each of the at least one tainted path automatically.

### Claim 10 (depends on 9)

The computer system in claim 9, wherein the processor further compiles the source code before building the path graph.

### Claim 11 (depends on 10)

The computer system in claim 10, wherein:
the processor determines whether the target node in each of the at least one tainted path corresponds to at least one other tainted path,
when the target node in each of the at least one tainted path corresponds to the at least one other tainted path, the processor determines whether each same target node corresponds to different vulnerabilities,
when the same target node does not correspond to different vulnerabilities, the processor removes the at least one other tainted path, and
when the same target node corresponds to different vulnerabilities, the processor applies multiple instant-fix calls on the different vulnerabilities in the same target node based on the result of the syntax analysis.

### Claim 12 (depends on 9)

The computer system in claim 9, wherein the processor performs data flow analysis on the path graph and identifies the at least one tainted path by enabling a plurality of vulnerability rules.

### Claim 13 (depends on 9)

The computer system in claim 9, wherein the processor determines whether each of the candidate nodes in each of the at least one tainted path contains at least one of predefined strings, symbols, tokens, operators, variables, methods, and functions, and wherein if so, the processor changes the priority order of the corresponding candidate node.

### Claim 14 (depends on 9)

The computer system in claim 9, wherein the processor determines whether each of the candidate nodes in each of the at least one tainted path does not contain at least one of predefined strings, symbols, tokens, operators, variables, methods and functions, and wherein if so, the processor changes the priority order of the corresponding candidate node.

### Claim 15 (depends on 9)

The computer system in claim 9, wherein the processor applies an instant-fix call on the candidate nodes in each of the at least one tainted path based on the corresponding vulnerability rule, determines whether amended source code corresponding to the instant-fix call is compilable, and wherein if not, the processor sets the corresponding candidate node to the lowest priority order.

### Claim 16

A non-transitory computer-readable medium comprising a plurality of program instructions, which when executed by a computer system, cause the computer system to execute steps of:
building a path graph according to the source code, wherein the path graph comprises a plurality of paths traversing from sources to sinks, and wherein each of the paths comprises a plurality of nodes;
identifying at least one tainted path from the path graph, wherein each of the at least one tainted path corresponds to a vulnerability;
locating a target node in each of the at least one tainted path based on an existence of a tainted object and a result of syntax analysis comprising:
obtaining a list of candidate nodes from each of the at least one tainted path based on the existence of the tainted object;
performing syntax analysis on each of the candidate nodes and accordingly evaluating a priority order for each of the candidate nodes; and
selecting the target node from the candidate nodes based on the priority orders comprising:
identifying and setting the candidate node with the highest priority order in each of the at least one tainted path as the target node, wherein when there exists more than one candidate node with the same highest priority order in each of the at least one tainted path, setting the node with the same highest priority order and closest to the sink in each of the at least one tainted path as the target node; and
mitigating at least one vulnerability in the target node in each of the at least one tainted path automatically.
