Quantifies a hidden dataset bias
Safe audited DeFi contracts average 91.9 functions; exploited vulnerable contracts average 6.2—a 14.9× size gap that lets models learn size instead of security.
Published in IEEE Xplore
School of Computer Science and Technology · Karunya Institute of Technology and Sciences
01 · Abstract
Smart contracts governing Decentralized Finance (DeFi) protocols on Ethereum handle billions of dollars in assets, making reliable vulnerability detection a practical necessity rather than an academic exercise. Existing machine learning studies achieve strong benchmark numbers, yet a fundamental problem in how training datasets are assembled has received little attention: audited safe contracts drawn from large DeFi protocols are structurally much larger than exploited vulnerable ones, creating a size-proxy bias that inflates reported accuracy without teaching the model anything about security. This paper identifies and corrects that bias through a nine-stage automated pipeline that produces a curated dataset of 3,316 real-world Ethereum contracts, extracts nine security-oriented features via Slither static analysis and source-code metrics, trains a Gradient Boosting classifier, and applies SHAP attribution to verify that predictions are driven by genuine security patterns rather than contract size. On the raw biased dataset the model reached 98.49% accuracy with function_count capturing 89.51% of feature importance; after correction, accuracy settles to a realistic 93.37%, with assembly_flag becoming the dominant predictor at a SHAP value of 2.02. Full evaluation on the held-out test set yields 90.51% precision, 83.14% recall, 86.67% F1-score, and 0.9710 ROC-AUC, outperforming Random Forest and Logistic Regression baselines trained on identical features and splits. The 4.88 percentage-point accuracy drop after bias correction is not a performance loss but a removal of a confounding factor, and the shift in feature importance from size proxies to security indicators confirms the model is learning what it is supposed to learn.
02 · Contributions
Safe audited DeFi contracts average 91.9 functions; exploited vulnerable contracts average 6.2—a 14.9× size gap that lets models learn size instead of security.
A nine-stage pipeline scrapes, resolves, verifies, flattens, and labels contracts, producing 3,316 Ethereum contracts with nine security-oriented features.
After correction, function_count no longer dominates. assembly_flag becomes the top predictor at a SHAP value of 2.02, followed by external_calls (0.92) and function_count (0.71); unchecked calls and delegatecall follow at 0.64 each.
On the same features and test split, Gradient Boosting leads both baselines on accuracy and ROC-AUC, reaching 90.51% precision and 83.14% recall.
03 · The problem
Audited safe contracts from large DeFi protocols
average 91.9 functions; exploited vulnerable
contracts average 6.2. That 14.9× gap is enough for
a model to learn contract size as a stand-in for
vulnerability. On the raw 4,492-contract dataset,
function_count absorbed 89.51% of
Gradient Boosting’s impurity importance and
accuracy reached 98.49%—a number that measured size
discrimination, not security learning.
accuracy
function_count · 89.51% of feature importance
accuracy
assembly_flag · SHAP value 2.02
The 4.88 percentage-point drop is not a performance loss. It is the removal of a confounding factor.
04 · Methodology
The final corpus contains 3,316 real-world Ethereum contracts: 924 vulnerable and 2,392 safe. Every stage runs with checkpoints every 100 contracts, and nine security-oriented features combine Slither analysis with source-code metrics.
Collect vulnerable-contract leads and incident metadata from rekt.news, DefiLlama, and SlowMist.
Deduplicate addresses across sources so the same incident is not counted twice.
Use LLM-assisted extraction to resolve each incident to its Ethereum contract address.
Fetch verified Solidity source code through the Etherscan API.
Merge multi-file contracts and imports into a single compilable Solidity unit.
Run Slither with solc-select across compiler versions to extract security flags.
Combine Slither JSON output with regex-based source-code metrics into nine features.
Gather Etherscan-verified safe contracts while excluding proxies and empty source code.
Validate, label, and export the final CSV used for training, validation, and testing.
05 · Results
The held-out test set contains 664 contracts: 172 vulnerable and 492 safe. Gradient Boosting outperforms both baselines on accuracy and ROC-AUC, and Random Forest on precision. Logistic Regression has higher precision, but it misses nearly one in three vulnerable contracts.
| Model | Accuracy | Precision | Recall | ROC-AUC |
|---|---|---|---|---|
| Gradient Boosting (ours) | 93.37% | 90.51% | 83.14% | 0.9710 |
| Random Forest | 92.77% | 86.47% | 85.47% | 0.9630 |
| Logistic Regression | 90.51% | 93.60% | 68.02% | 0.9289 |
All models use identical features and the same held-out split.
After correction, security flags dominate.
assembly_flag leads at 2.02, followed
by external_calls (0.92) and
function_count (0.71). Size now
provides context instead of driving the decision.
On the raw biased dataset, Gradient Boosting reached 98.49% accuracy while function_count captured 89.51% of impurity importance.
After correction, accuracy settled at 93.37% and assembly_flag became the dominant predictor at a SHAP value of 2.02.
The held-out 664-contract test set produced 90.51% precision, 83.14% recall, 86.67% F1-score, and 0.9710 ROC-AUC.
Removing assembly_flag reduced F1 by 6.04 percentage points; removing function_count reduced it by only 1.12 points.
Security flags collectively contributed 3.648 mean |SHAP|, compared with 1.870 for structural code metrics.
06 · Publication evidence
Both official IEEE Xplore screenshots and the paper’s framework and first page are included as publication evidence. Select any image to view it at full size.
The two IEEE Xplore screenshots document the official record; the framework diagram summarizes the paper’s pipeline, and the first page is reproduced from the published PDF.
07 · Citation
If you reference this work, please use the BibTeX entry below.
@inproceedings{Dharshan2026BiasCorrected,
author = {Dharshan Kumar J and Srija J and Shivanthana S},
title = {A Bias-Corrected Dataset Construction Framework for Machine Learning-Based Smart Contract Vulnerability Detection},
booktitle = {2026 International Conference on Secure IoT and Cybersecurity (ICOSICS)},
publisher = {IEEE},
year = {2026},
pages = {1436--1442},
doi = {10.1109/ICOSICS70095.2026.11746875},
url = {https://ieeexplore.ieee.org/document/11746875}
} Official record: https://ieeexplore.ieee.org/document/11746875
Read the full paper