Jason-42195 commited on
Commit
c614f7c
·
verified ·
1 Parent(s): 996f0f0

Model card: leakage-free Branch-1 numbers (F1 0.9907) + audit note

Browse files
Files changed (1) hide show
  1. README.md +26 -16
README.md CHANGED
@@ -17,7 +17,7 @@ the Database Proxy layer:
17
 
18
  - **Branch 1** — supervised multi-class classifier (Normal + SQLi variants), per query.
19
  - **Branch 2** — anomaly detector trained on benign traffic only (generalises to unseen syntax).
20
- - **Branch 3** — session-level sequence model over a stream of requests (the main contribution).
21
 
22
  Training data: [Jason-42195/VNU-SQLi-Detection](https://huggingface.co/datasets/Jason-42195/VNU-SQLi-Detection).
23
 
@@ -25,12 +25,12 @@ Training data: [Jason-42195/VNU-SQLi-Detection](https://huggingface.co/datasets/
25
 
26
  | Folder | Branch | Model | Headline metric |
27
  |---|---|---|---|
28
- | `branch1_v1/` | 1 | TF-IDF (char) + Logistic Regression | F1-macro **0.9822** (5 classes) |
29
  | `branch1_comparison/` | 1 | 4 candidate architectures (5-class) | see table below |
30
  | `branch1_no_*/` | 1 | Leave-one-class-out ablations (zero-day coverage) | F1 ~0.98 on remaining |
31
  | `branch2_v1/` | 2 | One-Class SVM (4 structural features) | avg-precision **0.982** |
32
  | `branch2_zeroday/` | 2 | One-Class SVM (zero-day coverage variant) | — |
33
- | `branch3_v1/` | 3 | GRU session-sequence classifier (4 classes) | see project repo |
34
 
35
  Download everything: `hf download Jason-42195/VNU-SQLi-Detection-Models --local-dir models/`
36
 
@@ -41,8 +41,9 @@ Download everything: `hf download Jason-42195/VNU-SQLi-Detection-Models --local-
41
  TF-IDF (`char_wb`, 2–4 gram, 50k features) + Logistic Regression. Classifies a query into one of
42
  **5 classes**: `normal`, `union_based`, `error_based`, `boolean_blind`, `time_blind`.
43
 
44
- - **F1-macro: 0.9822** on the held-out test set (13,560 rows).
45
- - p50 latency ~0.8 ms, size ~3.5 MB.
 
46
  - Files: `vectorizer.joblib` (TfidfVectorizer), `model.joblib` (LogisticRegression), `metadata.json`.
47
 
48
  ```python
@@ -60,12 +61,14 @@ Four candidates trained on the same 5-class data (`train/compare_branch1_archite
60
  The neural heads are sized from the data (true 5-class, no dead `stacked` neuron). TF-IDF+LogReg
61
  was chosen for production on the latency/size trade-off — the F1 gap is negligible.
62
 
 
 
63
  | Candidate | F1-macro | p50 latency | Size |
64
  |---|---|---|---|
65
- | `candidate_tfidf_logreg` | 0.9822 | 0.8 ms | 3.5 MB |
66
- | `candidate_tfidf_lightgbm` | 0.9912 | 91.7 ms | 5.7 MB |
67
- | `candidate_distilbert` | 0.9892 | 2.9 ms (GPU) | 256 MB |
68
- | `candidate_cnn_sqltok` | 0.9838 | 0.3 ms | 0.11 MB (28.5K params) |
69
 
70
  Only the two neural candidates' weights are hosted here (`candidate_distilbert/`:
71
  `model.safetensors` + tokenizer/config; `candidate_cnn_sqltok/`: `model.pt` + `vocab.json`).
@@ -113,12 +116,16 @@ detector.anomaly_flags(X) # boolean flag
113
  One-Class SVM with the same config as `branch2_v1`, used in the zero-day coverage experiment
114
  (pairs with the `branch1_no_*` ablations). Same loader as `branch2_v1`.
115
 
116
- ## `branch3_v1/` — Branch 3 (session-level sequence model)
117
 
118
- A GRU over a session's stream of per-request feature vectors (`input_dim=7`, `hidden_dim=32`,
119
- `max_len=64` requests/session). Classifies a **session** into 4 classes: `benign`,
120
- `boolean_blind`, `time_blind`, `query_splitting`. Files: `model.pt` (state dict), `metadata.json`.
121
- See the project repo for the model definition and the session-feature extractor needed to load it.
 
 
 
 
122
 
123
  ---
124
 
@@ -126,8 +133,11 @@ See the project repo for the model definition and the session-feature extractor
126
 
127
  - Branch 1's `boolean_blind` class has ~13% measured label noise (catch-all bucket for unmatched
128
  attack rows) — see `data_contract.md` in the project repo.
129
- - The uniformly high Branch-1 F1 (~0.98–0.99 across all 4 architectures) indicates the current
130
- dataset is easy to separate; it is **not** an adversarial/obfuscation benchmark.
 
 
 
131
  - No adversarial/obfuscation robustness testing yet.
132
  - License: mixed/unclear for the underlying training data (see the dataset repo's card) — treat as
133
  research / course-project artifacts, not cleared for unrestricted reuse.
 
17
 
18
  - **Branch 1** — supervised multi-class classifier (Normal + SQLi variants), per query.
19
  - **Branch 2** — anomaly detector trained on benign traffic only (generalises to unseen syntax).
20
+ - **Branch 3** — Session Correlator: not a separately-trained model, re-uses Branch 1 + Branch 2 and correlates their signals over a session (the main contribution).
21
 
22
  Training data: [Jason-42195/VNU-SQLi-Detection](https://huggingface.co/datasets/Jason-42195/VNU-SQLi-Detection).
23
 
 
25
 
26
  | Folder | Branch | Model | Headline metric |
27
  |---|---|---|---|
28
+ | `branch1_v1/` | 1 | TF-IDF (char) + Logistic Regression | F1-macro **0.9907** (5 classes, leakage-free) |
29
  | `branch1_comparison/` | 1 | 4 candidate architectures (5-class) | see table below |
30
  | `branch1_no_*/` | 1 | Leave-one-class-out ablations (zero-day coverage) | F1 ~0.98 on remaining |
31
  | `branch2_v1/` | 2 | One-Class SVM (4 structural features) | avg-precision **0.982** |
32
  | `branch2_zeroday/` | 2 | One-Class SVM (zero-day coverage variant) | — |
33
+ | `branch3_v2/` | 3 | Session Correlator (no weights — reuses `branch1_v1`/`branch2_v1`, 4 calibrated thresholds) | FPR=0.0, detection rate=1.0 on 3 session-attack classes, 280-session held-out test set |
34
 
35
  Download everything: `hf download Jason-42195/VNU-SQLi-Detection-Models --local-dir models/`
36
 
 
41
  TF-IDF (`char_wb`, 2–4 gram, 50k features) + Logistic Regression. Classifies a query into one of
42
  **5 classes**: `normal`, `union_based`, `error_based`, `boolean_blind`, `time_blind`.
43
 
44
+ - **F1-macro: 0.9907** on the held-out test set (13,560 rows), **leakage-free split** (dataset
45
+ deduplicated by `query_canonical` before the train/test split — see the audit note below).
46
+ - p50 latency ~0.5 ms, size ~3.5 MB.
47
  - Files: `vectorizer.joblib` (TfidfVectorizer), `model.joblib` (LogisticRegression), `metadata.json`.
48
 
49
  ```python
 
61
  The neural heads are sized from the data (true 5-class, no dead `stacked` neuron). TF-IDF+LogReg
62
  was chosen for production on the latency/size trade-off — the F1 gap is negligible.
63
 
64
+ Numbers are on the **leakage-free split** (deduped by `query_canonical` before splitting):
65
+
66
  | Candidate | F1-macro | p50 latency | Size |
67
  |---|---|---|---|
68
+ | `candidate_tfidf_logreg` | 0.9907 | 0.5 ms | 3.5 MB |
69
+ | `candidate_tfidf_lightgbm` | 0.9977 | 60.4 ms | 5.6 MB |
70
+ | `candidate_distilbert` | 0.9957 | 2.8 ms (GPU) | 256 MB |
71
+ | `candidate_cnn_sqltok` | 0.9906 | 0.3 ms | 0.11 MB (28.5K params) |
72
 
73
  Only the two neural candidates' weights are hosted here (`candidate_distilbert/`:
74
  `model.safetensors` + tokenizer/config; `candidate_cnn_sqltok/`: `model.pt` + `vocab.json`).
 
116
  One-Class SVM with the same config as `branch2_v1`, used in the zero-day coverage experiment
117
  (pairs with the `branch1_no_*` ablations). Same loader as `branch2_v1`.
118
 
119
+ ## `branch3_v2/` — Branch 3 (Session Correlator)
120
 
121
+ Not a trained model no weights, just `metadata.json` holding 4 calibrated scalar thresholds
122
+ (`content_threshold`, `per_query_threshold`, `mean_threshold`, `fraction_threshold`). At inference
123
+ time it re-uses `branch1_v1`'s classifier (re-scores the session's concatenated query text) and
124
+ `branch2_v1`'s anomaly detector (aggregates its per-query scores), OR'ing the two checks together.
125
+ Classifies a **session** into 4 classes: `benign`, `boolean_blind`, `time_blind`,
126
+ `query_splitting`. See the project repo's `src/models/branch3_session.py`
127
+ (`SessionCorrelator`) for the scoring logic, and `report/plan/data_contract.md` §4.2 for why
128
+ this replaced an earlier trained GRU design (`branch3_v1`, removed).
129
 
130
  ---
131
 
 
133
 
134
  - Branch 1's `boolean_blind` class has ~13% measured label noise (catch-all bucket for unmatched
135
  attack rows) — see `data_contract.md` in the project repo.
136
+ - The uniformly high Branch-1 F1 (~0.99 across all 4 architectures) indicates the current dataset
137
+ is easy to separate; it is **not** an adversarial/obfuscation benchmark. A `/blog/index.php/...`
138
+ request format makes up ~17.6% of rows (content-format duplication), further limiting diversity.
139
+ - Cross-split leakage (949 identical texts straddling train & test) was found and **fixed** on
140
+ 20/8 by deduplicating `query_canonical` before the split; the numbers here are leakage-free.
141
  - No adversarial/obfuscation robustness testing yet.
142
  - License: mixed/unclear for the underlying training data (see the dataset repo's card) — treat as
143
  research / course-project artifacts, not cleared for unrestricted reuse.