Blockchain Security: A Reproducible Machine Learning Framework for Smart Contract Vulnerability Detection
Smart contracts on the Ethereum blockchain enable decentralized, trustless applications but remain highly susceptible to security vulnerabilities that have caused substantial financial losses. Traditional static and symbolic analysis tools often suffer from limited generalizability and high false-positive rates, motivating the exploration of machine learning alternatives. In this paper, we present a reproducible machine learning framework for smart contract vulnerability detection using a carefully designed synthetic dataset of 400 contracts. The dataset contains twelve static code-level features (including lines of code, external calls, delegatecalls, cyclomatic complexity, and state variable writes) and a binary vulnerability label with realistic class imbalance (22.5% vulnerable). We evaluate four classifiers Logistic Regression, Random Forest, Extra Trees, and Histogram-based Gradient Boosting under a stratified train-test protocol. Experimental results show that tree-based ensembles achieve strong performance, with HistGradientBoosting reaching an F1-score of 0.971 and ROC-AUC of 1.000, while Logistic Regression provides a competitive and more interpretable baseline (F1-score 0.882, ROC-AUC 0.974). Feature importance analysis highlights external calls, delegatecalls, and cyclomatic complexity as the most discriminative indicators. We openly release the dataset, preprocessing pipeline, and evaluation scripts to support reproducibility. Although the synthetic nature of the data limits direct claims about real-world deployment, the framework offers a transparent, controllable testbed for benchmarking detection methods and studying the impact of class imbalance and feature design in smart contract security research.
Authors
- Alireza Assadzadeh (ORCID: https://orcid.org/0009-0008-1797-3606)
Publication Details
- Journal
- Preprints.org
- Published
- 2026-10-27
- DOI
- https://doi.org/10.20944/preprints202610.2628.v1
- Primary Topic
- Blockchain Technology Applications and Security
- Type
- preprint