File size: 8,102 Bytes
6478e18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d89543b
 
 
 
6478e18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc624fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6478e18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
---
base_model: Qwen/Qwen3.5-0.8B-Base
library_name: peft
license: apache-2.0
tags:
- base_model:adapter:Qwen/Qwen3.5-0.8B-Base
- lora
- transformers
- security
- xss
- vulnerability-detection
- cybersecurity
- web-security
language:
- en
pipeline_tag: text-classification
---

<div align="center">
<img src="assets/banner.png" alt="xss-decision — AI-Powered XSS Detection" width="100%">
</div>

# XSS Decision Model — Kev 0.8B Live v2

A **0.8B parameter Small Language Model (SLM)** fine-tuned for real-time XSS (Cross-Site Scripting) vulnerability decision-making. This is a LoRA adapter on top of `Qwen/Qwen3.5-0.8B-Base`, trained using the [Kev](https://github.com/jaredpalmer/kev) typed-decision framework.

## What It Does

The model makes 5 types of XSS assessment decisions in real-time:

| Task | Question | Description |
|------|----------|-------------|
| **triage** | exploitable? | Should this URL/parameter combination be probed for XSS? |
| **analyze** | true_context | What is the actual injection context? (html_text, html_attr, js_string, dom_html, etc.) |
| **interpret** | exploitable? | Given reflection evidence, is this actually exploitable? |
| **strategy** | best_probe | Which XSS probe technique should be tried? |
| **escalate** | escalation | What escalation technique to try next? (evasion, mXSS, CSP bypass) |

## Held-out Test Accuracy

Evaluated on 57 held-out records (never seen during training):

| Task | Question | Accuracy |
|------|----------|----------|
| analyze | has_sanitizer | **100%** (21/21) |
| analyze | true_context | **95.2%** (20/21) |
| interpret | exploitable | **100%** (7/7) |
| escalate | escalation | **100%** (2/2) |
| strategy | best_probe | **75%** (3/4) |
| triage | exploitable | **78.3%** (18/23) |

## Pipeline Integration Results (XSS-LiveBench-v2)

When integrated into the xss-specialist live assessment pipeline — 225 cases:

| Metric | Value | 95% Bootstrap CI |
|--------|-------|-------------------|
| Precision | **1.000** | [1.000, 1.000] |
| Recall | **1.000** | [1.000, 1.000] |
| FPR | **0.000** | [0.000, 0.000] |
| FNR | **0.000** | [0.000, 0.000] |
| Confirmed-exec accuracy | **1.000** | [1.000, 1.000] |
| Near-miss leakage | **0.000** | — |

**Confusion matrix:** TP=157 · FP=0 · FN=0 · TN=68

### By XSS class

| Class | Cases | Recall |
|-------|-------|--------|
| Reflected | 75 | 100% |
| DOM | 78 | 100% |
| Stored | 4 | 100% |
| Safe (negative) | 68 | 0 FP |

### By injection context

| Context | Cases | Accuracy |
|---------|-------|----------|
| html_text | 83 | 100% |
| dom_html | 81 | 100% |
| html_attr | 22 | 100% |
| js_code | 22 | 100% |
| js_string | 8 | 100% |
| html_attr_url | 5 | 100% |
| css | 3 | 100% |
| dom_attr | 1 | 100% |

### By category (25 categories — all 100%)

`reflected` (37) · `owasp_evasion` (24) · `sanitizer_nearmiss` (21) · `csp_bypass` (20) · `fp_torture` (16, 0 FP) · `dom` (15) · `modern_controls` (12) · `advanced_delivery` (8) · `dom_source` (7) · `event_driven` (7) · `encoding_chain` (6) · `framework_sink` (6) · `svg_xss` (6) · `encoding` (5) · `postmessage` (5) · `proto_pollution` (5) · `sanitizer` (5) · `mxss` (4) · `dom_clobbering` (3) · `script_gadget` (3) · `template_injection` (3) · `second_order` (2) · `stored` (2) · `websocket` (2) · `dom_multistep` (1)

### Live XSS Lab — 10 Independent Scenarios

| # | Scenario | Context | Status |
|---|----------|---------|--------|
| 1 | Basic reflected XSS | html_attr | CONFIRMED |
| 2 | Reflected in HTML body | html_text | CONFIRMED |
| 3 | DOM-based XSS (innerHTML) | dom_html | CONFIRMED |
| 4 | Attribute injection | html_attr | CONFIRMED |
| 5 | JS string injection (multi-context) | js_string | CONFIRMED |
| 6 | Unquoted attribute injection | html_attr | CONFIRMED |
| 7 | `<script>` filter bypass | html_attr | CONFIRMED |
| 8 | Event handler injection | html_attr | CONFIRMED |
| 9 | Encoded reflection bypass | html_attr | CONFIRMED |
| 10 | Mutation XSS (mXSS) | js_string | CONFIRMED |

### Baseline Comparison

| Approach | Precision | Recall | FPR | Note |
|----------|-----------|--------|-----|------|
| **xss-specialist (full)** | **1.000** | **1.000** | **0.000** | Browser-oracle verified |
| Nuclei (signature-based) | N/A | 0.000 | 0.000 | Zero recall on custom endpoints |
| Reflection-only scanner | 0.62 | 0.95 | 0.97 | Flags anything that echoes |
| Encoding-aware scanner | 0.87 | 0.41 | 0.11 | Checks if dangerous chars survive |

## How to Use

```python
# Requires the kev package (Python 3.12/3.13)
# pip install "kev @ git+https://github.com/jaredpalmer/kev.git"

from xss_decision.learned import LearnedBackend

backend = LearnedBackend("path/to/checkpoint", device="mps")  # or "cuda", "cpu"

# Triage decision
result = backend.predict({
    "state": {
        "task": "triage",
        "url": "/search",
        "parameter": "q",
        "delivery": "query",
        "context": "html_text",
        "method": "GET"
    },
    "questions": {
        "exploitable": {
            "type": "noul",
            "criteria": {
                "true": "High likelihood of reflection into a dangerous context",
                "false": "Low likelihood — encoded, filtered, or structural param"
            }
        }
    }
})
print(result["probabilities"])
# {"exploitable": {"true": 0.854, "false": 0.146}}
```

### Use with the Live Scanner

```bash
# Install
uv sync
uv run python -m playwright install chromium

# Run with the trained model
uv run python -m live.assess --target http://authorized-target.com --kev runs/kev-xss-v2/checkpoint
```

## Training Details

| Parameter | Value |
|-----------|-------|
| Base model | Qwen/Qwen3.5-0.8B-Base |
| Parent checkpoint | jaredpalmer/kev-0.8b |
| Adapter | LoRA (rank 16, full placement) |
| Trainable parameters | 11.3M |
| Training records | 528 (from XSS-LiveBench-v2 execution-verified run) |
| Typed decisions | 582 |
| Epochs | 3 |
| Learning rate | 1e-5 |
| Batch size | 4 (accumulation 2) |
| Optimizer steps | 159 |
| Precision | fp32 |
| Device | Apple MPS |
| Training time | 1213s (~20 min) |
| Permutation KL | 0.1 (option-order stability regularization) |

### Training Data

528 records exported from a perfect-score XSS-LiveBench-v2 run (225 cases, P=1.0, R=1.0, FPR=0.0). Each record represents a real decision the pipeline made during live XSS assessment, with execution-verified ground truth from the headless Chromium browser oracle.

Task distribution: triage (221), analyze (203), interpret (63), strategy (29), escalate (12).

## Architecture

This is a **Kev typed-decision model** — a pointer-network head on a Mamba2/transformer hybrid backbone. Unlike autoregressive text generation, it produces calibrated probability distributions over structured decision options in a single forward pass (~242ms on Apple MPS).

```
Qwen3.5-0.8B-Base (frozen)
  └── LoRA adapters (rank 16, all projections)
       └── Kev pointer head (dim 256)
            └── Per-question probability distributions
```

## Limitations

- **Research preview** — not independently validated for production use
- **Training data is synthetic benchmark-derived** — may not generalize to all real-world XSS patterns
- **A "safe" prediction is not proof of safety** — always verify with browser execution
- **Near-miss sanitizer leakage** — the model alone cannot reliably distinguish DOMPurify from DOMPvrify; the full pipeline handles this via execution verification
- **No blind/out-of-band XSS** — training data covers reflected, DOM, and stored XSS only
- **Chromium-specific** — browser oracle ground truth is Chromium-based

## Ethical Use

This model is intended for **authorized security testing only**. All assessment paths require explicit scope and authorization. The model should be used as part of a defensive security workflow, not for unauthorized testing.

## License

Apache-2.0 (adapter and pointer head). The base model (Qwen3.5-0.8B-Base) is also Apache-2.0.

### Framework versions

- PEFT 0.22.0
- Kev 0.1.0
- PyTorch 2.x
- Transformers 4.x