Guanni Qu commited on
Commit
c83ccbe
·
1 Parent(s): 32fc41c

Update dataset card with proper YAML frontmatter

Browse files
Files changed (1) hide show
  1. README.md +148 -106
README.md CHANGED
@@ -1,126 +1,168 @@
1
- # A minimal formal model for LLM tool permissions + a tiny detector for prompt-injection-induced grants
2
-
3
- **TL;DR.** LLM agents call tools. Prompt injection can coerce the agent into **granting new rights** (e.g., `browser.read`) it wasn’t authorized to have — a classic **grant/take/transfer** abuse. I wrote a tiny, opinionated core + detector that flags **unauthorized grants** and (optionally) **blocks** them with a deny-by-default policy. Minimal moving parts, fast to reason about, easy to extend.
4
-
5
  ---
6
-
7
- ## Why (problem in two beats)
8
-
9
- - Tool-using agents are great… until the prompt smuggles in a **permission change**.
10
- - I model tool rights as state transitions and surface a simple rule: **blocked unless explicitly allowed**. If something tries to sneak a grant, the detector yells in red.
11
-
 
 
 
 
 
 
 
 
 
12
  ---
13
 
14
- ## Model (small, sharp, composable)
15
-
16
- - **Subjects / Objects / Rights**
17
- - Subject = `assistant`
18
- - Objects = tools `{browser, file_system}`
19
- - Rights = `{use, grant, take, transfer}`
20
- - For the demo I instantiate `use.read` and `grant.read`.
21
- - **State**: `rights_state ⊆ (subject × tool × right)`
22
- - **Transition**: events update state via `grant` / `use`
23
- - **Policy**: `allowed_grants = ∅` (deny-by-default) any `grant` is **unauthorized** unless whitelisted
24
-
25
- Threats I care about first:
26
- 1. **Data exfiltration** via injected `browser.read`
27
- 2. **Tool escalation** (grant write/upload)
28
- 3. **Cross-tool lateral movement** (chained grants to new tools)
29
-
30
- ---
31
-
32
- ## Detector (baseline, intentionally tiny)
33
-
34
- - **Rule**: if an event of type `grant` is **not** in `allowed_grants`, flag
35
- `UNAUTHORIZED GRANT DETECTED`.
36
- - **Heuristic**: mark `note/reason` as injection-like if text contains patterns like
37
- “ignore previous”, “escalate permissions”, “bypass”, etc. (cheap, effective baseline).
38
-
39
- **Fix mode (optional):** `autofix=true` block unauthorized grants, log it, continue execution with least privilege.
40
-
41
- ---
42
-
43
- ## Repo layout
44
-
45
- ```
46
- llm-perm-detector/
47
- ├─ perm_model/
48
- │ └─ model.yaml # tools/rights + allowed_grants (default: empty)
49
- ├─ engine/
50
- │ └─ perm_engine.py # tiny state machine (grant/use) + deny-by-default
51
- ├─ detector/
52
- │ └─ detector.py # injection text heuristic (baseline)
53
- ├─ cases/
54
- │ ├─ benign.json # no permission change no flags
55
- │ ├─ injected.json # injection asks for browser.read flagged
56
- │ └─ injected_autofix.json # same as above but blocked by autofix
57
- └─ simulate.py # glue runner; pretty prints log + summary
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  ```
59
 
60
- ---
61
-
62
- ## Quickstart
63
 
64
- ```bash
65
- # benign (should be clean)
66
- python3 simulate.py cases/benign.json
 
67
 
68
- # injected (should flag an unauthorized grant)
69
- python3 simulate.py cases/injected.json
70
 
71
- # injected + autofix (should flag AND block)
72
- python3 simulate.py cases/injected_autofix.json
73
- ```
 
 
74
 
75
- Expected money lines:
76
 
77
- - Benign:
78
- `No unauthorized grants detected.`
79
- - Injected:
80
- `UNAUTHORIZED GRANT DETECTED: assistant -> browser.read reason='...'`
81
- - Injected + Autofix:
82
- `[DETECTOR] UNAUTHORIZED GRANT DETECTED: ...`
83
- `[AUTOFIX] Blocked unauthorized grant.`
84
 
85
- **Screenshot the three runs** (benign, injected, injected+autofix). That’s the demo.
 
 
 
86
 
87
- ---
88
 
89
- ## Policy knob (optional whitelist)
 
90
 
91
- You can explicitly allow a grant in `perm_model/model.yaml`:
92
 
93
- ```yaml
94
- policies:
95
- allowed_grants:
96
- - ["assistant", "file_system", "read"]
 
 
 
 
97
  ```
