Skip to main content
QUICK REVIEW

[Paper Review] Large Language Models for Code Analysis: Do LLMs Really Do Their Job?

Chongzhou Fang, Ning Miao|arXiv (Cornell University)|Oct 18, 2023
Natural Language Processing TechniquesComputer Science11 citations
TL;DR

The paper systematically evaluates publicly available LLMs (GPT-3.5/4, LLaMA-2-13B variants) on code analysis tasks, including non-obfuscated and obfuscated code, and presents two real-world malware case studies to assess capabilities and limitations.

ABSTRACT

Large language models (LLMs) have demonstrated significant potential in the realm of natural language understanding and programming code processing tasks. Their capacity to comprehend and generate human-like code has spurred research into harnessing LLMs for code analysis purposes. However, the existing body of literature falls short in delivering a systematic evaluation and assessment of LLMs' effectiveness in code analysis, particularly in the context of obfuscated code. This paper seeks to bridge this gap by offering a comprehensive evaluation of LLMs' capabilities in performing code analysis tasks. Additionally, it presents real-world case studies that employ LLMs for code analysis. Our findings indicate that LLMs can indeed serve as valuable tools for automating code analysis, albeit with certain limitations. Through meticulous exploration, this research contributes to a deeper understanding of the potential and constraints associated with utilizing LLMs in code analysis, paving the way for enhanced applications in this critical domain.

Motivation & Objective

  • Assess whether LLMs understand and analyze source code across languages (JavaScript, Python, C).
  • Evaluate LLMs' ability to comprehend obfuscated code and code with low readability.
  • Provide real-world case studies applying LLMs to malware analysis to gauge defensive utility.

Proposed method

  • Construct datasets of non-obfuscated and obfuscated code across multiple languages (JavaScript, Python, C).
  • Obfuscate JavaScript code with four schemes and include IOCCC samples for de-obfuscation challenges.
  • Evaluate multiple LLMs (GPT-3.5-turbo, GPT-4, LLaMA-2-13B, Code-LLaMA-2-13B-instruct) on code analysis tasks.
  • Manual ground-truth labeling of explanations using GPT-4 as a reference and compute cosine similarity, BERT-based semantic similarity, and GPT-4 based accuracy as metrics.
  • Test de-obfuscated code generation and compilation/run feasibility for IOCCC-derived samples.
  • Conduct two case studies analyzing decompiled Android malware and WannaCry ransomware to illustrate practical defensive analysis.
(a) C.
(a) C.

Experimental results

Research questions

  • RQ1RQ1: Do LLMs understand source code?
  • RQ2RQ2: Can LLMs comprehend obfuscated or low-readability code?
  • RQ3How do publicly available LLMs perform on real-world code analysis and malware analysis tasks?

Key findings

  • GPT-4 achieves high accuracy on non-obfuscated code across C, JavaScript, and Python, with an overall accuracy of 97.4%.
  • Smaller models like LLaMA-2-13B and Code-LLaMA-2-13B-instruct struggle to produce meaningful code analyses.
  • Obfuscated JavaScript degrades GPT-3.5 and GPT-4 performance, with GPT-4 achieving 87% accuracy on obfuscated code.
  • GPT-4 generally outperforms GPT-3.5 in obfuscated settings, though both are affected; basic obfuscation (e.g., identifier renaming) only slightly reduces performance for GPT models.
  • De-obfuscation of IOCCC-style C code by GPT models is challenging; compilable and correct runnable results are rare (GPT-3.5 ~8% correct runnable, GPT-4 ~4% correct runnable among tested samples).
  • GPT-4 shows better ability to associate inputs with IOCCC examples but often cannot provide exact year/author details; GPT-3.5 identifies fewer IOCCC samples.
(b) Python.
(b) Python.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.