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ecommits: Real-World Vulnerability-Fixing Commits
|
| 93 |
+
from **Do Language Models Prefer Vulnerable Code? A Probabilistic Study of Insecure Code Preference** @ICST 2026
|
| 94 |
+
|
| 95 |
+
A curated dataset of **2,493 paired vulnerable/secure C code samples** from real-world vulnerability-fixing commits, covering **25 CWE (Common Weakness Enumeration) categories** and **2,422 unique vulnerability identifiers**.
|
| 96 |
+
|
| 97 |
+
## Overview
|
| 98 |
+
|
| 99 |
+
DeltaSecommits provides paired code snapshots—the vulnerable version (pre-patch) and the secure version (post-patch) of the same file from a single commit. This structure eliminates confounds from stylistic variation between authors and projects, making it ideal for mechanistic analysis of how models encode security properties.
|
| 100 |
+
|
| 101 |
+
Each pair includes:
|
| 102 |
+
- **Vulnerable code**: Pre-patch version with the security flaw
|
| 103 |
+
- **Secure code**: Post-patch version with the fix applied
|
| 104 |
+
- **CWE identifier**: The specific vulnerability type (CWE-119, CWE-89, etc.)
|
| 105 |
+
- **Severity rating**: CVE severity (if available)
|
| 106 |
+
|
| 107 |
+
## Data Source & Curation
|
| 108 |
+
|
| 109 |
+
The dataset is drawn from authoritative sources:
|
| 110 |
+
- **Open Source Vulnerability (OSV) Database**: https://osv.dev
|
| 111 |
+
- **National Vulnerability Database (NVD)**: https://nvd.nist.gov
|
| 112 |
+
|
| 113 |
+
**Filtering pipeline** (for quality assurance):
|
| 114 |
+
1. Single-file commits only — excludes multi-file changes that cloud the signal
|
| 115 |
+
2. Single-commit fixes — removes vulnerabilities requiring multiple commits to resolve
|
| 116 |
+
3. Patch retrieval — uses GitHub API to fetch commit metadata and validate patches
|
| 117 |
+
4. Label deduplication — removes duplicate vulnerability IDs
|
| 118 |
+
|
| 119 |
+
This resulted in the final dataset of **2,493 high-quality pairs** from **278 publicly disclosed vulnerabilities**.
|
| 120 |
+
|
| 121 |
+
## CWE Coverage
|
| 122 |
+
|
| 123 |
+
The dataset spans 25 CWE categories across four major families:
|
| 124 |
+
|
| 125 |
+
**Memory Safety** (3 CWEs, 610 pairs)
|
| 126 |
+
- CWE-119: Buffer Overflow
|
| 127 |
+
- CWE-125: Out-of-bounds Read
|
| 128 |
+
- CWE-787: Out-of-bounds Write
|
| 129 |
+
|
| 130 |
+
**Injection** (2 CWEs, 471 pairs)
|
| 131 |
+
- CWE-89: SQL Injection
|
| 132 |
+
- CWE-79: Cross-Site Scripting (XSS)
|
| 133 |
+
|
| 134 |
+
**Resource Management** (3 CWEs, 248 pairs)
|
| 135 |
+
- CWE-401: Memory Leak
|
| 136 |
+
- CWE-400: Resource Consumption
|
| 137 |
+
- CWE-416: Use-After-Free
|
| 138 |
+
|
| 139 |
+
**Information Disclosure** (1 CWE, 143 pairs)
|
| 140 |
+
- CWE-200: Sensitive Information Exposure
|
| 141 |
+
|
| 142 |
+
And 16 additional CWEs with varying sample counts (minimum 20 pairs per type).
|
| 143 |
+
|
| 144 |
+
## Dataset Statistics
|
| 145 |
+
|
| 146 |
+
| Metric | Value |
|
| 147 |
+
|--------|-------|
|
| 148 |
+
| Total pairs | 2,493 |
|
| 149 |
+
| CWE categories | 25 |
|
| 150 |
+
| Unique vulnerabilities | 2,422 |
|
| 151 |
+
| Programming language | C |
|
| 152 |
+
| Mean tokens (vulnerable) | 230 |
|
| 153 |
+
| Mean tokens (secure) | 191 |
|
| 154 |
+
| Pairs where vulnerable > secure | 85% |
|
| 155 |
+
|
| 156 |
+
## Usage
|
| 157 |
+
|
| 158 |
+
### Loading the Dataset
|
| 159 |
+
|
| 160 |
+
```python
|
| 161 |
+
from datasets import load_dataset
|
| 162 |
+
|
| 163 |
+
# Load full dataset
|
| 164 |
+
ds = load_dataset("deltasecommits")
|
| 165 |
+
|
| 166 |
+
# Access a single example
|
| 167 |
+
example = ds["train"][0]
|
| 168 |
+
print(example["vulnerable_code"])
|
| 169 |
+
print(example["secure_code"])
|
| 170 |
+
print(example["cwe"])
|
| 171 |
+
```
|
| 172 |
+
|
| 173 |
+
### Data Format
|
| 174 |
+
|
| 175 |
+
Each example contains:
|
| 176 |
+
```python
|
| 177 |
+
{
|
| 178 |
+
"vulnerable_code": str, # Pre-patch code with vulnerability
|
| 179 |
+
"secure_code": str, # Post-patch code with fix
|
| 180 |
+
"cwe": str, # CWE identifier (e.g., "CWE-119")
|
| 181 |
+
"severity": str, # CVE severity (if available)
|
| 182 |
+
"vulnerability_id": str, # Unique identifier
|
| 183 |
+
"source": str # Source (osv, nvd)
|
| 184 |
+
}
|
| 185 |
+
```
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
## Use Cases
|
| 189 |
+
|
| 190 |
+
**Security-focused ML research:**
|
| 191 |
+
- Training vulnerability detection models
|
| 192 |
+
- Analyzing how LLMs encode security information
|
| 193 |
+
- Benchmarking code security analyzers
|
| 194 |
+
|
| 195 |
+
**Mechanistic interpretability:**
|
| 196 |
+
- Understanding model representations of code safety
|
| 197 |
+
- Probing vulnerability direction geometry
|
| 198 |
+
- Analyzing activation patterns across CWE types
|
| 199 |
+
|
| 200 |
+
**Code generation safety:**
|
| 201 |
+
- Evaluating whether language models prefer secure or vulnerable patterns
|
| 202 |
+
- Testing security alignment in code assistants
|
| 203 |
+
- Debugging security misalignment in LLM-generated code
|
| 204 |
+
|
| 205 |
+
## Limitations & Known Issues
|
| 206 |
+
|
| 207 |
+
1. **Language scope**: C code only. Multi-language analysis requires separate datasets (SVEN, PreciseBugs).
|
| 208 |
+
2. **Real-world bias**: Reflects OSV/NVD coverage—some vulnerability types may be overrepresented.
|
| 209 |
+
3. **Patch simplicity**: Many fixes are removals/simplifications rather than structural additions. Mean vulnerable code is 20% longer.
|
| 210 |
+
4. **CWE distribution**: Some CWE categories have <30 pairs; use caution with small-sample types.
|
| 211 |
+
|
| 212 |
+
## Replication & Validation
|
| 213 |
+
|
| 214 |
+
The core findings have been validated on two additional C vulnerability datasets:
|
| 215 |
+
|
| 216 |
+
- **SVEN** (Semantic Vulnerability Extraction Network): 423 paired samples across 6 CWEs, synthetically curated
|
| 217 |
+
- **PreciseBugs**: 4,101 paired samples from open-source repositories across 9 CWEs
|
| 218 |
+
|
| 219 |
+
Results consistently replicate across all three datasets.
|
| 220 |
+
|
| 221 |
+
## Related Work
|
| 222 |
+
|
| 223 |
+
- **CVSS**: Common Vulnerability Scoring System (severity ratings)
|
| 224 |
+
- **CWSS**: Common Weakness Scoring System (weakness prioritization)
|
| 225 |
+
- **SonarQube**: Static analysis for vulnerability detection
|
| 226 |
+
- **Semgrep**: Lightweight vulnerability scanning
|
| 227 |
+
|
| 228 |
+
## Contact & Issues
|
| 229 |
+
|
| 230 |
+
For dataset issues, questions, or contributions:
|
| 231 |
+
- GitHub: https://github.com/rufimelo/DeltaSecommits/edit/main/README.md)
|
| 232 |
+
- Email: rmelo@cs.cmu.edu
|
| 233 |
+
|
| 234 |
+
## License
|
| 235 |
+
|
| 236 |
+
DeltaSecommits is provided under the **MIT License**. Code samples are derived from publicly disclosed vulnerabilities in the OSV and NVD databases and are used in accordance with those databases' terms.
|
| 237 |
|
| 238 |
## 📚 Citation
|
| 239 |
|