Code Security Auditor v2 (Qwen2.5-Coder-1.5B Multilingual CVE/CWE LoRA)

Open In Colab Security Audit CI GitHub Repository

Fine-tuned on 4,568 high-fidelity multilingual CVE/CWE security auditing traces across Rust, Java, Ruby, PHP, Python, C/C++, Go, JavaScript/TypeScript, and Solidity. Analyzes source code for critical security vulnerabilities, identifies MITRE CWE identifiers and CVSS severities, breaks down adversary exploit vectors, and synthesizes production-ready remediated patches.

What's New in v2 (Multilingual CVE/CWE Expansion)

  • 4,568 Validated ChatML Training Traces + 240 Stratified Holdout Traces (dataset/train_dataset_multilingual.jsonl)
  • Rust (>1,100 examples): unsafe raw pointer dereference & out-of-bounds write (CWE-787/CWE-119), Box::from_raw double-free & use-after-free (CWE-415/CWE-416), unsound unsafe impl Send/Sync data races (CWE-362), integer overflow in allocation layouts (CWE-190), and uninitialized memory exposure via Vec::set_len (CWE-908 / CVE-2020-36317).
  • Java (>1,100 examples): JNDI Lookup & Log4Shell injection (CWE-917 / CVE-2021-44228), insecure deserialization via ObjectInputStream/Jackson/XStream (CWE-502), Spring Expression Language (SpEL) RCE (CWE-917), JDBC SQL injection (CWE-89), and Zip-Slip / Path Traversal (CWE-22).
  • Ruby (>1,100 examples): YAML.load & Marshal.load RCE (CWE-502 / CVE-2013-0156), Kernel#open pipe & backtick OS command injection (CWE-78), Rails Mass Assignment privilege escalation (CWE-915), ERB .html_safe / raw XSS (CWE-79), and ActiveRecord SQL injection (CWE-89).
  • PHP (>1,100 examples): PHP Object Injection via unserialize() (CWE-502), Local/Remote File Inclusion LFI/RFI (CWE-98), mysqli_query SQL injection (CWE-89), loose type juggling & magic hash bypass (CWE-697), and system()/eval() command & code injection (CWE-78/CWE-94).
  • False-Positive Calibration: Includes ~15% already-hardened negative control snippets across Rust, Java, Ruby, and PHP.

Usage Example

import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer

base_model = "Qwen/Qwen2.5-Coder-1.5B-Instruct"
adapter_id = "shivanshDIMRI/code-security-auditor-qwen"

tokenizer = AutoTokenizer.from_pretrained(base_model, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    base_model,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True,
)
model = PeftModel.from_pretrained(model, adapter_id)

code = '''
pub fn copy_packet(src: *const u8, dst: *mut u8, untrusted_len: usize) {
    unsafe {
        std::ptr::copy_nonoverlapping(src, dst, untrusted_len);
    }
}
'''

messages = [
    {"role": "system", "content": "You are an expert security auditor and vulnerability research engine. Inspect the provided source code for vulnerabilities, specify the CWE and severity, explain the exploit vector, and provide the production-ready secure patch."},
    {"role": "user", "content": f"Audit this Rust snippet for security vulnerabilities:\n\n```rust\n{code}\n```"}
]

inputs = tokenizer(tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True), return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=1024, temperature=0.2)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))

Training Details

  • Base Model: Qwen/Qwen2.5-Coder-1.5B-Instruct
  • Method: Parameter-Efficient Fine-Tuning (PEFT) via LoRA (r=16, lora_alpha=32, target: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj)
  • Precision: bfloat16 on NVIDIA GeForce RTX 5070 GPU (Blackwell sm_120, PyTorch 2.11+cu128)
  • Dataset: 4,568 curated multilingual CVE/CWE vulnerability audit scenarios + 240 evaluation holdout records
Downloads last month
4
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for shivanshDIMRI/code-security-auditor-qwen

Adapter
(253)
this model