Reentrancy vulnerabilities pose a pervasive threat to blockchain ecosystems, demanding detection methods that are both highly accurate and produce trustworthy, human-verifiable explanations. While Large Language Models (LLMs) show promise, their opaque decision-making processes limit their reliability in this security-critical domain. We address this challenge by systematically evaluating two competing guidance strategies: grounding LLM analysis in external, structural evidence (via Retrieval-Augmented Generation) versus prescribing a human-expert-crafted, internal thought process (via Chain of Thought). A reasoning-optimized model enhanced by a Structurally-Aware RAG pipeline establishes a new state-of-the-art, surpassing traditional static analysis, deep learning, and other LLM baselines on a curated dataset of manually verified contracts. This evidence-grounded approach not only yields superior classification accuracy but, critically, produces transparent and actionable explanations that human experts judged as maximally correct and informative. By grounding automated analysis in verifiable evidence, our work delivers a validated blueprint for the next generation of AI-powered security tools.

Advanced Large Language Models Prompting Strategies for Reentrancy Classification and Explanation in Smart Contracts

Rizzo, Matteo;Spanò, Alvise;Benetollo, Lorenzo;Ressi, Dalila;Gasparetto, Andrea;Rossi, Sabina
2026

Abstract

Reentrancy vulnerabilities pose a pervasive threat to blockchain ecosystems, demanding detection methods that are both highly accurate and produce trustworthy, human-verifiable explanations. While Large Language Models (LLMs) show promise, their opaque decision-making processes limit their reliability in this security-critical domain. We address this challenge by systematically evaluating two competing guidance strategies: grounding LLM analysis in external, structural evidence (via Retrieval-Augmented Generation) versus prescribing a human-expert-crafted, internal thought process (via Chain of Thought). A reasoning-optimized model enhanced by a Structurally-Aware RAG pipeline establishes a new state-of-the-art, surpassing traditional static analysis, deep learning, and other LLM baselines on a curated dataset of manually verified contracts. This evidence-grounded approach not only yields superior classification accuracy but, critically, produces transparent and actionable explanations that human experts judged as maximally correct and informative. By grounding automated analysis in verifiable evidence, our work delivers a validated blueprint for the next generation of AI-powered security tools.
2026
Lecture Notes of the Institute for Computer Sciences, Social-Informatics and Telecommunications Engineering, LNICST
File in questo prodotto:
Non ci sono file associati a questo prodotto.

I documenti in ARCA sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/10278/5113990
Citazioni
  • ???jsp.display-item.citation.pmc??? ND
  • Scopus 0
  • ???jsp.display-item.citation.isi??? ND
social impact