SmartPattern: A Machine Learning Framework for Detecting Reentrancy Vulnerabilities in Blockchain Smart Contracts

Temitope Ezekiel Ajibola, Opeyemi Adeniran, Peter O. Taiwo · 2025

This study introduces SmartPattern, a novel machine learning-based framework to detect reentrancy attacks in smart contracts, a critical threat to blockchain security. Analyzing 40,000 smart contract, SmartPattern achieves 94% detection accuracy with Random Forest and Support Vector Classifier, outperforming Bidirectional Encoder Representations Transformers embeddings, which produced inconsistent accuracies of 84% and 78% Random Forest and Support Vector Classifier, respectively. Unlike traditional tools like Slither, which rely on static analysis and predefined heuristics, SmartPattern overcomes limitations related to dynamic invocation patterns and non-linear state changes. By leveraging machine learning models and targeted pattern recognition, SmartPattern effectively detects obfuscated attack patterns and generalizes to unseen vulnerabilities. This scalable, automated framework significantly enhances blockchain security by safeguarding billions of dollars in digital assets and promoting trust in decentralized ecosystems. The results demonstrate that SmartPattern is a viable alternative to state-of-the-art models, including those using Graph Convolutional Networks, and provides a comprehensive solution for fortifying smart contract ecosystems against reentrancy attacks.

Read the paper · More papers on PaperTik