bencodez commited on
Commit
28c784c
·
verified ·
1 Parent(s): eefdcef

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +68 -0
README.md ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Qwen/Qwen2.5-Coder-0.5B-Instruct
4
+ tags:
5
+ - code
6
+ - security
7
+ - secure-coding
8
+ - lora
9
+ - qwen2.5-coder
10
+ language:
11
+ - en
12
+ pipeline_tag: text-generation
13
+ ---
14
+
15
+ # Cipheron
16
+
17
+ **Cipheron** is a small, LoRA fine-tuned coding model specialized in **secure code review** — given a piece of code, it tries to spot common security vulnerabilities and suggest a fixed, secure version.
18
+
19
+ - **Base model**: [Qwen/Qwen2.5-Coder-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-0.5B-Instruct) (Apache 2.0)
20
+ - **Method**: LoRA fine-tuning (r=16, alpha=32), 3 epochs, ~830 steps
21
+ - **Training data**: [CyberNative/Code_Vulnerability_Security_DPO](https://huggingface.co/datasets/CyberNative/Code_Vulnerability_Security_DPO) (~4.6k vulnerable/secure code pairs across 11 languages), trained on the secure ("chosen") responses only
22
+ - **Size**: 0.5B parameters
23
+ - **Formats**: full-precision merged model (this repo) and a `Cipheron-Q8_0.gguf` quantized file for on-device / CPU / phone use via llama.cpp, Ollama, or similar runners
24
+
25
+ ## What it's good at
26
+
27
+ In testing, Cipheron reliably identifies and correctly fixes:
28
+ - **SQL injection** (rewrites string-concatenated queries as parameterized queries)
29
+ - **Command injection** (rewrites `os.system`/shell string concatenation as safer `subprocess` calls)
30
+
31
+ These categories are well-represented in the training data.
32
+
33
+ ## Known limitations
34
+
35
+ The training dataset is heavily imbalanced (e.g. ~30% buffer-overflow examples, mostly in memory-unsafe languages like C/C++, largely irrelevant to Python; some important categories like path traversal, hardcoded secrets, and weak cryptography have only a handful of examples total). As a result, in testing Cipheron **failed to correctly fix**:
36
+ - Path traversal
37
+ - Hardcoded secrets / API keys
38
+ - Weak hashing (e.g. MD5 for passwords)
39
+ - Insecure deserialization (`pickle.loads` on untrusted input)
40
+ - Reflected XSS
41
+
42
+ For these categories it tends to produce superficial, security-irrelevant changes (e.g. wrapping code in try/except, adding default arguments) rather than the actual fix. **Do not rely on this model as a substitute for a real security review or a larger model.** It's best used as a lightweight, offline first-pass check for the vulnerability classes listed above under "What it's good at," not as a general-purpose security auditor.
43
+
44
+ This is a small (0.5B parameter) educational/experimental model, not a production security tool.
45
+
46
+ ## Usage
47
+
48
+ ```python
49
+ from transformers import AutoModelForCausalLM, AutoTokenizer
50
+ import torch
51
+
52
+ tokenizer = AutoTokenizer.from_pretrained("bencodez/Cipheron")
53
+ model = AutoModelForCausalLM.from_pretrained("bencodez/Cipheron", torch_dtype=torch.bfloat16)
54
+
55
+ messages = [
56
+ {"role": "system", "content": "You are a secure coding assistant. Review code for security vulnerabilities and provide fixed, secure versions."},
57
+ {"role": "user", "content": "Review this code for security issues and fix it:\n\ndef get_user(username):\n query = \"SELECT * FROM users WHERE username = '\" + username + \"'\"\n return db.execute(query)"},
58
+ ]
59
+ input_ids = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=False)
60
+ out = model.generate(input_ids, max_new_tokens=250)
61
+ print(tokenizer.decode(out[0][input_ids.shape[1]:], skip_special_tokens=True))
62
+ ```
63
+
64
+ Or with the GGUF file via `llama-cpp-python` / llama.cpp / Ollama for lightweight CPU/on-device inference.
65
+
66
+ ## License
67
+
68
+ Apache 2.0, inherited from the base model (Qwen2.5-Coder-0.5B-Instruct).