Text Generation
PEFT
Safetensors
Rust
English
security
code-security
vulnerability-detection
cve
cwe
java
ruby
php
qwen2.5-coder
lora
exploit-analysis
conversational
Instructions to use shivanshDIMRI/code-security-auditor-qwen with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use shivanshDIMRI/code-security-auditor-qwen with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-Coder-1.5B-Instruct") model = PeftModel.from_pretrained(base_model, "shivanshDIMRI/code-security-auditor-qwen") - Notebooks
- Google Colab
- Kaggle
Code Security Auditor v2 (Qwen2.5-Coder-1.5B Multilingual CVE/CWE LoRA)
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.
- 1-Click Interactive Google Colab Demo: Launch
demo.ipynbin Colab - Automated CI/CD & Pre-Commit Bot: Ships with GitHub Actions workflow (
.github/workflows/security-audit.yml) and pre-commit integration (.pre-commit-hooks.yaml) at github.com/shiv677/code-security-auditor
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):unsaferaw pointer dereference & out-of-bounds write (CWE-787/CWE-119),Box::from_rawdouble-free & use-after-free (CWE-415/CWE-416), unsoundunsafe impl Send/Syncdata races (CWE-362), integer overflow in allocation layouts (CWE-190), and uninitialized memory exposure viaVec::set_len(CWE-908/CVE-2020-36317). - Java (
>1,100 examples): JNDI Lookup & Log4Shell injection (CWE-917/CVE-2021-44228), insecure deserialization viaObjectInputStream/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.loadRCE (CWE-502/CVE-2013-0156),Kernel#openpipe & backtick OS command injection (CWE-78), Rails Mass Assignment privilege escalation (CWE-915), ERB.html_safe/rawXSS (CWE-79), and ActiveRecord SQL injection (CWE-89). - PHP (
>1,100 examples): PHP Object Injection viaunserialize()(CWE-502), Local/Remote File Inclusion LFI/RFI (CWE-98),mysqli_querySQL injection (CWE-89), loose type juggling & magic hash bypass (CWE-697), andsystem()/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:
bfloat16on NVIDIA GeForce RTX 5070 GPU (Blackwellsm_120, PyTorch 2.11+cu128) - Dataset: 4,568 curated multilingual CVE/CWE vulnerability audit scenarios + 240 evaluation holdout records
- Downloads last month
- 4
Model tree for shivanshDIMRI/code-security-auditor-qwen
Base model
Qwen/Qwen2.5-1.5B Finetuned
Qwen/Qwen2.5-Coder-1.5B Finetuned
Qwen/Qwen2.5-Coder-1.5B-Instruct