SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2403.18624 · 2024

Vulnerability Detection with Code Language Models: How Far Are We?

arXiv · PDF · Open in the Atlas

Code that ran

6 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 6 failures of our instrument; 4 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2403.18624.json · badge: /api/ran/2403.18624.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
dlvuldet/primevul canonical (classifier label)
classifier basis: census
6 ran · 4 no recorded run
FunctionStatusWhere it lives
calculate_metrics Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
dlvuldet/primevul/os_expr/run_ft.py
code served (permissive licence) · get_code("7559f2b5dd244067")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, confusion_matrix
import numpy as np

# Create simple binary classification data
# labels: true labels (0 or 1)
# preds: predicted labels (0 or 1)

labels = np.array([0, 1, 1, 0, 1, 1, 0, 0])
preds = np.array([0, 1, 1, 0, 0, 1, 0, 1])

ARGS = {
    "labels": labels,
    "preds": preds
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
calculate_vul_det_score Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
dlvuldet/primevul/calc_vd_score.py
code served (permissive licence) · get_code("879ec3454c9a7395")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Set random seed for reproducibility
np.random.seed(42)

# Create sample predictions (probabilities for positive class)
predictions = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95]

# Create sample ground truth labels (1 = vulnerable, 0 = benign)
ground_truth = [0, 0, 0, 1, 0, 1, 1, 1, 1, 1]

# Create target FPR
target_fpr = 0.005

