Vulnerability Prompt Analysis with O3 (CVE-2025-37899 use-after-free)
Vulnerability Prompt Analysis with O3 (CVE-2025-37899 use-after-free)
一句話摘要:Sean Heelan 公開的 system prompt — 教 OpenAI o3 用三段式(code path → 條件分析 → 矛盾自檢)找 Linux kernel 的 use-after-free 漏洞;嚴守「寧可不報、不報 false positive」原則,實際成功發現 CVE-2025-37899。
核心論點(150-200 字繁中)
這份 raw prompt 是 Sean Heelan 用來驅動 OpenAI o3 model 在 Linux kernel source code 中尋找 use-after-free(UAF,釋放後使用) 漏洞的 system prompt 範本,且實際產出 CVE-2025-37899 — 一個被官方確認的 kernel 漏洞。Prompt 設計核心是三階段方法論:(1) Code path documentation — 從 entry point 到 vulnerability 點,逐步寫出完整 code path;(2) Conditional analysis — 對 path 上每個 conditional statement,具體說明攻擊者要如何控制條件以達成所需 outcome,把理論漏洞轉成可行的攻擊腳本;(3) Contradiction detection — 提交前自我審查推理是否有矛盾或未經驗證的假設,等同 self peer-review。最關鍵的紀律:「It is better to report no vulnerabilities than to report false positives or hypotheticals」— 寧可漏報也不願誤報。對於遺漏的 helper function,分兩類處理:應用層的請使用者補定義;屬於 Linux kernel API 的可在有信心時自行假設。
關鍵概念
- Use-after-free(UAF,釋放後使用) — 程式 free 一塊記憶體後,仍持有 dangling pointer 並去 read/write 它,可導致 memory corruption、資訊外洩或 RCE。
- CVE-2025-37899 — 由此 prompt 驅動 o3 找出的 Linux kernel UAF 漏洞,是首個由 LLM 獨立發現並獲官方 CVE 編號的 kernel 漏洞之一。
- Dangling pointer(懸空指標) — 指向已釋放或失效記憶體的 pointer,是 UAF 的物質載體。
- Code path / conditional analysis — 從程式 entry 走到 vulnerable sink 的完整執行路徑與沿途每個 if/else 的可控性分析,是 manual exploit development 的標準語言。
- No-hypotheticals principle — Prompt 明確要求所有報告必須附具體 code 範例與 step-by-step trace,禁止「理論上可能」的描述。
對 CS146S 的意義
這是 W6 中「LLM 真的找到 zero-day」最具體的證據。對照前面 Semgrep 那篇 80% false positive 的悲觀結論,本案告訴我們:只要 prompt 設計夠精確、scope 夠窄、紀律夠嚴(寧可不報),LLM 也能在 Linux kernel 這種高度複雜 codebase 找出真實 vulnerability。它把 prompt engineering 從「對話技巧」升級為一種正式的 security research methodology。
對 Vibe Coder 的 Takeaway
請 LLM 找 bug 時:(1) 範圍要窄(指定一類漏洞、一個檔案,而非「全部」);(2) 強制三階段輸出(path → 條件 → 矛盾自檢),不要只要結論;(3) 明確說「找不到就回 no findings、別亂掰」— 這條紀律會大幅降低 false positive;(4) 對自家專案 critical path(auth、權限、payment)可仿此 prompt 寫專屬 security review template,每次大改後跑一次。
原文連結
Vulnerability Prompt Analysis with O3 (CVE-2025-37899 use-after-free)