98
 
99
- Re-run to see the contrast: whitelisted grants flow; everything else gets flagged/blocked.
100
-
101
- ---
102
-
103
- ## Tiny benchmark plan (what I’m targeting)
104
-
105
- - **40 prompts** total (20 benign / 20 injected)
106
- - KPI goal by **Nov 6**: **precision ≥ 0.80**, **recall ≥ 0.70** on unauthorized grants
107
- - For the demo here, I show the 3 canonical cases above
108
 
109
- ---
110
-
111
- ## Roadmap (2 weeks)
112
-
113
- - **v0.1**: formal core + detector + 40-prompt micro-benchmark; **min-fix playbook**; **5-page draft** + tidy repo
114
- - **Stretch**: add `transfer` events; a simple lattice for right inclusion; evaluate on a more diverse injection set; logs → JSONL for downstream dashboards
115
-
116
- ---
117
-
118
- ## Impact (why this framing)
119
 
120
- - Turns “prompt injection” into concrete, auditable **state transitions**.
121
- - Makes agent tool-use **observable** and **enforceable**.
122
- - Plays nicely with stronger detectors/policies later; baseline is intentionally small so it’s easy to reason about and extend.
123
-
124
- ---
125
 
126
- If you want to skim one thing, run the three cases and look for the red line. If you want to extend it, add a new tool/right in `model.yaml`, drop a new `cases/*.json`, and watch the state machine make the implications obvious.
 
 
 
 
 
 
 
1
  ---
2
+ license: mit
3
+ task_categories:
4
+ - text-classification
5
+ language:
6
+ - en
7
+ tags:
8
+ - linux-kernel
9
+ - security
10
+ - vulnerabilities
11
+ - code
12
+ - bugs
13
+ - software-engineering
14
+ pretty_name: Linux Kernel Vulnerability Dataset
15
+ size_categories:
16
+ - 100K<n<1M
17
  ---
18
 
19
+ # Linux Kernel Vulnerability Dataset
20
+
21
+ **125,183 bug-introducing commits** mined from 20 years of Linux kernel git history (2005-2025).
22
+
23
+ ## Dataset Description
24
+
25
+ This dataset maps every kernel bug fix with a `Fixes:` tag back to the commit that introduced the bug. It enables research on:
26
+
27
+ - **Vulnerability detection**: Train models to identify bug-introducing commits
28
+ - **Bug lifetime analysis**: Study how long different bug types persist
29
+ - **Subsystem risk assessment**: Identify which kernel subsystems have the longest-lived bugs
30
+ - **Developer patterns**: Analyze who introduces and fixes bugs
31
+
32
+ ### Key Statistics
33
+
34
+ | Metric | Value |
35
+ |--------|-------|
36
+ | Total bug-fix pairs | 125,183 |
37
+ | Valid records (0 < lifetime < 27 years) | 123,696 |
38
+ | Average bug lifetime | 2.1 years |
39
+ | Median bug lifetime | 0.7 years |
40
+ | Longest-lived bug | 20.7 years |
41
+ | Bugs hiding 5+ years | 13.5% |
42
+ | Unique fixing commits | 119,449 |
43
+ | Unique bug-introducing authors | 9,159 |
44
+ | With CVE ID | 158 |
45
+ | With Cc: stable | 27,875 (22%) |
46
+
47
+ ## Dataset Structure
48
+
49
+ ### Data Fields
50
+
51
+ | Column | Type | Description |
52
+ |--------|------|-------------|
53
+ | `fixing_commit` | string | SHA of the commit that fixed the bug |
54
+ | `introducing_commit` | string | SHA of the commit that introduced the bug |
55
+ | `lifetime_days` | int | Days between introduction and fix |
56
+ | `subsystem` | string | Kernel subsystem (networking, drivers, fs, etc.) |
57
+ | `bug_type` | string | Detected bug type (race-condition, null-deref, etc.) |
58
+ | `fix_subject` | string | Commit message subject of the fix |
59
+ | `fixing_date` | datetime | When the fix was committed |
60
+ | `introducing_date` | datetime | When the bug was introduced |
61
+ | `files_changed` | string | Files modified in introducing commit |
62
+ | `insertions` | int | Lines added in introducing commit |
63
+ | `deletions` | int | Lines removed in introducing commit |
64
+ | `cve_id` | string | CVE ID if mentioned in fix commit (nullable) |
65
+ | `cc_stable` | bool | Whether fix was tagged for stable backport |
66
+ | `fix_author` | string | Author of the fix |
67
+ | `intro_author` | string | Author who introduced the bug |
68
+
69
+ ### Subsystem Distribution
70
+
71
+ | Subsystem | Count | Avg Lifetime |
72
+ |-----------|-------|--------------|
73
+ | drivers | 38,412 | 2.3 years |
74
+ | networking | 6,079 | 2.9 years |
75
+ | gpu | 5,212 | 1.4 years |
76
+ | filesystem | 4,891 | 2.6 years |
77
+ | sound | 3,847 | 2.1 years |
78
+ | usb | 2,505 | 3.5 years |
79
+ | memory | 2,459 | 1.8 years |
80
+ | bpf | 959 | 1.1 years |
81
+
82
+ ### Bug Type Distribution
83
+
84
+ | Bug Type | Count | Avg Lifetime |
85
+ |----------|-------|--------------|
86
+ | null-deref | 4,931 | 2.2 years |
87
+ | use-after-free | 2,963 | 3.2 years |
88
+ | memory-leak | 2,846 | 3.1 years |
89
+ | refcount | 2,209 | 2.8 years |
90
+ | deadlock | 1,683 | 2.2 years |
91
+ | race-condition | 1,188 | 5.1 years |
92
+ | buffer-overflow | 399 | 3.1 years |
93
+ | integer-overflow | 298 | 3.9 years |
94
+
95
+ ## Collection Methodology
96
+
97
+ ### Mining Process
98
+
99
+ 1. Clone Linux kernel repository at v6.19-rc3
100
+ 2. Run `git log --grep="Fixes:"` to find all fixing commits
101
+ 3. Extract the referenced commit hash from each `Fixes:` tag using regex
102
+ 4. Retrieve metadata (dates, authors, files) from both commits
103
+ 5. Classify subsystem from file paths using 70+ regex patterns
104
+ 6. Detect bug type from commit message keywords
105
+ 7. Calculate lifetime as `fixing_date - introducing_date`
106
+
107
+ ### Extraction Code
108
+
109
+ ```python
110
+ import re
111
+
112
+ def extract_fixes_tag(commit_msg: str) -> str | None:
113
+ """Extract the commit ID from a Fixes: tag"""
114
+ pattern = r'Fixes:\s*([a-f0-9]{12,40})'
115
+ match = re.search(pattern, commit_msg, re.IGNORECASE)
116
+ return match.group(1) if match else None
117
  ```
