IP Library Granted Patent US 12705382
Granted Patent B2
US 12705382 · App. 18/647,372 · Granted Aug 11, 2026

System and method for protecting source code from unauthorized access

Inventors: Pushkar Taneja (Telangana, IN); Suryanarayana Adivi (Telangana, IN); Shailendra Singh (Maharashtra, IN); Sunilkumar Sriperambudur (Telangana, IN)
Assignee: Bank of America Corporation
G06F21/6218G06F8/41
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12705382
App. No.
18/647,372
Granted
Aug 11, 2026
Kind
B2
Abstract

A system for protecting source code from unauthorized access is disclosed. The system is configured to scan the source code and identify code segments, including function code. The system may perform code obfuscation, code separation, and code encryption. The system may extract a first set of code features from the function code. The first set of code features indicates a first task associated with the function code. The system accesses a training dataset comprising a sample code that is associated with a second task and a template code. The system compares the first task with the second task. In response to determining that the first task corresponds to the second task, the system obfuscates the function code with the template code. In response, the system updates the source code to include the obfuscated function code.

Claims (96)

1 . A system for securing source code from unauthorized access, comprising:

a memory configured to store:

source code comprising a set of code lines, wherein the set of code lines comprises a first function code; and

a training dataset comprising a set of sample codes, wherein a first sample code from among the set of sample codes is associated with a first task which the first sample code is configured to perform and a first template code; and

a processor, operably coupled to the memory, and configured to:

train a machine learning algorithm on the training dataset to identify which template code from the training dataset is to be added to a given function code of the source code based at least in part upon a task of the given function code, such that the identified template code is configured to perform the task of the given function code, and comprises an irrelevant code segment that does not alter the task;

train the machine learning algorithm on a second set of sample codes, wherein each sample code is associated with a respective set of split code segments after splitting the sample code according to a function splitting rule;

receive an instruction to obfuscate at least a portion of the source code;

in response to receiving the instruction:

scan the source code;

in response to scanning the source code, identify, via the trained machine learning algorithm, a plurality of break points that indicates boundaries to divide the first function code according to the function splitting rule;

split the first function code at the plurality of break points into a plurality of code segments such that each code segment, individually, does not infer a task that the first function code is configured to perform;

extract, via the trained machine learning algorithm, a first set of code features from the first function code, wherein the first set of code features comprises an indication of a second task which the first function code is configured to perform;

compare the first task with the second task;

determine that the first task corresponds to the second task;

in response to determining that the first task corresponds to the second task, obfuscate the first function code, wherein obfuscating the first function code comprises updating the first function code with the first template code, wherein updating the first function code with the first template code comprises replacing at least a portion of the first function code with the first template code; and

update the source code to include the updated first function code.

2 . The system of claim 1 , wherein the processor is further configured to:

generate a first feature vector to represent the first set of code features;

extract, via the trained machine learning algorithm, a second set of code features from the first sample code;

generate a second feature vector to represent the second set of code features;

compare the first feature vector with the second feature vector by determining a distance between the first feature vector and the second feature vector in a vector space; and

determine that the distance between the first feature vector and the second feature vector is less than a threshold distance, wherein determining that the first task corresponds to the second task is in response to determine that the distance between the first feature vector and the second feature vector is less than the threshold distance.

3 . The system of claim 1 , wherein the processor is further configured to:

revert the first function code to an initial state before the source code is compiled;

compile the source code; and

execute the compiled source code to perform the first task.

4 . The system of claim 1 , wherein obfuscating the first function code comprises changing a first variable name used in the first function code to a second variable name, wherein the second variable name is irrelevant to the first task associated with the first function code.

5 . The system of claim 1 , wherein obfuscating the first function code comprises encrypting a comment line associated with a code line in the first function code, wherein the comment line comprises text that describes a function of the code line.

6 . The system of claim 1 , wherein:

the set of code lines further comprises a second function code configured to perform a third task;

the memory is further configured to store the function splitting rule, wherein the function splitting rule indicates that the given function code is to be split such that each split code segment, individually, does not infer a task which the given function code is configured to perform; and

the processor is further configured to obfuscate the second function code by dividing the second function code into a set of code segments according to the function splitting rule.

7 . The system of claim 1 , wherein the processor is further configured to obfuscate the source code by changing a first data structure associated with a portion of the source code to a second data structure, wherein the second data structure is different from data structures associated with other parts of the source code, wherein each of the first data structure and the second data structure comprises at least one of an array, a list, a linked list, or a stack.

8 . A method for securing source code from unauthorized access, comprising:

storing:

source code comprising a set of code lines, wherein the set of code lines comprises a first function code; and

a training dataset comprising a set of sample codes, wherein a first sample code from among the set of sample codes is associated with a first task which the first sample code is configured to perform and a first template code;

training a machine learning algorithm on the training dataset to identify which template code from the training dataset is to be added to a given function code of the source code based at least in part upon a task of the given function code, such that the identified template code is configured to perform the task of the given function code, and comprises an irrelevant code segment that does not alter the task;

training the machine learning algorithm on a second set of sample codes, wherein each sample code is associated with a respective set of split code segments after splitting the sample code according to a function splitting rule;

receiving an instruction to obfuscate at least a portion of the source code;

in response to receiving the instruction:

scanning the source code; and

in response to scanning the source code, identifying, via the trained machine learning algorithm, a plurality of break points that indicates boundaries to divide the first function code according to the function splitting rule;

