Downloads · 30 days
6
23% of all-time downloads
jacpacd/Foss-Cherub-Vuln-Detector
Foss-Cherub-Vuln-Detector is a machine learning model from jacpacd. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Downloads · 30 days
6
23% of all-time downloads
All-time downloads
26
Public
Parameters
7.6B
15.2 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors15.2 GB · 100%
From the Hugging Face model README
--
Foss-Cherub-Vuln-Detector-v1 is a specialized generative language model fine-tuned to act as an expert security analyst. Its primary function is to analyze snippets of source code across various languages (C, C++, Java, Python) and identify potential security flaws.
The model is trained to follow a specific instruction format, where it receives code and responds with either "Vulnerable" along with the relevant Common Weakness Enumeration (CWE) ID, or "Not Vulnerable" if the code appears secure. It also has capabilities for generating mitigation advice when prompted correctly.
Key Features:
This model is intended to be used as the core AI engine for automated security auditing tools, IDE extensions, and CI/CD pipeline security gates. It is designed to assist:
This model is not a replacement for a comprehensive security review by a human expert, especially for critical applications. It should be used as an assistive tool to augment, not replace, manual security practices.
The model was fine-tuned on a synthetically generated dataset comprising thousands of instruction-response pairs. Each data point consisted of a source code snippet (either secure or containing a specific vulnerability) and an expert-style analysis. The training was performed using the following prompt structure, which is crucial for effective inference:
<|im_start|>system
You are an expert security analyst. Analyze the code for vulnerabilities. Respond with "Vulnerable" and the CWE ID if a flaw exists, or "Not Vulnerable".
<|im_end|>
<|im_start|>user
Analyze this {language} code:
{code}
<|im_end|>
<|im_start|>assistant
{expert_analysis}
The model should be used with the transformers library. It is critical to format the input using the same prompt structure it was trained on.
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
# Your Hugging Face repository name
model_name = "CipherSaber/Foss-Cherub-Vuln-Detector-v1"
device = "cuda" if torch.cuda.is_available() else "cpu"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
device_map="auto"
)
# Example vulnerable C code
vulnerable_code = """
#include <stdio.h>
#include <string.h>
void vulnerable_function(char *input) {
char buffer[100];
strcpy(buffer, input); // Classic buffer overflow
printf("Input was: %s\n", buffer);
}
"""
# Format the input using the specific prompt template
prompt = f"""<|im_start|>system
You are an expert security analyst. Analyze the code for vulnerabilities. Respond with "Vulnerable" and the CWE ID if a flaw exists, or "Not Vulnerable".
<|im_end|>
<|im_start|>user
Analyze this C code:
{vulnerable_code}
<|im_end|>
<|im_start|>assistant
"""
# Generate the analysis
inputs = tokenizer(prompt, return_tensors="pt").to(device)
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=50)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
analysis = response.split("<|im_start|>assistant")[-1].strip()
print(analysis)
# Expected Output: Vulnerable. CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')
If you use this model in your research or application, please cite it as follows:
@software{CipherSaber_2025_Foss-Cherub,
author = {CipherSaber},
title = {{Foss-Cherub-Vuln-Detector-v1: An AI-Powered Source Code Vulnerability Detector}},
month = oct,
year = 2025,
url = {https://huggingface.co/CipherSaber/Foss-Cherub-Vuln-Detector-v1}
}