syedubaid's picture
Add fine-tuned DistilBERT attack-type classifier
2438187 verified
|
Raw History Blame Contribute Delete
2.23 kB
metadata
license: apache-2.0
base_model: distilbert-base-uncased
pipeline_tag: text-classification
language: en
tags:
  - cybersecurity
  - cve
  - vulnerability
  - text-classification

DockerGuard attack-type classifier

Reads a vulnerability (CVE) description and predicts what kind of attack it allows, one of 8 types:

Code execution 路 Memory corruption 路 Injection 路 Web attack 路 Information disclosure 路 Access control bypass 路 Denial of service 路 File access

Part of DockerGuard AI, a college project that scans Docker images, ranks vulnerabilities by exploit risk, and explains them.

Training

  • Base model: distilbert-base-uncased, fine-tuned for 8-class classification.
  • Data: public CVE descriptions from the NIST National Vulnerability Database (2016 onwards).
  • Labels: each CVE's CWE code (type of programming mistake) grouped into the 8 attack types. The model only sees the description text, never the CWE code.
  • Setup: balanced sample of 16,000 CVEs (2,000 per type), 1 epoch, AdamW, learning rate 5e-5 with linear warmup, max 128 tokens, CPU only.

Results

Tested on 4,000 of the newest CVEs (published after all training CVEs):

Model Trained on Accuracy Macro F1
TF-IDF + Logistic Regression all ~2 lakh labelled CVEs 89.6% 0.875
TF-IDF + Logistic Regression same 16,000 as this model 85.1% 0.827
This model (DistilBERT) 16,000 CVEs, 1 epoch 85.5% 0.833

With the same training data this model slightly beats the baseline, but the baseline trained on far more data is better overall. Training on more CVEs and for more epochs (on a GPU) is the obvious next step.

Use

from transformers import pipeline

classify = pipeline("text-classification", model="syedubaid/dockerguard-attack-classifier")
classify("Apache Log4j2 JNDI features do not protect against attacker controlled LDAP endpoints, "
         "allowing remote code execution.")

Limitations

  • Labels come from CWE codes, which are sometimes vague or wrong in NVD, so some "errors" are label noise.
  • "Information disclosure" is the weakest type (F1 0.62): it overlaps with access-control bugs.
  • English descriptions only.