Dataset Viewer
Auto-converted to Parquet Duplicate
cwe_id
stringclasses
158 values
cwe_description
stringclasses
158 values
language
stringclasses
21 values
vulnerable_code
stringlengths
54
508k
fixed_code
stringlengths
54
508k
file_pair_id
stringlengths
3
7
source
stringclasses
1 value
language_dir
stringclasses
29 values
CWE-1021
Improper Restriction of Rendered UI Layers or Frames - A web application is expected to place restrictions on whether it is allowed to be rendered within frames, iframes, objects, embed or applet elements.
go
package controllers import ( "compress/gzip" "context" "crypto/tls" "html/template" "net/http" "net/url" "time" "github.com/NYTimes/gziphandler" "github.com/gophish/gophish/auth" "github.com/gophish/gophish/config" ctx "github.com/gophish/gophish/context" "github.com/gophish/gophish/controllers/api" log ...
package controllers import ( "compress/gzip" "context" "crypto/tls" "html/template" "net/http" "net/url" "time" "github.com/NYTimes/gziphandler" "github.com/gophish/gophish/auth" "github.com/gophish/gophish/config" ctx "github.com/gophish/gophish/context" "github.com/gophish/gophish/controllers/api" log ...
4282_0
crossvul
go
CWE-1021
Improper Restriction of Rendered UI Layers or Frames - A web application is expected to place restrictions on whether it is allowed to be rendered within frames, iframes, objects, embed or applet elements.
go
package middleware import ( "encoding/json" "fmt" "net/http" "strings" ctx "github.com/gophish/gophish/context" "github.com/gophish/gophish/models" "github.com/gorilla/csrf" ) // CSRFExemptPrefixes are a list of routes that are exempt from CSRF protection var CSRFExemptPrefixes = []string{ "/api", } // CSRF...
package middleware import ( "encoding/json" "fmt" "net/http" "strings" ctx "github.com/gophish/gophish/context" "github.com/gophish/gophish/models" "github.com/gorilla/csrf" ) // CSRFExemptPrefixes are a list of routes that are exempt from CSRF protection var CSRFExemptPrefixes = []string{ "/api", } // CSRF...
4282_1
crossvul
go
CWE-1021
Improper Restriction of Rendered UI Layers or Frames - A web application is expected to place restrictions on whether it is allowed to be rendered within frames, iframes, objects, embed or applet elements.
php
<?php /* * LimeSurvey * Copyright (C) 2007-2016 The LimeSurvey Project Team / Carsten Schmitz * All rights reserved. * License: GNU/GPL License v3 or later, see LICENSE.php * LimeSurvey is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includ...
<?php /* * LimeSurvey * Copyright (C) 2007-2016 The LimeSurvey Project Team / Carsten Schmitz * All rights reserved. * License: GNU/GPL License v3 or later, see LICENSE.php * LimeSurvey is free software. This version may have been modified pursuant * to the GNU General Public License, and as distributed it includ...
1075_0
crossvul
php
CWE-113
Improper Neutralization of CRLF Sequences in HTTP Headers ('HTTP Request/Response Splitting') - HTTP agents or components may include a web server, load balancer, reverse proxy, web caching proxy, application firewall, web browser, etc.
javascript
'use strict'; const util = require('util'); const net = require('net'); const HTTPParser = process.binding('http_parser').HTTPParser; const assert = require('assert').ok; const common = require('_http_common'); const parsers = common.parsers; const freeParser = common.freeParser; const debug = common.debug; const CRLF...
'use strict'; const util = require('util'); const net = require('net'); const HTTPParser = process.binding('http_parser').HTTPParser; const assert = require('assert').ok; const common = require('_http_common'); const parsers = common.parsers; const freeParser = common.freeParser; const debug = common.debug; const CRLF...
5103_0
crossvul
js
CWE-116
"Improper Encoding or Escaping of Output - Improper encoding or escaping can allow attackers to chan(...TRUNCATED)
python
"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyrigt: (c) 2017, Yanis Guenane <yanis+ansible@gu(...TRUNCATED)
"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyrigt: (c) 2017, Yanis Guenane <yanis+ansible@gu(...TRUNCATED)
4295_1
crossvul
py
CWE-116
"Improper Encoding or Escaping of Output - Improper encoding or escaping can allow attackers to chan(...TRUNCATED)
python
"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyright: (c) 2016, Yanis Guenane <yanis+ansible@g(...TRUNCATED)
"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyright: (c) 2016, Yanis Guenane <yanis+ansible@g(...TRUNCATED)
4295_2
crossvul
py
CWE-116
"Improper Encoding or Escaping of Output - Improper encoding or escaping can allow attackers to chan(...TRUNCATED)
python
"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyright: (c) 2016-2017, Yanis Guenane <yanis+ansi(...TRUNCATED)
"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyright: (c) 2016-2017, Yanis Guenane <yanis+ansi(...TRUNCATED)
4295_3
crossvul
py
CWE-116
"Improper Encoding or Escaping of Output - Improper encoding or escaping can allow attackers to chan(...TRUNCATED)
python
"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyright: (c) 2016, Yanis Guenane <yanis+ansible@g(...TRUNCATED)
"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyright: (c) 2016, Yanis Guenane <yanis+ansible@g(...TRUNCATED)
4295_4
crossvul
py
CWE-116
"Improper Encoding or Escaping of Output - Improper encoding or escaping can allow attackers to chan(...TRUNCATED)
python
"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyright: (c) 2019, Patrick Pichler <ppichler+ansi(...TRUNCATED)
"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyright: (c) 2019, Patrick Pichler <ppichler+ansi(...TRUNCATED)
4295_5
crossvul
py
CWE-116
"Improper Encoding or Escaping of Output - Improper encoding or escaping can allow attackers to chan(...TRUNCATED)
python
"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyright: (c) 2016-2017, Yanis Guenane <yanis+ansi(...TRUNCATED)
"#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n# Copyright: (c) 2016-2017, Yanis Guenane <yanis+ansi(...TRUNCATED)
4295_6
crossvul
py
End of preview. Expand in Data Studio

CrossVul Multi-Language Security Vulnerability Dataset

Security vulnerability dataset from CrossVul with 9,313 before/after code pairs across 158 CWE categories and 21 programming languages.

Contains vulnerable code examples paired with their secure fixes, ideal for training AI models on security code remediation.

Dataset Statistics

  • Total Examples: 9,313
  • CWE Categories: 158
  • Languages: 21
  • Format: Raw vulnerability records (JSON Lines)

Top Languages

Language Examples
c 3,972
php 2,139
javascript 660
python 492
java 489
ruby 422
cpp 399
go 172
xml 106
json 97

Top CWE Categories

CWE ID Description Examples
CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') - Cross-site scripting (XSS) vulnerabilities occur when: Untrusted data enters a web application, typically from a web request. 1,426
CWE-119 Improper Restriction of Operations within the Bounds of a Memory Buffer - Certain languages allow direct addressing of memory locations and do not automatically ensure that these locations are valid for the memory buffer that is being referenced. 724
CWE-20 Improper Input Validation - Input validation is a frequently-used technique for checking potentially dangerous inputs in order to ensure that the inputs are safe for processing within the code, or when communicating with othe... 710
CWE-125 Out-of-bounds Read - Typically, this can allow attackers to read sensitive information from other memory locations or cause a crash. 531
CWE-200 Exposure of Sensitive Information to an Unauthorized Actor - There are many different kinds of mistakes that introduce information exposures. 448
CWE-264 Permissions, Privileges, and Access Controls 419
CWE-89 Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') - Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data. 393
CWE-352 Cross-Site Request Forgery (CSRF) - When a web server is designed to receive a request from a client without any mechanism for verifying that it was intentionally sent, then it might be possible for an attacker to trick a client into... 298
CWE-476 NULL Pointer Dereference - NULL pointer dereference issues can occur through a number of flaws, including race conditions, and simple programming omissions. 244
CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') - Many file operations are intended to take place within a restricted directory. 231

Usage

from datasets import load_dataset

# Load raw vulnerability dataset
dataset = load_dataset("hitoshura25/crossvul")

# Example raw record format
record = dataset['train'][0]
print(record)
# {
#   'cwe_id': 'CWE-79',
#   'cwe_description': 'Cross-site Scripting (XSS)',
#   'language': 'java',
#   'vulnerable_code': '...',
#   'fixed_code': '...',
#   'file_pair_id': '1163_0',
#   'source': 'crossvul',
#   'language_dir': 'java'
# }

Processing for Training

This dataset contains raw vulnerability data. To use for training:

Step 1: Transform into Chat Format (process_artifacts.py)

# Transform raw records into chat-formatted training pairs
def transform_to_chat(record):
    return {
        'messages': [
            {'role': 'system', 'content': 'Security expert...'},
            {'role': 'user', 'content': f"Fix {record['cwe_id']} in {record['language']}:\n{record['vulnerable_code']}"},
            {'role': 'assistant', 'content': f"Fixed code:\n{record['fixed_code']}"}
        ]
    }

Step 2: Sequential Fine-Tuning

# Stage 1: General security training (this dataset)
model = train_on_crossvul(
    model_path="base-model",
    dataset="hitoshura25/crossvul",
    transform_fn=transform_to_chat
)

# Stage 2: Project-specific adaptation
model = specialized_training(
    base_model=model,
    project_data="your-vulnerability-dataset",
    memory_replay=0.15  # 15% CrossVul to prevent forgetting
)

Citation

If you use this dataset, please cite the original CrossVul paper:

@inproceedings{wartschinski2022vulnrepair,
  title={VulnRepair: Learning to Repair Vulnerable Code with Graph Neural Networks},
  author={Wartschinski, Laura and Noller, Yannic and Vogel, Thomas and Kehrer, Timo and Grunske, Lars},
  booktitle={Proceedings of the 44th International Conference on Software Engineering},
  year={2022}
}

License

Apache License 2.0 - Derived from CrossVul Dataset

Dataset Preprocessing

This dataset was processed from the original CrossVul dataset using automated scripts to:

  • Match vulnerable/fixed code pairs (bad_*/good_* files)
  • Detect programming language from directory structure
  • Filter by file size and quality (<500KB, >50 chars)
  • Extract CWE metadata and descriptions
  • Output raw JSON Lines format (no chat formatting)

Note: This is a raw dataset. Use process_artifacts.py to transform into chat-formatted training data.

Preprocessing script: crossvul_dataset_loader.py

Downloads last month
177