White-Basilisk: A Hybrid Model for Code Vulnerability Detection

Ioannis Lamprou, Alexander Shevtsov, Ioannis Arapakis, Sotiris Ioannidis · Submission to ICLR 2026 · Rejected

TL;DR

White-Basilisk is a compact, 200M-parameter hybrid model designed for automated code vulnerability detection that outperforms models up to 35× its size. By combining state-space models (Mamba), linear-scaling attention with compressive memory, and a Mixture of Experts (MoE), it overcomes the quadratic memory bottleneck of standard Transformers to analyze long code sequences—up to 524,000 tokens—with a 24-fold reduction in memory consumption.

What Problem Does This Paper Address?

Software vulnerabilities carry immense financial and security risks, yet detecting them remains notoriously difficult. Current approaches hit two major roadblocks:

  1. Severe context limitations: Real-world vulnerabilities often stem from subtle inter-function and file-level interactions. Standard Transformer-based large language models (LLMs) scale quadratically ($O(n^2)$) in compute and memory with sequence length $n$, making full-file or repo-level analysis computationally prohibitive.
  2. The "bigger is better" mismatch: Scaling massive, general-purpose LLMs (e.g., 7B–100B+ parameters) requires massive compute, yet these models frequently stumble on realistic, highly imbalanced benchmarks where vulnerable code accounts for under 10% of samples.

The authors ask: Can specialized, compact architectural design outperform massive parameter counts in high-stakes, long-context domains like code security?

Methods

White-Basilisk replaces standard quadratic Transformer blocks with an interleaved, linear-scaling hybrid architecture consisting of:

  • Mamba Layers: Selective state-space models (SSMs) acting as the backbone for efficient local syntactic pattern recognition with linear time complexity.
  • Basilisk Self-Attention: A modified linear-attention mechanism inspired by Infini-attention. Long inputs are split into 2,048-token segments. Instead of pure streaming, the model computes local dot-product attention per segment, updates a compressed key-value memory matrix $M$ using ELU activations, and accumulates segment representations across the whole sequence. An adaptive gating mechanism blends local and compressive long-term memory.
  • Mixture of Experts (MoE): Sparse feed-forward layers (8 experts, 2 activated per token) interleaved every 2 layers to expand model capacity without increasing compute per token.
  • Imbalance & Robustness Techniques: To handle datasets with 90–97% non-vulnerable code, training uses inverse frequency loss weighting, non-replacement Weighted Random Sampling (front-loading vulnerable samples in each epoch), and Scale-Invariant Fine-Tuning (SIFT) adversarial regularization.
  • Pretraining: Pretrained from scratch on 2M general C/C++ source code files from the StarCoder dataset using both Causal Language Modeling (CLM) and Fill-In-the-Middle (FIM) objectives on a single 40GB A100 GPU (approx. 600 hours).

Datasets

The authors used five widely recognized public benchmarks (focusing on C/C++):

  • PRIMEVUL: A recent, high-quality realistic benchmark designed to avoid synthetic artifacts (3.0% vulnerable samples). Also includes a paired vulnerable/patched evaluation set.
  • BigVul: A large C/C++ dataset derived from CVEs and commit changes (5.8% vulnerable).
  • Draper: Over 1 million function-level C/C++ samples (6.5% vulnerable).
  • REVEAL: Real-world vulnerability dataset from open-source projects (9.9% vulnerable).
  • VulDeePecker: Synthetic/gadget-based C/C++ benchmark with significant duplication (~38%).

Note: No new dataset was created, but the authors mapped validation samples in PRIMEVUL back to their original complete source files to test full-file sequence processing up to 524K tokens.

Key Insights and Ideas

  • More Context Actually Helps Vulnerability Detection: In standard models, performance often degrades over long sequences. Here, detection performance rose consistently from 512 up to 16,384 tokens (PRIMEVUL F1 jumped from 0.111 to 0.411). When evaluating whole files (up to 524K tokens), F1 jumped further from 0.233 to 0.288, proving that vital vulnerability indicators lie in inter-function dependencies outside isolated functions.
  • Linear Memory Enables Massive Windows: At 16K tokens, Basilisk Attention uses ~1.3 GB peak GPU memory compared to >32 GB for standard attention (a 24× reduction), allowing full-file evaluation without out-of-memory (OOM) errors.
  • Specialized Architectures Beat General Scale: Despite having only 200M parameters, White-Basilisk outperforms 7B-parameter models (such as StarCoder2 and CodeGen2.5) by wide margins across benchmarks.
  • The Difficulty of Paired Distinctions: On PRIMEVUL’s paired test (distinguishing vulnerable code from its security fix), White-Basilisk scored 12.92% pair-correctness—matching GPT-4 with Chain-of-Thought (12.94%) and beating open-source baselines (CodeGen2.5 achieved 3.01%), though the low score across all models highlights that detecting subtle security patches remains fundamentally challenging.

Key Results

  • PRIMEVUL: Dataset-specific White-Basilisk achieved F1 = 0.291 (a 35.5% improvement over UnixCoder's 0.214) with a False Negative Vulnerability Detection Score (VD-S) of 0.724 (vs. 0.892).
  • BigVul: Achieved F1 = 0.949 and Accuracy = 0.994 (vs. StarCoder2's F1 = 0.683 and UnixCoder's 0.655).
  • Traditional Benchmarks: Consistently set state-of-the-art results:
  • Draper: F1 = 0.607 (vs. Russell et al. 0.566, VulBERTa 0.579).
  • REVEAL: F1 = 0.493 (vs. baseline 0.413, VulBERTa 0.453).
  • VulDeePecker: F1 = 0.939, Precision = 0.972.
  • CWE Category Granularity: In BigVul, the unified model achieved perfect $F_1 = 1.000$ scores across 22 Common Weakness Enumeration classes, excelling at memory-safety bugs like buffer overflows (CWE-119: F1 = 0.969) and null-pointer dereferences (CWE-476: F1 = 0.971).

Limitations and Future Work

  • Language Scope: The current model is exclusively pretrained and tested on C/C++ code; applicability to memory-managed languages (e.g., Python, Java) remains untested.
  • Sample Scarcity at Extreme Lengths: Although capable of handling 524K tokens, real-world benchmark datasets contain very few samples beyond 16K tokens (e.g., only 19 samples in PRIMEVUL Bin 6), limiting statistical power for ultra-long context evaluation.
  • Explainability: The model operates as a binary classifier; it does not yet output reasoning, root-cause explanations, or line-level vulnerability localization.
  • Future Directions: The authors aim to scale the architecture to 1 billion parameters, create native file-level vulnerability benchmarks, integrate attention visualization for explainability, and extend the hybrid design to general long-sequence NLP tasks.

Summary updated

BibTeX
@misc{lamprou2025white,
  author = {Ioannis Lamprou and Alexander Shevtsov and Ioannis Arapakis and Sotiris Ioannidis},
  title = {{White-Basilisk: A Hybrid Model for Code Vulnerability Detection}},
  year = {2025},
  eprint = {2507.08540},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.08540},
}
Figure