# Changelog ## v3 — 2026-06-21 ### Models retrained (all 4) — major dataset expansion **Prompt Injection (v3)** - Added `fmops/prompt-injection` (~800 examples) - Added `Harelix/prompt-injection-mixed-attacks-2024` (~400 examples) - Added 10 hard negatives targeting known FP pattern (benign imperatives like "Summarize this article" scoring 0.94) - Total training data: ~2,370 examples (was ~660) **Jailbreak (v2)** - Added `TrustAIRLab/in-the-wild-jailbreak-prompts` (~1,000 real-world jailbreaks) - Added `markush1/LLM-Jailbreak-Classifier-Dataset` (~500 examples) - Added 12 hard negatives: legitimate creative/roleplay requests to fix FP on "write a story as X" - Total training data: ~3,092 examples (was ~1,600) **Insecure Output (v2)** - Root cause of "everything shows LOW": v1 had only **41 synthetic examples** — model never learned the signal - Added `FredZhang7/sqli-attack-dataset` (~4,000 SQL injection examples) - Added `Multilingual-Multimodal-NLP/xss-dataset` (~1,000 XSS payloads) - Expanded synthetic: 45 malicious payloads (XSS, SQLi, CMDi, path traversal, SSTI, XXE, LDAP, open redirect) - Added 35 safe counterexamples (parameterized queries, sanitized code, normal output) - Total training data: ~5,080 examples (was 41) **Indirect Injection (v2)** - Root cause: v1 had only **20 synthetic examples** - Added `structuredlabs/indirect-prompt-injection` dataset - Repurposed `deepset/prompt-injections` injection examples wrapped in document contexts (~150 positives) - Synthetic expansion: 15 document contexts × 20 injection payloads = 300 inline poisoned docs - Synthetic expansion: 15 contexts × 5 suffix injections = 75 suffix-hidden attacks - Added 50 clean document augmentations (partial truncations to simulate RAG chunking) - Total training data: ~575+ examples (was 20) ### Training improvements (all models) - Metric for best model changed from `roc_auc` → `f1` (better for imbalanced classes) - Epochs increased 5 → 6 with early stopping patience=2 - `top_k=None` replaces deprecated `return_all_scores=True` (removed in transformers 4.40+) - Dynamic label lookup via `clf.model.config.id2label` — no more hardcoded string matching ### Platform - UI redesigned: dark cyber theme, gradient hero banner, per-threat colored cards, glow buttons - Space renamed: `LLM_Security_Scanner` → `LLM_Threat_Shield` - Log path: `/data/predictions.csv` (HF persistent storage) with `/tmp` fallback - Model cards pushed to all 4 HF Hub model repos - All Claude co-author tags removed from git history (force push) ### Security hardening - Adversarial preprocessing layer added to `preprocess()`: - NFKC Unicode normalisation — neutralises fullwidth Unicode attacks (`Ignore` → `Ignore`) - Zero-width character stripping — removes U+200B, U+200C, U+200D, U+FEFF, U+2060 - Leet-speak translation table — `0→o`, `1→i`, `3→e`, `4→a`, `5→s`, `7→t`, `@→a`, `$→s`, `!→i` - Excess whitespace collapse between word chars - Sliding window inference in `_score()`: score first 512 + last 512 chars, take max — fixes suffix attack bypass - PII regex tightened: passport `[A-Z]{2}\d{7,9}`, credit card requires grouping pattern `(?:\d{4}[\s\-]){3}\d{4}` - Session-scoped rate limiting: max 10 req/60s per tab via `gr.State` timestamp list (no Redis) ### UI additions - New tab: `📊 Model Health` — 10 held-out examples per model (5 attack + 5 clean), F1/precision/recall/accuracy, ✅/❌ vs F1 ≥ 0.80 - New tab: `🧪 Adversarial Tests` — 9-test bypass suite (fullwidth, zero-width, leet, mixed case, suffix, DAN, clean baselines), click-to-run - PII Scanner tab added (was previously unreachable via Scan All only) - Hero: removed 5 threat-type badge strip below title - Bug fix: removed `column_widths` from `gr.Dataframe` — caused BodyStreamBuffer abort on Space startup ### Eval / CI - `training/eval_benchmark.py` — CLI eval: loads public HF datasets, runs all 4 models, prints classification_report, saves `benchmark_results.json`, exits 1 if any F1 < 0.80 ### Model cards - `training/push_model_cards.py` — pushes README.md to all 4 HF Hub model repos - Each card: task description, OWASP category, label table, training data sources, usage snippet, threshold table, limitations ### Training — Jailbreak v2 retrain - Primary dataset (verazuo/jailbreak-llms) disappeared from Hub — replaced with `lmsys/toxic-chat` jailbreak subset - Class imbalance fix: capped safe examples at 2× jailbreak count via `random.sample(seed=42)` — was 19k safe vs 2k jailbreak --- ## v2 — 2026-06-21 ### Models retrained (all 4) - Expanded synthetic dataset: 26-30 examples per class per model - Added deduplication pass before balancing - Fixed `model_type: distilbert` in config.json (was dropped by `trainer.push_to_hub()`) - Push method changed to `model.save_pretrained()` + `HfApi().upload_folder()` for reliability - All models tagged `v2` on HF Hub ### Platform - Orchestrator Space live: `Builder117/LLM_Threat_Shield` - 5 tabs: Prompt Injection, Jailbreak, Insecure Output, Indirect Injection, Scan All - Added test suite: `tests/test_models.py` (pytest, 16 pass/fail cases across all 4 models) ## v1 — 2026-06-20 ### Initial release - 4 DistilBERT classifiers fine-tuned and deployed - Unified Gradio Space with multi-tab UI - Private models on HF Hub, accessed via `HF_TOKEN` secret