IP Library Granted Patent US 12664256
Granted Patent B2
US 12664256 · App. 18/953,612 · Granted Jun 23, 2026

Securing programmatically-generated code

Inventors: Jeremy R. Fox (Georgetown, TX); Logan Bailey (Atlanta, GA); Zachary Augustus Silverstein (Georgetown, TX); Suman Patra (Raritan, NJ)
Assignee: International Business Machines Corporation
G06F21/53G06F8/35G06F21/577G06N3/0475G06F2221/033
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 12664256
App. No.
18/953,612
Granted
Jun 23, 2026
Kind
B2
Abstract

A computer-implemented method for training a large language model (LLM) on a plurality of programming languages to recognize common coding patterns and generating, using the trained LLM, software code based on user-defined inputs. The method further includes analyzing the generated software code to identify destructive code and determining a reversal of the generated software code from a current state to a previous state is required based on the destructive code. Responsive to the determining that a reversal is required, the method may include running the generated software code comprising the destructive code in a controlled and isolated environment and providing a user with a reversal function that causes the generated software code to revert from the current state to the previous state. The method further includes executing the generated software code.

Claims (60)

1 . A computer-implemented method, comprising:

training, by a processor set, a large language model (LLM) on a plurality of programming languages to recognize common coding patterns;

generating, by the processor set using the trained LLM, software code based on user-defined inputs;

analyzing, by the processor set, the generated software code to identify destructive code;

determining, by the processor set, a reversal of the generated software code from a current state to a previous state is required based on the destructive code;

responsive to the determining that the reversal is required:

running, by the processor set, the generated software code comprising the destructive code in a controlled and isolated environment; and

providing, by the processor set, a user with a reversal function, that when executed by the user, causes the generated software code to revert from the current state to the previous state; and

responsive to a determination that running the generated software code comprising the destructive code does not result in a system error, executing, by the processor set, the generated software code.

2 . The computer-implemented method of claim 1 , further comprising:

determining, by the processor set, that running the generated software code comprising the destructive code results in a system error; and

responsive to detecting the system error, retraining the LLM based on the generated software code including the destructive code and an associated system error.

3 . The computer-implemented method of claim 2 , further comprising regenerating the software code based on the user-defined inputs using the retrained LLM.

4 . The computer-implemented method of claim 1 , further comprising determining a risk score for the destructive code;

responsive to the risk score exceeding a predetermined threshold, rejecting the generated software code; and

responsive to rejecting the software code, generating a second software code based on factors used to determine the risk score and based on the user-defined inputs.

5 . The computer-implemented method of claim 1 , wherein determining the reversal of the generated software code from the current state to the previous state is required is further based on an identified risk level associated with executing the generated code including the destructive code in a runtime environment.

6 . The computer-implemented method of claim 1 , further comprising configuring the LLM based on the user-defined inputs, wherein the user-defined inputs comprise reserved keywords, constraints, and known vulnerabilities.

7 . The computer-implemented method of claim 6 , wherein the common coding patterns comprise loops, conditional statements, and function declarations.

8 . A computer program product comprising:

one or more computer-readable storage media; and

program instructions stored on the one or more computer-readable storage media to perform operations comprising:

training a large language model (LLM) on a plurality of programming languages to recognize common coding patterns;

generating, using the trained LLM, software code based on user-defined inputs;

analyzing the generated software code to identify destructive code;

determining a reversal of the generated software code from a current state to a previous state is required based on the destructive code;

responsive to the determining that the reversal is required:

running the generated software code comprising the destructive code in a controlled and isolated environment; and

providing a user with a reversal function, that when executed by the user, causes the generated software code to revert from the current state to the previous state; and

responsive to a determination that running the generated software code comprising the destructive code does not result in a system error, executing the generated software code.

9 . The computer program product of claim 8 , wherein the operations further comprise:

determining that running the generated software code comprising the destructive code results in a system error; and

responsive to detecting the system error, retraining the LLM based on the generated software code including the destructive code and an associated system error.

10 . The computer program product of claim 9 , wherein the operations further comprise regenerating the software code based on the user-defined inputs using the retrained LLM.

11 . The computer program product of claim 8 , wherein the operations further comprise:

determining a risk score for the destructive code;

responsive to the risk score exceeding a predetermined threshold, rejecting the generated software code; and

responsive to rejecting the software code, generating a second software code based on factors used to determine the risk score and based on the user-defined inputs.

12 . The computer program product of claim 8 , wherein determining the reversal of the generated software code from the current state to the previous state is required is further based on an identified risk level associated with executing the generated code including the destructive code in a runtime environment.

13 . The computer program product of claim 8 , wherein the operations further comprise configuring the LLM based on the user-defined inputs, wherein the user-defined inputs comprise reserved keywords, constraints, and known vulnerabilities.

14 . The computer program product of claim 13 , wherein the common coding patterns comprise loops, conditional statements, and function declarations.

15 . A computer system comprising:

a processor set;

one or more computer-readable storage media; and

program instructions stored on the one or more computer-readable storage media to cause the processor set to perform operations comprising:

training a large language model (LLM) on a plurality of programming languages to recognize common coding patterns;

generating, using the trained LLM, software code based on user-defined inputs;

analyzing, the generated software code to identify destructive code;

determining a reversal of the generated software code from a current state to a previous state is not required based on the destructive code;

responsive to the determining that the reversal is required:

running the generated software code comprising the destructive code in a controlled and isolated environment; and

providing a user with a reversal function, that when executed by the user, causes the generated software code to revert from the current state to the previous state; and

responsive to a determination that running the generated software code comprising the destructive code does not result in a system error, executing the generated software code.

16 . The computer system of claim 15 , wherein the operations further comprise:

determining, by the processor set, that running the generated software code comprising the destructive code results in a system error; and

responsive to detecting the system error, retraining the LLM based on the generated software code including the destructive code and an associated system error.

17 . The computer system of claim 16 , wherein the operations further comprise regenerating the software code based on the user-defined inputs using the retrained LLM.

18 . The computer system of claim 15 , wherein determining a reversal of the generated software code from the current state to the previous state is required is further based on an identified risk level associated with executing the generated code including the destructive code in a runtime environment.

19 . The computer system of claim 18 , wherein the operations further comprise configuring the LLM based on the user-defined inputs, wherein the user-defined inputs comprise reserved keywords, constraints, and known vulnerabilities.

20 . The computer system of claim 19 , wherein the common coding patterns comprise loops, conditional statements, and function declarations.