← Latest papers
💻 computer science

Reentrancy Detection in the Age of LLMs

This paper evaluates the effectiveness of traditional static analyzers, machine learning models, and large language models in detecting reentrancy vulnerabilities in modern Solidity 0.8+ smart contracts using two new benchmarks, revealing that leading LLMs significantly outperform existing tools and highlighting critical gaps in current detection robustness.

Original authors: Dalila Ressi, Alvise Spanò, Matteo Rizzo, Lorenzo Benetollo, Sabina Rossi

Published 2026-03-30
📖 5 min read🧠 Deep dive

Original authors: Dalila Ressi, Alvise Spanò, Matteo Rizzo, Lorenzo Benetollo, Sabina Rossi

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine the world of Ethereum smart contracts as a massive, high-stakes digital bank. In this bank, the rules are written in code (Solidity), and once the doors are locked, they can't be easily changed.

One of the most dangerous ways to rob this bank is a trick called Reentrancy.

The "Double-Dipping" Heist

To understand the problem, imagine a teller at a bank who follows a strict rule: "Check your balance, then give you cash, then update your account."

A clever thief (the hacker) walks up and asks for a withdrawal.

  1. The teller checks the balance: $100.
  2. The teller hands over the cash: $100.
  3. Before the teller updates the ledger to say "Balance is now $0," the thief pulls a magic trick. He asks the teller to give him more money immediately.
  4. Because the ledger hasn't been updated yet, the teller still thinks the thief has $100. So, the teller hands over another $100.
  5. The thief repeats this loop until the bank is drained, and then the teller finally updates the ledger to $0.

This is Reentrancy: The thief "re-enters" the bank's logic before the first transaction is finished, tricking the system into thinking nothing has changed.

The Problem: The Old Security Guards

For years, we've had "Security Guards" (software tools) designed to catch these thieves. These guards look at the code and shout, "Stop! You're updating the balance after handing out cash! That's a reentrancy trap!"

However, the authors of this paper discovered a scary problem: The security guards are old, broken, and confused.

  • The Language Changed: The "language" the bank uses (Solidity) has evolved. It's like the bank switched from English to a new, complex dialect. The old guards only speak the old dialect. When they see the new code, they either crash, freeze, or just ignore the danger.
  • They Disagree: If you ask 12 different guards to check the same vault, 11 of them might say "Safe," while the 12th says "Dangerous." They can't even agree on what a "dangerous" pattern looks like anymore.
  • The Training Data is Garbage: The machine learning guards (AI) were trained by the old, broken guards. So, they learned the wrong rules. It's like teaching a student using a textbook written in 1990 about a world that now uses 2025 technology.

The Experiment: A New Stress Test

The researchers decided to fix this by building two new "training grounds" to test the guards:

  1. The "Real World" Vault (Aggregated Benchmark): They took 432 real contracts from the internet and had human experts manually check them to see if they were actually safe or dangerous. This was the "Gold Standard."
  2. The "Trap Room" (Reentrancy Scenarios Dataset): They built 143 tiny, perfect examples of every possible way a thief could try to double-dip. Some traps were obvious; others were hidden behind complex code tricks, like using a "mutex" (a digital lock) or hiding the trick inside a loop.

The Results: The Old Guards vs. The New AI

They tested three types of defenders:

  1. Traditional Static Analyzers: The old-school rule-following guards.
  2. Machine Learning Models: The AI students trained on old data.
  3. Large Language Models (LLMs): The new, super-smart AI assistants (like the ones you chat with today).

The Outcome:

  • The Old Guards: Many of them failed completely. They couldn't even run on the new code. The ones that did run were inconsistent, often missing the traps or crying wolf on safe code.
  • The Machine Learning Models: They did okay on simple tasks but struggled when the code got tricky or used new features.
  • The New AI (LLMs): They won.
    • They didn't need to be retrained.
    • They didn't crash on new code.
    • They understood the meaning of the code, not just the syntax.
    • In the hardest "Trap Room" tests, the best LLM caught 82% of the thieves, while the best old tool only caught 76%.

The "Explain Your Work" Bonus

Here is the coolest part: The old guards just give a "Yes/No" answer. If they say "Dangerous," they often can't explain why in a way a human understands.

The LLMs, however, acted like a detective. When they flagged a contract, they wrote a clear explanation: "I found a reentrancy here because the code hands out money before updating the balance, and the thief can call the function again before the update happens."

This helped the human researchers realize that some of their own "Gold Standard" labels were actually wrong! The AI helped fix the dataset.

The Big Takeaway

This paper tells us that in the fast-moving world of blockchain security, our old tools are becoming obsolete. They are like using a map from 1990 to navigate a city that has been completely rebuilt.

While we used to rely on rigid, rule-based tools, the future of finding these security holes lies in smart, adaptable AI that can understand the intent of the code, explain its reasoning to humans, and keep up with the language changes without needing to be manually updated every week.

In short: The old security guards are retiring. It's time to hire the new AI detectives who can actually speak the language of the future.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →