/ Модель

Характеристики

Контекст
514 токенов
Параметры
152 млн
Лицензия
MIT
Архитектура
roberta · dense
Базовая модель
codebert-base
Опубликована
29 авг 2026

codebert-smart-contract-vuln

Классификация текстаТекст → label3 профессии

Дообученная CodeBERT классифицирует код Solidity по четырём типам уязвимостей смарт-контрактов.

47скачиваний за 30 дней1лайквеса обновлены29 авг 2026

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Публичные оценки

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

В подключённых источниках результатов для этой модели пока нет.

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

AbijithwearsHUGGIES подготовил дообученную модель CodeBERT для классификации фрагментов кода Solidity по четырём типам уязвимостей смарт-контрактов: Reentrancy, Integer Overflow, Timestamp Dependency и Dangerous Delegatecall. Модель основана на microsoft/codebert-base, использует архитектуру RoBERTa с классификационной головой и содержит 151,8 млн параметров. Максимальная длина входа — 514 токенов; веса доступны в форматах Safetensors и ONNX.

Модель предназначена для отнесения уязвимого контракта к одному из четырёх классов, например при исследовании Solidity-кода. Она всегда выбирает класс и не умеет сообщать, что уязвимостей нет. Обучение проводилось на 387 размеченных контрактах; автор приводит результаты на небольшой тестовой выборке и отмечает нестабильность классификации Integer Overflow. Лицензия — MIT.

Сценарии применения

  • классификация уязвимых контрактов Solidity по типу уязвимости
  • поиск риска повторного входа в смарт-контракте
  • выявление зависимости логики контракта от временных меток
  • поиск опасного использования delegatecall
  • выявление потенциального переполнения целых чисел в размеченных уязвимых контрактах

Ограничения

Модель всегда относит вход к одному из четырёх классов, обучена только на уязвимых контрактах и не умеет подтверждать безопасность кода; на безвредных и выходящих за распределение входах может выдавать уверенные ошибочные прогнозы. Качество класса Integer Overflow ограничено, а результаты получены на небольшой выборке из 387 контрактов; модель не заменяет аудит.

Для каких профессий подходит3

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

CodeBERT — Solidity Vulnerability Classifier (4-class)

Fine-tuned microsoft/codebert-base that classifies a Solidity snippet into one of four vulnerability types: Reentrancy, Integer Overflow, Timestamp Dependency, or Dangerous Delegatecall.

Reproduces the approach of Hossain, Altarawneh & Roberts, "Leveraging LLMs and ML for Smart Contract Vulnerability Detection", IEEE CCWC 2025, on a smaller public dataset.

Code, training pipeline and full evaluation: github.com/Riicko-19/smart-contract-vuln-detector — including a 5-seed variance study, a label-contamination analysis, and an adversarial out-of-distribution probe.

Usage

from transformers import pipeline

clf = pipeline("text-classification", model="AbijithwearsHUGGIES/codebert-smart-contract-vuln")
clf("function withdraw(uint a) public { msg.sender.call.value(a)(\"\"); balances[msg.sender] -= a; }")
# [{'label': 'Reentrancy', 'score': ...}]

Results

This checkpoint, on the held-out 59-contract test split:

MetricValue
Accuracy0.881
Macro F10.871
Reentrancy F10.957
Dangerous Delegatecall F11.000
Timestamp Dependency F10.897
Integer Overflow F10.632

Read those with care. The test split has only 59 contracts, so one flipped prediction moves a per-class F1 by roughly 0.09. Measured across 5 seeds, this architecture averages:

ModelAccuracyMacro F1ReentrancyOverflow
CodeBERT0.868 ±0.0370.858 ±0.0540.926 ±0.0480.624 ±0.170
DistilBERT0.834 ±0.0710.826 ±0.0610.949 ±0.0180.508 ±0.168

A paired per-seed comparison found no statistically significant difference between CodeBERT and DistilBERT (accuracy p=0.41, macro-F1 p=0.47, Integer Overflow p=0.38). This checkpoint is simply the best single artifact from that sweep, not evidence that CodeBERT is the better architecture here.

Training

  • 12 epochs, class-weighted cross-entropy (the dataset is imbalanced)
  • Best checkpoint selected on validation macro-F1, not eval_loss — selecting on loss lets the majority class dominate and yields 0.00 F1 on Integer Overflow, because the "best" checkpoint abandons the minority class
  • Max sequence length 512 (no truncation occurs; longest contract is 248 tokens)

Data

387 labelled contracts from the Messi-Q/Smart-Contract-Dataset "Resource 2" release — Timestamp Dependency 174, Integer Overflow 80, Reentrancy 71, Dangerous Delegatecall 62. Split 270 train / 58 val / 59 test.

This is roughly a sixth the size of the paper's 2,217-contract IR-Fuzz split (which is not publicly redistributable), so treat these numbers as directional rather than a reproduction.

Limitations

  • Integer Overflow is weak (F1 ~0.62, ±0.17 across seeds), and the cause is the label, not the model. Across all 387 contracts, the other three classes have a near-perfect syntactic signature (Reentrancy 100% contain .call.value(, Timestamp 100% contain block.timestamp/now, Delegatecall 89% contain .delegatecall(). Integer Overflow has none of its own: 39% of its contracts contain the reentrancy pattern and 55% contain timestamp calls. The source dataset ships four independent binary labelled sets, and forcing a single label onto contracts that exhibit several vulnerabilities pushes the ambiguity into this class. Treating the task as multi-label would be the principled fix.
  • Forced-choice, not detection. The model always returns one of four classes. It cannot say "no vulnerability", and it was trained only on vulnerable contracts. An out-of-distribution probe makes the cost concrete: a pure math library with no state, no external calls and no timestamps is classified Timestamp Dependency at 99.1% confidence, and Python source code scores Integer Overflow at 93.7%. Confidence does not help — on benign inputs it reaches 99.1%, while genuine vulnerabilities go as low as 97.9%, so the ranges overlap and no threshold separates them. Never use this to decide whether a contract is safe.
  • It does generalise on genuinely vulnerable code, which is the flip side: it correctly flags reentrancy written with modern .call{value:} syntax, and even reentrancy expressed through a callback with no low-level call at all — so it is not merely keyword matching.
  • Not a substitute for an audit. This is a research/portfolio artifact trained on 387 contracts, not a security tool.

License

MIT

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · text-classification

Можно запустить

Подбираем GPU…

Класс архитектуры
RobertaForSequenceClassification
Ревизия весов
7697a28

0 моделей