Jason-42195 commited on
Commit
2cfb4cd
·
verified ·
1 Parent(s): 633d7f4

Add model card

Browse files
Files changed (1) hide show
  1. README.md +70 -0
README.md ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: unknown
3
+ tags:
4
+ - security
5
+ - sql-injection
6
+ - scikit-learn
7
+ - anomaly-detection
8
+ - text-classification
9
+ pipeline_tag: text-classification
10
+ ---
11
+
12
+ # VNU SQLi Detection Models
13
+
14
+ Trained model artifacts for a 2-branch AI-based SQL Injection detection system (Branch 3 —
15
+ session-level — is designed but not yet implemented; see the project repo for details).
16
+
17
+ Data used to train these models: [Jason-42195/VNU-SQLi-Detection](https://huggingface.co/datasets/Jason-42195/VNU-SQLi-Detection).
18
+
19
+ ## `nhanh1_v1/` — Branch 1 (supervised multiclass)
20
+
21
+ TF-IDF (char_wb, 2-4gram) + Logistic Regression. Classifies a query into one of 5 classes:
22
+ `normal`, `union_based`, `error_based`, `boolean_blind`, `time_blind`.
23
+
24
+ - **F1-macro: 0.9822** on held-out test set (13,560 rows)
25
+ - p50 latency: ~0.5ms, size: ~3.9MB
26
+ - Files: `vectorizer.joblib` (TfidfVectorizer), `model.joblib` (LogisticRegression), `metadata.json`
27
+
28
+ ```python
29
+ import joblib
30
+ vectorizer = joblib.load("nhanh1_v1/vectorizer.joblib")
31
+ clf = joblib.load("nhanh1_v1/model.joblib")
32
+
33
+ X = vectorizer.transform(["1' OR '1'='1"])
34
+ clf.predict(X) # -> array([3]) (3 = boolean_blind)
35
+ ```
36
+
37
+ ## `nhanh2_v1/` — Branch 2 (anomaly detection)
38
+
39
+ One-Class SVM trained on 100% benign traffic, using 4 structural features (length,
40
+ special_char_ratio, sql_keyword_count, entropy) — not TF-IDF, so it can generalize to
41
+ unseen attack syntax.
42
+
43
+ - **AUC: 0.90**, FPR: 0.3% (9/3000 benign), detection rate: 20.7% (5196/25065 anomalous)
44
+ - Files: `model.joblib` (wraps `src.models.nhanh2_anomaly.AnomalyDetector`), `metadata.json`
45
+
46
+ ```python
47
+ # From within the project repo (needs src.models.nhanh2_anomaly.AnomalyDetector):
48
+ from src.models.nhanh2_anomaly import AnomalyDetector
49
+ import numpy as np
50
+
51
+ detector = AnomalyDetector.load("nhanh2_v1")
52
+ X = np.array([[40, 0.05, 1, 3.6]]) # [length, special_char_ratio, sql_keyword_count, entropy]
53
+ detector.score(X) # continuous anomaly score
54
+ detector.anomaly_flags(X) # boolean flag
55
+ ```
56
+
57
+ ## Limitations
58
+
59
+ - Branch 1's `boolean_blind` class has ~13% measured label noise (catch-all bucket for
60
+ unmatched attack rows) — see `data_contract.md` in the project repo.
61
+ - Branch 2's detection rate (20.7%) reflects a diverse anomalous eval set (D3 CSIC2010,
62
+ covering XSS/path-traversal/etc., not just SQLi) — not a pure SQLi zero-day benchmark.
63
+ - No adversarial/obfuscation robustness testing yet.
64
+ - License: mixed/unclear for underlying training data (see the dataset repo's card) —
65
+ treat as research/course-project artifacts, not yet cleared for unrestricted reuse.
66
+
67
+ ## Project repo
68
+
69
+ Full source, training scripts, and documentation: see the `VNU-Database2-Project` repo
70
+ (private/course project — ask the author for access).