118
 
119
+ ### Filtering
 
 
120
 
121
+ - Excluded commits where `Fixes:` tag points to non-existent hash
122
+ - Excluded merge commits
123
+ - For lifetime analysis: excluded same-day fixes (lifetime_days = 0)
124
+ - For lifetime analysis: excluded outliers (lifetime > 10,000 days)
125
 
126
+ ## Limitations
 
127
 
128
+ - **Selection bias**: Only ~28% of fix commits use `Fixes:` tags. Well-documented bugs (likely more serious) are overrepresented.
129
+ - **Mainline only**: Doesn't include bugs fixed only in stable branches or vendor kernels.
130
+ - **Subsystem classification**: Heuristic-based on file paths; some bugs span multiple subsystems.
131
+ - **Bug type detection**: Keyword-based; many bugs classified as "unknown".
132
+ - **Timestamp accuracy**: Uses author dates, not commit dates. Rebasing can skew.
133
 
134
+ ## Intended Uses
135
 
136
+ ### Recommended
 
 
 
 
 
 
137
 
138
+ - Training vulnerability detection models (e.g., VulnBERT)
139
+ - Analyzing bug lifetime patterns across subsystems
140
+ - Studying the evolution of kernel security over time
141
+ - Research on code review and testing effectiveness
142
 
143
+ ### Out of Scope
144
 
145
+ - Direct exploit development (commits don't include full code context)
146
+ - Claiming completeness of kernel vulnerability data
147
 
148
+ ## Citation
149
 
150
+ ```bibtex
151
+ @dataset{qu2026kernelvuln,
152
+ author = {Qu, Jenny Guanni},
153
+ title = {Linux Kernel Vulnerability Dataset},
154
+ year = {2026},
155
+ publisher = {HuggingFace},
156
+ url = {https://huggingface.co/datasets/quguanni/kernel-vuln-dataset}
157
+ }
158
  ```
159
 
160
+ ## License
 
 
 
 
 
 
 
 
161
 
162
+ MIT License
 
 
 
 
 
 
 
 
 
163
 
164
+ ## Contact
 
 
 
 
165
 
166
+ - **Author**: Jenny Guanni Qu
167
+ - **Email**: jenny@pebblebed.com
168
+ - **Blog post**: [Kernel bugs hide for 2 years on average](https://pebblebed.com/blog/kernel-bugs)