Dynamic Decimation of Token N-grams for Code Similarity

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Conventional methods for identifying code similarity and detecting malware or related code variants in binaries and text samples face challenges in achieving rapid bulk processing speed and library capacity, limiting their effectiveness in addressing the need for efficient malware detection and code provenance analysis.

Innovation Solution

The proposed solution involves generating 'fingerprints' or 'DNA' strings through lossy compression of binary code, which are then processed using n-gram based scoring and dynamic decimation to efficiently identify similarities, allowing for scalable and efficient comparison of code variants and malware detection.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If conventional n-gram based similarity detection methods are used, then code similarity can be identified, but processing speed and library capacity are insufficient for rapid bulk processing

Engineering Contradiction:
Improveprocessing speedVSAvoidsimilarity detection accuracy
Core Design Contradiction:
ProductivityVSMeasurement precision

Solution Approach 1:

The patent segments the code into fixed-length substrings called n-grams, where each n-gram represents a contiguous sequence of characters or tokens. This segmentation transforms the code into a collection of discrete units that can be processed independently and efficiently, enabling rapid bulk processing while maintaining similarity detection capability through statistical comparison of n-gram distributions

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The patent changes the parameter of n-gram length from variable to fixed, and introduces a decimation factor to control the density of n-grams retained for comparison. By adjusting these parameters, the system can optimize between processing speed (higher decimation) and similarity detection precision (lower decimation), resolving the contradiction through parameter tuning

Inventive Principle:
Principle #35Parameter changes

2Measurement precision

If all n-grams are retained for comparison, then similarity detection precision is maintained, but memory requirements and processing overhead increase significantly

Engineering Contradiction:
Improvesimilarity detection accuracyVSAvoidmemory usage
Core Design Contradiction:
Measurement precisionVSQuantity of substance

Solution Approach 1:

The patent extracts only a subset of n-grams from the full set by applying a decimation factor, which selectively retains certain n-grams while discarding others. This extraction process reduces the quantity of data stored in memory and processed during comparison, while the extracted subset maintains sufficient statistical properties for accurate similarity detection

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The patent applies partial action by retaining only a fraction (1/F where F is the decimation factor) of the total n-grams for comparison. This partial retention is sufficient to maintain similarity detection precision while dramatically reducing memory usage and processing overhead, especially for large code bases

Inventive Principle:
Principle #16Partial or excessive action

3Productivity

If dynamic decimation with variable factors is applied, then processing efficiency improves, but system complexity increases

Engineering Contradiction:
Improveprocessing efficiencyVSAvoidsystem complexity
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The patent introduces dynamic decimation where the decimation factor F varies based on the size and characteristics of the code being processed. For larger code bases, higher decimation factors are applied to maintain efficiency, while smaller codes use lower factors to preserve precision. This dynamic adjustment optimizes processing efficiency across different scenarios without requiring fundamentally different systems

Inventive Principle:
Principle #15Dynamics

Data Source

PatentUS9910985B2Apparatus and method for identifying similarity via dynamic decimation of token sequence N-grams
Publication Date: 2018.03.06 JOHNS HOPKINS UNIVERSITY
  • US9910985B2 patent drawing
  • US9910985B2 patent drawing
  • US9910985B2 patent drawing

AI summary

An apparatus for identifying related code variants or text samples includes processing circuitry configured to execute instructions for receiving query binary code, processing the query binary code to generate one or more query code fingerprints comprising compressed representations of respective functional components of the query binary code, generating token sequence n-grams of the fingerprints, hashing the n-grams, partitioning samples by length to compare selected samples based on length, and identifying similarity via dynamic decimation of token sequence n-grams.