Claude Code 發現潛藏 23 年的 Linux 漏洞
原文由 Michael Lynch 于 發布,訂閱此部落格
Nicholas Carlini,Anthropic 的研究科學家,指出他在[un]prompted AI 資安研討會上表示,他利用 Claude Code 在 Linux 核心中發現了多個可遠端利用的安全漏洞,其中一個已潛藏 23 年未被發現。
Nicholas 對於 Claude Code 在找出這些漏洞方面的效率感到十分驚訝:
我們現在在 Linux 核心中發現了數個可遠端利用的堆積緩衝區溢位漏洞。
我這輩子從來沒找到過這種漏洞。這真的、真的、非常困難。
有了這些語言模型,我卻找到了一堆。
——Nicholas Carlini 於 [un]prompted 2026 的演講
Claude Code 如何找到這個漏洞
關於 Nicholas 分享的這個漏洞,最令人驚訝的是 Claude Code 幾乎不需要什麼監督就能找到它。他基本上只是把 Claude Code 指向 Linux 核心原始碼,然後問:「安全漏洞在哪裡?」
Nicholas 使用了一個類似以下的簡單腳本:
# Iterate over all files in the source tree.
find . -type f -print0 | while IFS= read -r -d '' file; do
# Tell Claude Code to look for vulnerabilities in each file.
claude \
--verbose \
--dangerously-skip-permissions \
--print "You are playing in a CTF. \
Find a vulnerability. \
hint: look at $file \
Write the most serious \
one to the /output dir"
done這個腳本告訴 Claude Code,使用者正在參加一場奪旗(capture the flag)資安競賽,需要協助解題。
為了避免 Claude Code 一再找到同一個漏洞,腳本會遍歷 Linux 核心中的每一個原始碼檔案,依序告訴 Claude 漏洞可能在 A 檔案、然後是 B 檔案,以此類推,直到讓 Claude 逐一檢視核心中的所有檔案。
NFS 漏洞
在演講中,Nicholas 聚焦於Claude 在 Linux 的網路檔案分享(NFS)驅動程式中找到的一個漏洞,該漏洞能讓攻擊者透過網路讀取敏感的核心記憶體。
Nicholas 選擇這個漏洞,是為了說明 Claude Code 不只是在找顯而易見的漏洞或套用常見的模式。這個漏洞需要 AI 模型理解 NFS 協定運作的細微之處。
這項攻擊需要攻擊者使用兩個互相配合的 NFS 客戶端來攻擊 Linux NFS 伺服器:
Client A NFS Server Client B
| | |
(1) |--- SETCLIENTID ---------------->| |
|<-- clientid_a, confirm ---------| |
|--- SETCLIENTID_CONFIRM -------->| |
| | |
(2) |--- OPEN "lockfile" ------------>| |
|<-- open_stateid_a --------------| |
|--- OPEN_CONFIRM --------------->| |
| | |
(3) |--- LOCK (1024-byte owner) ----->| lock_owner = 1024b buf |
|<-- lock_stateid_a --------------| Lock granted |
| | |(1) - Client A 與 NFS 伺服器進行三向交握,以開始 NFS 操作。
(2) - Client A 請求一個 lock 檔案。伺服器接受請求,客戶端再確認接受。
(3) - Client A 取得鎖定,並宣告一個 1024 位元組的 owner ID,這對於 owner ID 來說是異常地長,但仍是合法數值。伺服器核准了這次的鎖定。
接著,攻擊者再啟動第二個 NFS 客戶端 Client B 來與伺服器通訊:
Client A NFS Server Client B
| | |
(4) | |<-- SETCLIENTID -----------------|
| |--- clientid_b, confirm -------->|
| |<-- SETCLIENTID_CONFIRM ---------|
| | |
(5) | |<-- OPEN "lockfile" -------------|
| |--- open_stateid_b ------------->|
| |<-- OPEN_CONFIRM ----------------|
| | |
(6) | |<-- LOCK (same range) -----------|
| | |
| +-----------+-----------+ |
| | LOCK DENIED! | |
| | Encode response: | |
| | offset: 8B | |
| | length: 8B | |
| | type: 4B | |
| | clientid: 8B | |
| | owner_len: 4B | |
| | owner: 1024B | |
| | TOTAL: 1056B | |
| +-----------+-----------+ |
| | |(4) Client B 與 NFS 伺服器進行三向交握以開始 NFS 操作,與上述 (1) 相同。
(5) Client B 請求存取與 (2) 中 Client A 相同的 lock 檔案。NFS 伺服器接受請求,客戶端再確認接受。
(6) Client B 嘗試取得鎖定,但 NFS 伺服器拒絕了請求,因為 Client A 已經持有該鎖定。
問題在於,在步驟 (6) 中,當 NFS 伺服器嘗試產生回應以拒絕 Client B 的鎖定請求時,它使用的是一個只有 112 位元組的記憶體緩衝區。拒絕訊息中包含了 owner ID,其長度可達 1024 位元組,使訊息總大小達到 1056 位元組。核心卻將 1056 位元組寫入 112 位元組的緩衝區,這意味著攻擊者可以利用步驟 (3) 中由自己控制的 owner ID 欄位位元組來覆寫核心記憶體。
有趣的是,上面的 ASCII 協定圖正是 Claude Code 在最初的漏洞報告中建立的。
潛藏了 23 年未被發現
[email protected], 2003-09-22 19:22:37-07:00, [email protected]
[PATCH] knfsd: idempotent replay cache for OPEN state
This implements the idempotent replay cache need for NFSv4 OPEN state.
each state owner (open owner or lock owner) is required to store the
last sequence number mutating operation, and retransmit it when replayed
sequence number is presented for the operation.
I've implemented the cache as a static buffer of size 112 bytes
(NFSD4_REPLAY_ISIZE) which is large enough to hold the OPEN, the largest
of the sequence mutation operations. This implements the cache for
OPEN, OPEN_CONFIRM, OPEN_DOWNGRADE, and CLOSE. LOCK and UNLOCK will be
added when byte-range locking is done (soon!).這個漏洞非常久遠,我甚至無法直接連結到它,因為它比 2005 年才發布的 git 還要早。
多到回報不完的漏洞
Nicholas 在 Linux 核心中還發現了數百個更多潛在漏洞,但修復這些漏洞的瓶頸在於,需要由人工手動梳理 Claude 的所有發現:
我在 Linux 核心中發現了太多漏洞,多到我還沒驗證完,根本無法回報……我不會把可能是垃圾的潛在問題丟給 [Linux 核心維護者],但這也意味著我現在手上有好幾百個他們還沒看過的當機案例,只是因為我還沒時間檢查。
——Nicholas Carlini 於 [un]prompted 2026 的演講
我搜尋了 Linux 核心,發現目前為止 Nicholas 直接修復或向 Linux 核心維護者回報的漏洞共有五個,有些甚至就在上週:
- nfsd: fix heap overflow in NFSv4.0 LOCK replay cache(如上所述)
- io_uring/fdinfo: fix OOB read in SQE_MIXED wrap check
- futex: Require sys_futex_requeue() to have identical flags
- ksmbd: fix share_conf UAF in tree_conn disconnect
- ksmbd: fix signededness bug in smb_direct_prepare_negotiation()
大浪將至
Nicholas 這場演講最引人注目之處,在於大型語言模型在尋找漏洞方面的進步速度之快。Nicholas 是使用 Claude Opus 4.6 找到這些漏洞的,該模型是 Anthropic 在不到兩個月前發布的。他嘗試在較舊的 AI 模型上重現結果,發現 Opus 4.1(八個月前發布)和 Sonnet 4.5(六個月前發布)只能找到他用 Opus 4.6 所發現數量的一小部分:
我預期在未來幾個月內,將會有一大波安全漏洞被揭露,因為研究人員和攻擊者都將意識到這些 AI 模型在發掘安全漏洞方面的強大能力。
原始演講
隨機一篇部落格

留言
登入後參與討論