splitting the first function code at the plurality of break points into a plurality of code segments such that each code segment, individually, does not infer a task that the first function code is configured to perform;

extracting, via the trained machine learning algorithm, a first set of code features from the first function code, wherein the first set of code features comprises an indication of a second task which the first function code is configured to perform;

comparing the first task with the second task;

determining that the first task corresponds to the second task;

in response to determining that the first task corresponds to the second task, obfuscating the first function code, wherein obfuscating the first function code comprises updating the first function code with the first template code, wherein updating the first function code with the first template code comprises replacing at least a portion of the first function code with the first template code; and

updating the source code to include the updated first function code.

9 . The method of claim 8 , further comprising:

generating a first feature vector to represent the first set of code features;

extracting, via the trained machine learning algorithm, a second set of code features from the first sample code;

generating a second feature vector to represent the second set of code features;

comparing the first feature vector with the second feature vector by determining a distance between the first feature vector and the second feature vector in a vector space;

determining that the distance between the first feature vector and the second feature vector is less than a threshold distance, wherein determining that the first task corresponds to the second task is in response to determining that the distance between the first feature vector and the second feature vector is less than the threshold distance.

10 . The method of claim 8 , further comprising:

reverting the first function code to an initial state before the source code is compiled; compiling the source code; and

executing the compiled source code to perform the first task.

11 . The method of claim 8 , wherein obfuscating the first function code comprises changing a first variable name used in the first function code to a second variable name, wherein the second variable name is irrelevant to the first task associated with the first function code.

12 . The method of claim 8 , wherein obfuscating the first function code comprises encrypting a comment line associated with a code line in the first function code, wherein the comment line comprises text that describes a function of the code line.

13 . The method of claim 8 , wherein:

the set of code lines further comprises a second function code configured to perform a third task; and

the method further comprises:

storing the function splitting rule, wherein the function splitting rule indicates that the given function code is to be split such that each split code segment, individually, does not infer a task which the given function code is configured to perform; and

obfuscating the second function code by dividing the second function code into a set of code segments according to the function splitting rule.

14 . The method of claim 8 , further comprising obfuscating the source code by changing a first data structure associated with a portion of the source code to a second data structure, wherein the second data structure is different from data structures associated with other parts of the source code, wherein each of the first data structure and the second data structure comprises at least one of an array, a list, a linked list, or a stack.

15 . A non-transitory computer-readable medium storing instructions that, when executed by a processor, cause the processor to:

train a machine learning algorithm on a training dataset to identify which template code from the training dataset is to be added to a given function code of source code based at least in part upon a task of the given function code, such that the identified template code is configured to perform the task of the given function code, and comprises an irrelevant code segment that does not alter the task;

train the machine learning algorithm on a second set of sample codes, wherein each sample code is associated with a respective set of split code segments after splitting the sample code according to a function splitting rule;

receive an instruction to obfuscate at least a portion of the source code, wherein the source code comprises a set of code lines comprising a first function code;

in response to receiving the instruction:

scan the source code;

in response to scanning the source code, identify, via the trained machine learning algorithm, a plurality of break points that indicates boundaries to divide the first function code according to the function splitting rule;

split the first function code at the plurality of break points into a plurality of code segments such that each code segment, individually, does not infer a task that the first function code is configured to perform;

extract, via the trained machine learning algorithm, a first set of code features from the first function code, wherein the first set of code features comprises an indication of a second task which the first function code is configured to perform;

access the training dataset comprising a set of sample codes, wherein a first sample code from among the set of sample codes is associated with a first task which the first sample code is configured to perform and a first template code;

compare the first task with the second task;

determine that the first task corresponds to the second task;

in response to determining that the first task corresponds to the second task, obfuscate the first function code, wherein obfuscating the first function code comprises updating the first function code with the first template code, wherein updating the first function code with the first template code comprises replacing at least a portion of the first function code with the first template code; and

update the source code to include the updated first function code.

16 . The non-transitory computer-readable medium of claim 15 , wherein the instructions further cause the processor to:

generate a first feature vector to represent the first set of code features;

extract, via the trained machine learning algorithm, a second set of code features from the first sample code;

generate a second feature vector to represent the second set of code features;

compare the first feature vector with the second feature vector by determining a distance between the first feature vector and the second feature vector in a vector space; and

determine that the distance between the first feature vector and the second feature vector is less than a threshold distance, wherein determining that the first task corresponds to the second task is in response to determine that the distance between the first feature vector and the second feature vector is less than the threshold distance.

17 . The non-transitory computer-readable medium of claim 15 , wherein the instructions further cause the processor to:

revert the first function code to an initial state before the source code is compiled; compile the source code; and

execute the compiled source code to perform the first task.

18 . The non-transitory computer-readable medium of claim 15 , wherein obfuscating the first function code comprises changing a first variable name used in the first function code to a second variable name, wherein the second variable name is irrelevant to the first task associated with the first function code.

19 . The non-transitory computer-readable medium of claim 15 , wherein obfuscating the first function code comprises encrypting a comment line associated with a code line in the first function code, wherein the comment line comprises text that describes a function of the code line.

20 . The non-transitory computer-readable medium of claim 15 , wherein the instructions further cause the processor to:

receive a request to access the source code; and

determine that the request has originated from an unknown computing device, wherein determining that the request has originated from the unknown computing device comprises determining that an internet protocol (IP) associated with the unknown computing device is not among a set of authorized IP addresses; and

obfuscate the first function code is in response to determining that the request has originated from the unknown computing device.