Claude Code Found a Linux Vulnerability Hidden for 23 Years

Michael Lynch

Claude Code 發現隱藏 23 年的 Linux 漏洞

Nicholas Carlini(尼可拉斯·卡里尼)是 Anthropic 的研究科學家,他在[un]prompted AI security conference表示,他利用 Claude Code 在 Linux 核心中發現了多個可遠端利用的安全漏洞,其中一個甚至已隱藏長達 23 年未被發現。

尼可拉斯·卡里尼對 Claude Code 在尋找這些漏洞上的效率感到十分驚訝:

我們現在在 Linux 核心中發現了多個可遠端利用的 heap buffer overflows(堆積緩衝區溢位)。

我這輩子從來沒找到過任何一個。這是非常、非常、非常困難的事。

有了這些語言模型,我卻找到了一大堆。

—尼可拉斯·卡里尼,於 [un]prompted 2026 演講

Claude Code 如何找到這個漏洞

尼可拉斯·卡里尼分享的這個漏洞最令人驚訝之處,在於 Claude Code 找到它時幾乎不需要任何人工監督。他基本上只是將 Claude Code 指向 Linux 核心的原始碼,然後問:「哪裡有安全漏洞?」

尼可拉斯·卡里尼使用了一個類似以下的簡單指令碼:

# 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 漏洞

在演講中,尼可拉斯·卡里尼聚焦於Claude 在 Linux 的網路檔案共享(NFS)驅動程式中找到的一個漏洞,該漏洞可讓攻擊者透過網路讀取敏感的核心記憶體。

尼可拉斯·卡里尼選擇這個漏洞,是為了說明 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 file。伺服器接受請求,客戶端再確認接受。

(3)—— Client A 取得鎖定,並宣告一個 1024 位元組的 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 file。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 年未被發現

這個漏洞是於 2003 年 3 月被引入 Linux 核心的:

[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!).

這個漏洞年代久遠,甚至無法直接連結到原始提交,因為它早於 Git,而 Git 直到 2005 年才發布。

多到回報不完的漏洞

尼可拉斯·卡里尼在 Linux 核心中還發現了數百個潛在漏洞,但修復工作的瓶頸在於需要人工逐一檢視 Claude 的所有發現:

我在 Linux 核心中發現了太多漏洞,多到還沒驗證完而無法回報……我不會把可能的垃圾資訊丟給〔Linux 核心維護者〕,但這也意味著我現在手上有數百個當機案例是他們還沒看到的,因為我還沒時間檢查。

—尼可拉斯·卡里尼,於 [un]prompted 2026 演講

我搜尋了 Linux 核心,發現目前為止尼可拉斯·卡里尼已直接修復或向 Linux 核心維護者回報的 Linux 漏洞共有五個,有些甚至就在上週:

  1. nfsd: fix heap overflow in NFSv4.0 LOCK replay cache(如上所述)
  2. io_uring/fdinfo: fix OOB read in SQE_MIXED wrap check
  3. futex: Require sys_futex_requeue() to have identical flags
  4. ksmbd: fix share_conf UAF in tree_conn disconnect
  5. ksmbd: fix signededness bug in smb_direct_prepare_negotiation()

大浪即將來襲

尼可拉斯·卡里尼這場演講最引人注目之處,在於 large language models(大型語言模型)在尋找漏洞方面的進步速度之快。尼可拉斯·卡里尼是使用 Claude Opus 4.6 發現這些漏洞的,而 Anthropic 是在不到兩個月前才發布該模型。他曾嘗試在較舊的 AI 模型上重現成果,發現 Opus 4.1(於八個月前發布)與 Sonnet 4.5(於六個月前發布)僅能找到他使用 Opus 4.6 所發現的一小部分:

我預期在未來幾個月內,將會看到大量安全漏洞被揭露,因為研究人員與攻擊者都將意識到這些 AI 模型在發掘安全漏洞方面的強大能力。

原始演講

原文由 Michael Lynch 發布

本文章由 muse-spark-1.2-contributor 進行翻譯