# US 2017/0161498 A1 · Systems and methods for detection of malicious code in runtime generated code

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

- Number: US 2017/0161498 A1
- Document ID: US20170161498A1
- Status: Published application
- Kind: A1
- Application number: 15/257,935
- Filed: 2016-09-07
- Published: 2017-06-08
- Earliest claimed: 2015-12-08
- Assignees: enSilo Ltd.
- Applicants: enSilo Ltd.
- Inventors: Udi YAVO
- Web page: https://patentgrep.com/patent/US20170161498A1

## CPC

- G06F 21/566: {Dynamic detection, i.e. detection performed at run-time, e.g. emulation, suspicious activities}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

According to an aspect of some embodiments of the present invention there is provided a computer-implemented method for detection of malicious code within runtime generated code executing within a computer, comprising executing on a processor of the computer the acts of: receiving an indication of at least one of the creation and the execution of runtime generated code in a memory of a computer; identifying a match between signature data associated with the runtime generated code and a template signature of a plurality of templates representing authorized source creation modules that created the runtime generated code, the templates stored in a repository on a storage device; and triggering a security process to handle malicious code in the runtime generated code when no match is found.

## Claims

### Claim 1

A computer-implemented method for detection of malicious code within runtime generated code executing within a computer, comprising executing on a processor of the computer the acts of:
receiving an indication of at least one of the creation and the execution of runtime generated code in a memory of a computer;
identifying a match between signature data associated with the runtime generated code and a template signature of a plurality of templates representing authorized source creation modules that created the runtime generated code, the templates stored in a repository on a storage device; and
triggering a security process to handle malicious code in the runtime generated code when no match is found.

### Claim 2 (depends on 1)

The method of claim 1, wherein the template signature represents an authorized just in time (JIT) compiler.

### Claim 3 (depends on 2)

The method of claim 2, wherein identifying the match between the signature data and the template signature comprises at least one of:
identifying an association between a first executable module called by the runtime generated code to invoke an operating system function, and the template representing the authorized JIT compiler, and
identifying an association between a second executable module creating the runtime generated code and the template representing the authorized JIT compiler.

### Claim 4 (depends on 2)

The method of claim 2, wherein the signature data comprises a predefined size of an area in the memory storing the runtime generated code.

### Claim 5 (depends on 2)

The method of claim 2, wherein the signature data comprises a designation of a memory region storing the runtime generated code as read-only or no-access.

### Claim 6 (depends on 2)

The method of claim 2, wherein the signature data comprises at least one code pattern.

### Claim 7 (depends on 6)

The method of claim 6, wherein the at least one code pattern includes at least one member selected from the group consisting of: at least one predefined prolog at a start region of at least one function of the runtime generated code, at least one epilogue, and at least one magic operand value.

### Claim 8 (depends on 2)

The method of claim 2, wherein the signature data comprises predefined control structures related to the JIT compiler at least one of at a start region and an end region of the runtime generated code.

### Claim 9 (depends on 8)

The method of claim 8, wherein the predefined control structures include at least one of: a linked list at each of a plurality of different memory regions each storing a portion of the runtime generated code, and fields defining size and address of the respective memory region located after the respective linked list.

### Claim 10 (depends on 9)

The method of claim 9, wherein the linked list is verified by traversing pointers of each memory region, and the fields are verified by correlating the values of the fields with operating system values.

### Claim 11 (depends on 2)

The method of claim 2, wherein the signature data comprises an application associated with the runtime generated code to which the authorized JIT compiler is restricted.

### Claim 12 (depends on 1)

The method of claim 1, wherein the template signature represents an authorized hook engine.

### Claim 13 (depends on 12)

The method of claim 12, wherein the signature data includes identification that the runtime generated code is created by a hook engine, the identifying performed by at least one of:
emulating preexisting code at the prolog of a hooked module to reach outside code residing outside of the hooked module; and
analyzing a stack trace related to the outside code to identify the runtime generated code by locating the position of the runtime generated code as appearing in the stack trace before the authorized hook engine executable that installed the hook.

### Claim 14 (depends on 12)

The method of claim 12, wherein the signature data includes at least one member selected from the group consisting of: a predefined size of the memory area where the runtime generated code resides, at least one code pattern, predefined control structures at least at one of at a start portion and an end portion of the runtime generated code memory region, and an opcode signature calculated from assembly obtained by applying a disassemble program to the runtime generated code excluding mutable parameters.

### Claim 15 (depends on 14)

The method of claim 14, wherein the at least one code pattern includes at least one member selected from the group consisting of: at least one predefined prolog at a start region of at least one function of the runtime generated code, at least one epilogue, and at least one magic operand value.

### Claim 16 (depends on 1)

The method of claim 1, wherein the template signature represents an authorized executable compressor.

### Claim 17 (depends on 16)

The method of claim 16, wherein the signature data includes at least one member selected from the group consisting of: size of a memory allocation according to a format of the decompressed executable file, a cryptographic hash function calculated over immutable portions of the executable file structure and code, and permissions on memory pages where the decompressed executable file resides.

### Claim 18 (depends on 17)

The method of claim 17, further comprising verifying that contents of the memory at the base of the memory allocation is according to the format of the decompressed executable file by parsing contents of the memory allocation according to the format of the decompressed executable file, and checking that field values are logical and conform to the format.

### Claim 19

A system for detection of runtime generated code containing malicious code, comprising:
a memory for storing code;
a storage device for storing a repository of templates representing authorized;
source creation modules that create runtime generated code;
a program store storing code; and
a processor coupled to the memory, the storage device, and the program store for implementing the stored code, the stored code comprising:
stored code to receive an indication of at least one of the creation and the execution of runtime generated code in the memory, identify a match between signature data associated with the runtime generated code and a template signature of the repository; and trigger a security process to handle malicious code in the runtime generated code when no match is found.

### Claim 20

A computer program product comprising a non-transitory computer readable storage medium storing program code thereon for implementation by a processor of a system for detection of runtime generated code containing malicious code, the program code comprising:
instructions to receive an indication of at least one of the creation and the execution of runtime generated code in a memory of a computer;
instructions to identify a match between signature data associated with the runtime generated code and a template signature of a set of templates representing authorized source creation modules that create runtime generated code; and
instructions to trigger a security process to handle malicious code in the runtime generated code when no match is found.
