Qwen2.5-Coder-1.5B XSS Analyst
code vulnerability analysis
2 min readupdated
This LoRA adapter (a lightweight add-on for a base model) fine-tunes Qwen2.5-Coder-1.5B-Instruct to catch cross-site scripting (XSS) flaws in Vue 3, Django, and Spring Boot source code. It outputs structured JSON reports detailing sources, data-flow paths, severity scores, ready-to-use patches, and proof-of-concept payloads for testing. The model also features a conversational mode to answer security questions, making it a practical tool for developers and security engineers running initial code audits.
Key features
- XSS specialization: detects vulnerabilities across Vue 3, Django, and Spring Boot codebases.
- Structured reporting: outputs JSON results complete with data-flow paths and code fixes.
- Hybrid training: trained via a two-stage QLoRA pipeline combining synthetic examples and conversational data.
- Proof of concept: generates PoC payloads for authorized security testing.
What you can do
- Scan a project: analyze Python, JavaScript, or template files using the companion GitHub repository.
- Generate JSON reports: pinpoint vulnerable code segments with exact line numbers and output contexts.
- Run pre-release audits: use the model for initial security checks on web apps before deployment.
- Explore vulnerabilities: ask questions about security theory and break down specific attack vectors.
Example
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base = "Qwen/Qwen2.5-Coder-1.5B-Instruct"
tok = AutoTokenizer.from_pretrained(base)
model = AutoModelForCausalLM.from_pretrained(base, torch_dtype="auto", device_map="auto")
model = PeftModel.from_pretrained(model, "hareramray325/qwen2.5-coder-1.5b-xss")
messages = [{"role": "user", "content": "What is DOM-based XSS?"}]
ids = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
out = model.generate(ids, max_new_tokens=512, do_sample=False)
print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True))
Read more
DetailsBase model: Qwen/Qwen2.5-Coder-1.5B-Instruct
Library: peft (QLoRA)
Hardware requirements: 2.34 GiB peak VRAM (trained on a single 8 GB GPU)
Limitations: roughly half of safe code may trigger false positives on unseen patterns, and it misses certain javascript: URL sinks










Comments