# Define ARGS dictionary with all parameters
ARGS = {
    "predictions": predictions,
    "ground_truth": ground_truth,
    "target_fpr": target_fpr
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
construct_prompts Ran
ran; our contract draft was wrong, not the code
dlvuldet/primevul/openai_expr/run_prompting.py
code served (permissive licence) · get_code("630c44e7fdc892f8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
import tempfile
import os

# Create a temporary file with sample JSONL data
temp_file = tempfile.NamedTemporaryFile(mode='w', suffix='.jsonl', delete=False)

sample_data = [
    {
        'project': 'project_a',
        'commit_id': 'abc123',
        'func': 'def hello(): return 42',
        'target': 'output_1'
    },
    {
        'project': 'project_b',
        'commit_id': 'def456',
        'func': 'def world(): return 100',
        'target': 'output_2'
    }
]

for sample in sample_data:
    temp_file.write(json.dumps(sample) + '\n')

temp_file.close()

# Create a simple instruction formatter class
class SimpleInstructor:
    def format(self, func):
        return f"Process this function: {func}"

inst = SimpleInstructor()

ARGS = {
    'input_file': temp_file.name,
    'inst': inst
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
convert_examples_to_features Ran
ran; our contract draft was wrong, not the code
dlvuldet/primevul/os_expr/run_ft.py
code served (permissive licence) · get_code("81aa84eb56e35382")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned InputFeatures. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

class MockTokenizer:
    def __init__(self):
        self.cls_token = '[CLS]'
        self.sep_token = '[SEP]'
        self.pad_token_id = 0
    
    def tokenize(self, text):
        return text.split()
    
    def encode(self, text, max_length=None, padding=None, truncation=None):
        tokens = self.tokenize(text)
        if truncation and max_length:
            tokens = tokens[:max_length]
        ids = [i + 1 for i in range(len(tokens))]
        if padding == 'max_length' and max_length:
            ids = ids + [self.pad_token_id] * (max_length - len(ids))
        return ids
    
    def convert_tokens_to_ids(self, tokens):
        return [i + 1 for i in range(len(tokens))]

class MockArgs:
    def __init__(self):
        self.model_type = 'bert'
        self.block_size = 16

torch.manual_seed(0)

js = {
    'func': 'def hello ( x ) : return x + 1',
    'idx': 42,
    'target': 1
}

tokenizer = MockTokenizer()

args = MockArgs()

ARGS = {
    'js': js,
    'tokenizer': tokenizer,
    'args': args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type InputFeatures — a InputFeatures output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a InputFeatures output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
convert_examples_to_features Ran
ran; our contract draft was wrong, not the code
dlvuldet/primevul/os_expr/run_ft_accelerator.py
code served (permissive licence) · get_code("b17fb0860dac6e1d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned InputFeatures. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from unittest.mock import Mock

torch.manual_seed(0)

# Create a minimal tokenizer mock that supports the required methods
class MinimalTokenizer:
    def __init__(self):
        self.cls_token = "[CLS]"
        self.sep_token = "[SEP]"
        self.pad_token_id = 0
        self.vocab = {
            "[CLS]": 1,
            "[SEP]": 2,
            "def": 3,
            "func": 4,
            "return": 5,
            "pass": 6,
            "</s>": 7,
        }
    
    def tokenize(self, text):
        # Simple tokenization - split by spaces and add special tokens as needed
        tokens = text.split()
        return tokens
    
    def encode(self, text, max_length=None, padding=None, truncation=None):
        # Simple encoding - convert tokens to ids with padding
        tokens = self.tokenize(text)
        ids = [self.vocab.get(token, 0) for token in tokens]
        if max_length:
            if len(ids) < max_length:
                ids = ids + [self.pad_token_id] * (max_length - len(ids))
            else:
                ids = ids[:max_length]
        return ids
    
    def convert_tokens_to_ids(self, tokens):
        # Convert list of tokens to ids
        return [self.vocab.get(token, 0) for token in tokens]

# Create minimal args object
class Args:
    def __init__(self):
        self.model_type = 'bert'  # Test with default case
        self.block_size = 16

# Create example input
js = {
    'func': 'def hello world return pass',
    'idx': 1,
    'target': 'classification_label'
}

tokenizer = MinimalTokenizer()
args = Args()

ARGS = {
    'js': js,
    'tokenizer': tokenizer,
    'args': args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type InputFeatures — a InputFeatures output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a InputFeatures output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
convert_examples_to_features Ran
ran; our contract draft was wrong, not the code
dlvuldet/primevul/os_expr/run_ft_clr.py
code served (permissive licence) · get_code("62a2fd5c0079c379")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned InputFeatures. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

class SimpleTokenizer:
    def __init__(self):
        self.cls_token = "[CLS]"
        self.sep_token = "[SEP]"
        self.pad_token_id = 0
        self.vocab = {
            "[CLS]": 101,
            "[SEP]": 102,
            "def": 1000,
            "foo": 1001,
            "bar": 1002,
            "return": 1003,
            "x": 1004,
        }
    
    def tokenize(self, text):
        # Simple whitespace tokenization
        return text.split()
    
    def convert_tokens_to_ids(self, tokens):
        ids = []
        for token in tokens:
            ids.append(self.vocab.get(token, 1005))
        return ids

class SimpleArgs:
    def __init__(self):
        self.block_size = 10

js = {
    'func': 'def foo bar return x',
    'idx': 42,
    'target': 1
}

tokenizer = SimpleTokenizer()
args = SimpleArgs()

ARGS = {
    'js': js,
    'tokenizer': tokenizer,
    'args': args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type InputFeatures — a InputFeatures output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a InputFeatures output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
evaluate Not yet run
unverified (harvested, no recorded run)
dlvuldet/primevul/os_expr/run_ft.py
code served (permissive licence) · get_code("5737bb1a8eda93a3")
How it ran

no invocation recorded.

evaluate Not yet run
unverified (harvested, no recorded run)
dlvuldet/primevul/os_expr/run_ft_accelerator.py
code served (permissive licence) · get_code("24722c9f04658f98")
How it ran

no invocation recorded.

evaluate Not yet run
unverified (harvested, no recorded run)
dlvuldet/primevul/os_expr/run_ft_clr.py
code served (permissive licence) · get_code("ad6ec6651bb9bdf0")
How it ran

no invocation recorded.

truncate_tokens_from_messages Not yet run
unverified (harvested, no recorded run)
dlvuldet/primevul/openai_expr/run_prompting.py
code served (permissive licence) · get_code("b5884da68dade4d3")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 10 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

In the context of the rising interest in code language models (code LMs) and vulnerability detection, we study the effectiveness of code LMs for detecting vulnerabilities. Our analysis reveals significant shortcomings in existing vulnerability datasets, including poor data quality, low label accuracy, and high duplication rates, leading to unreliable model performance in realistic vulnerability detection scenarios. Additionally, the evaluation methods used with these datasets are not representative of real-world vulnerability detection. To address these challenges, we introduce PrimeVul, a new dataset for training and evaluating code LMs for vulnerability detection. PrimeVul incorporates a novel set of data labeling techniques that achieve comparable label accuracy to human-verified benchmarks while significantly expanding the dataset. It also implements a rigorous data de-duplication and chronological data splitting strategy to mitigate data leakage issues, alongside introducing more realistic evaluation metrics and settings. This comprehensive approach aims to provide a more accurate assessment of code LMs' performance in real-world conditions. Evaluating code LMs on PrimeVul reveals that existing benchmarks significantly overestimate the performance of these models. For instance, a state-of-the-art 7B model scored 68.26% F1 on BigVul but only 3.09% F1 on PrimeVul. Attempts to improve performance through advanced training techniques and larger models like GPT-3.5 and GPT-4 were unsuccessful, with results akin to random guessing in the most stringent settings. These findings underscore the considerable gap between current capabilities and the practical requirements for deploying code LMs in security roles, highlighting the need for more innovative research in this domain.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2403.18624")
get_code_for_paper("2403.18624")
have("2403.18624")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2403.18624.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2403.18624.svg)](https://syntology.ai/paper/2403.18624)

Connect an agent — have() is free.