JsDeObsBench: Measuring and Benchmarking LLMs for JavaScript Deobfuscation

Guoqiang Chen, Xin Jin, Zhiqiang Lin

TL;DR

Researchers from The Ohio State University have introduced JsDeObsBench, the first comprehensive benchmark designed to evaluate how well Large Language Models (LLMs) can deobfuscate JavaScript. While LLMs excel at making messy, obfuscated code significantly more readable and "human-like" than traditional tools, they still struggle with semantic reliability, often introducing subtle bugs that break the code’s original logic.

What Problem Does This Paper Address?

JavaScript obfuscation is a double-edged sword. While developers use it to protect intellectual property or minify code for performance, cybercriminals use it to hide malicious logic from security scanners. Traditional deobfuscators are often "brittle"—they rely on hard-coded rules and heuristics that fail against sophisticated, multi-layered transformations.

Recently, security analysts have started using LLMs like GPT-4 to "clean up" suspicious scripts. However, there hasn't been a systematic way to measure if these models are actually preserving the code's original behavior or just hallucinating a cleaner-looking version of it. The authors identify three main gaps: a lack of large-scale datasets with "ground truth" (the original source code), the absence of execution-based verification, and a lack of metrics that measure code readability rather than just variable name recovery.

Methods

The authors built an automated pipeline to bridge these gaps:

  1. Dataset Curation: They started with high-quality, human-written JS solutions from coding challenges (CodeNet) to ensure the code was functional and had associated test cases.
  2. Automated Obfuscation: They applied seven common obfuscation techniques (e.g., control flow flattening, dead code injection, and string obfuscation) using the popular javascript-obfuscator tool to create a massive library of "ground truth" pairs.
  3. LLM Prompting: They tested six state-of-the-art models (including GPT-4o, Llama-3.1, and Codestral) using both zero-shot and one-shot prompting to see how in-context learning affects performance.
  4. Multi-Dimensional Evaluation: Instead of just looking at the text, they used four evaluators:
  5. Syntax: Does it even run? (Parsed via Esprima).
  6. Execution: Does it pass the original test cases in a sandboxed Docker environment?
  7. Simplification: How much was the complexity reduced? (Measured via Halstead length).
  8. Similarity: How close is it to the original human-written code? (Measured via CodeBLEU).

Datasets

The paper introduces two primary datasets:

  • JsDeObsBench-General: 36,260 unique obfuscated programs derived from 1,298 original JS problems, each with functional test cases.
  • JsDeObsBench-Malware: 4,515 malicious JS programs. Since malware doesn't come with "test cases," the authors used behavioral traces (API calls, file system changes) as a proxy to verify that the deobfuscated version still "acts" like the original malware.

Key Insights and Ideas

  • Readability vs. Reliability: LLMs are "beautification" masters. They outperformed traditional rule-based baselines in simplification scores by a wide margin (e.g., 1.72x better). However, they are less reliable; while traditional tools almost never break the code's logic, LLMs had an average execution failure rate of 37.4%.
  • The "Safety Filter" Paradox: When testing GPT-4o on the malware dataset, it had a very low success rate. This wasn't because it couldn't do the task, but because its safety alignment triggered a "Refuse to Response" error when it detected it was being asked to handle malicious code—even for a defensive security analysis task.
  • Code-Specific Models Win: Models specifically trained on code (like Codestral and DeepSeek-Coder) generally outperformed general-purpose models of similar sizes. They were more robust against complex structural changes like control flow flattening.
  • One-Shot is the Sweet Spot: Providing just a single example of a deobfuscation task in the prompt improved syntax and execution correctness by 11% and 14%, respectively.

Key Results

  • Top Performer: GPT-4o achieved the highest execution correctness (93.4%) and similarity scores (0.67 CodeBLEU) on general tasks, though it struggled with malware due to safety filters.
  • Open-Source Alternative: Codestral (22B) was the strongest open-source contender, particularly effective at handling complex structural obfuscations.
  • The Baseline Gap: Traditional tools like Synchrony had 100% syntax correctness but almost zero "simplification" score for certain transformations, meaning they "deobfuscated" the code without actually making it easier for a human to read.
  • Complexity Threshold: The study found a "threshold of six": once more than six different obfuscation transformations are combined, the performance of all models (and baselines) drops off a cliff.

Limitations and Future Work

The authors note that LLMs are still prone to semantic manipulation—for example, accidentally swapping the order of array elements during deobfuscation, which breaks the program. Furthermore, the context window remains a bottleneck; highly obfuscated code often balloons in size, causing the LLM to truncate its output and produce syntactically invalid code.

Future work suggests that "expert models" for deobfuscation could be trained by fine-tuning on the very dataset this paper provides, potentially combining the creative "renaming" abilities of LLMs with the logical "correctness" of traditional compilers.

Summary updated

BibTeX
@inproceedings{chen2025jsdeobsbench,
  author = {Guoqiang Chen and Xin Jin and Zhiqiang Lin},
  title = {{JsDeObsBench: Measuring and Benchmarking LLMs for JavaScript Deobfuscation}},
  booktitle = {CCS},
  year = {2025},
  doi = {10.1145/3719027.3744871},
}
Figure