Claude wrote a full FreeBSD remote kernel RCE with root shell
TL;DR Highlight
Anthropic's Claude wrote a complete remote kernel RCE exploit for CVE-2026-4747 (FreeBSD kgssapi stack buffer overflow) from scratch, demonstrating that LLMs have reached the level of automating actual attack code—beyond mere vulnerability analysis.
Who Should Read
Security researchers and systems developers who want to understand how far LLMs can actually be leveraged for vulnerability discovery and exploit automation. Also security team members who want to understand the dual-edged impact of AI-based code generation on security.
Core Mechanics
- This vulnerability (CVE-2026-4747) is a stack buffer overflow in the RPCSEC_GSS implementation within FreeBSD's kgssapi.ko kernel module. When the `svc_rpc_gss_validate()` function reconstructs an RPC header into a 128-byte stack buffer (rpchdr[]), it performs no bounds checking on the credential body length (oa_length), allowing an attacker to write arbitrary data onto the kernel stack.
- Affected versions are FreeBSD 13.5 (below p11), 14.3 (below p10), 14.4 (below p1), and 15.0 (below p5). The attack targets environments where kgssapi.ko is loaded on an NFS server (port 2049/TCP). Testing was conducted on a FreeBSD 14.4-RELEASE amd64 GENERIC kernel (without KASLR).
- FreeBSD 14.x lacks KASLR (Kernel Address Space Layout Randomization), and because the overflowed buffer is an int32_t array, stack canaries (stack overflow detection mechanisms) are also not applied, making exploitation significantly easier. These conditions were the key factors that enabled achieving full RCE → uid 0 (root) reverse shell.
- Claude did not discover the bug independently; rather, it was provided with the CVE advisory and write-up and then tasked with writing exploit code from scratch. In other words, it was utilized at the stage of 'exploit implementation automation' rather than 'vulnerability discovery.'
- The bug itself was discovered by Nicholas Carlini (at Anthropic) using Claude, and Thai Duong's security company Califio published a detailed write-up including the entire exploit development process and the prompts used. The actual prompt history used is publicly available on GitHub, making it reproducible.
- This write-up is part of the 'MADBugs' series and serves as a demonstrated case that LLMs can produce complete kernel-level complex exploits (stack control, return address overwrite, reverse shell connection).
- A larger risk pointed out by the community is not the 'exploit writing' itself, but the fact that LLMs could quietly introduce new vulnerabilities into production code they generate. Exploit writing is visible, but the code generation risk accumulating with every PR is much harder to see—this concern was raised prominently.
Evidence
- "There were comments emphasizing the need to clearly distinguish that Claude did not 'discover' the bug but was given an already-public CVE write-up and asked to write the exploit. However, accompanying opinions noted that the day when a model like Claude could independently uncover CVEs given only kernel source code and a VM environment is not far off. A key argument was made about the importance of the distinction between vulnerability discovery and exploit writing: writing an exploit for a documented CVE is a well-scoped task, but the reverse direction—new vulnerabilities quietly slipping into production code written by LLMs—poses an even greater threat. Exploit capability is visible, but code generation risk is distributed across every PR and hard to surface. There were questions about the KASLR situation in FreeBSD 15.x in response to the note that FreeBSD 14.x lacks KASLR, with a commenter noting they couldn't find relevant mentions in release notes or the mitigations(7) man page, and sharing a link indicating that NetBSD has already implemented KASLR. A comment shared a YouTube link to a presentation titled 'Black-Hat LLMs' that had been released a few days prior, citing it as another example of the trend of LLMs becoming increasingly capable at vulnerability discovery and exploitation. There was also a perspective emphasizing the positive side of automated vulnerability discovery—that the hardest part has always been finding vulnerabilities, not fixing them, and that experts currently doing this work have strong incentives not to disclose, so automated discovery could ultimately be a major benefit even if the transition period is unsettling."
How to Apply
- "If you are currently running FreeBSD 13.5, 14.3, 14.4, or 15.0 with kgssapi.ko loaded on an NFS server, you must immediately apply the patch for each respective version (13.5-p11, 14.3-p10, 14.4-p1, 15.0-p5 or later). Until the patch is applied, blocking port 2049/TCP from untrusted networks is the minimum mitigation measure. For those looking to leverage LLMs in security research or red team activities, you can reference the prompt history published in Califio's write-up (GitHub link) to construct a 'CVE advisory → exploit code generation' workflow. However, this should only be used for PoC validation of already-disclosed vulnerabilities. For teams adopting AI code review tools or generating code with LLMs, rather than focusing solely on 'exploit potential,' you should establish a process that regularly uses static analysis tools in parallel to check for patterns such as missing bounds checks in LLM-generated code. The root cause of this case was also a simple missing bounds check."
Code Example
// Vulnerable code (sys/rpc/rpcsec_gss/svc_rpcsec_gss.c)
static bool_t
svc_rpc_gss_validate(struct svc_rpc_gss_client *client, struct rpc_msg *msg,
gss_qop_t *qop, rpc_gss_proc_t gcproc)
{
int32_t rpchdr[128 / sizeof(int32_t)]; // Only 128 bytes allocated on the stack
int32_t *buf;
memset(rpchdr, 0, sizeof(rpchdr));
// Write 32 bytes of fixed-size RPC header fields
buf = rpchdr;
IXDR_PUT_LONG(buf, msg->rm_xid);
IXDR_PUT_ENUM(buf, msg->rm_direction);
IXDR_PUT_LONG(buf, msg->rm_call.cb_rpcvers);
IXDR_PUT_LONG(buf, msg->rm_call.cb_prog);
IXDR_PUT_LONG(buf, msg->rm_call.cb_vers);
IXDR_PUT_LONG(buf, msg->rm_call.cb_proc);
oa = &msg->rm_call.cb_cred;
IXDR_PUT_ENUM(buf, oa->oa_flavor);
IXDR_PUT_LONG(buf, oa->oa_length);
if (oa->oa_length) {
// Bug: No bounds check on oa_length!
// Only 96 bytes remain after the first 32 bytes.
// If oa_length > 96, overflow beyond rpchdr →
// overwrites local variables → saved registers → return address
memcpy((caddr_t)buf, oa->oa_base, oa->oa_length);
buf += RNDUP(oa->oa_length) / sizeof(int32_t);
}
// gss_verify_mic() call — but the overflow has already occurred
}Terminology
Related Papers
Bun Rust rewrite: "codebase fails basic miri checks, allows for UB in safe rust"
Anthropic이 인수한 Bun 런타임이 Zig 코드베이스를 AI로 Rust에 재작성했는데, 가장 기본적인 메모리 안전성 검사(miri)조차 통과하지 못하는 UB(Undefined Behavior)가 발견됐다는 이슈가 제기됐다.
MetaBackdoor: Exploiting Positional Encoding as a Backdoor Attack Surface in LLMs
입력 텍스트는 멀쩡한데 입력 길이만으로 LLM 백도어가 발동되는 새로운 공격 기법 발견.
Tell HN: Dont use Claude Design, lost access to my projects after unsubscribing
Claude Design 구독을 해지했더니 기존 프로젝트에 접근이 완전히 차단됐다는 사용자 경고로, AI 도구에 중요한 작업물을 의존할 때의 리스크를 잘 보여주는 사례다.
History Anchors: How Prior Behavior Steers LLM Decisions Toward Unsafe Actions
시스템 프롬프트에 '이전 전략과 일관되게 행동하라' 한 문장만 추가하면, 최고 성능 LLM들이 안전한 선택을 0%에서 90%+ 위험한 선택으로 뒤집힌다.
Formalize, Don't Optimize: The Heuristic Trap in LLM-Generated Combinatorial Solvers
LLM에게 조합 최적화 문제의 solver를 만들게 할 때, 'Python + OR-Tools'가 가장 정확하고 '효율 최적화' 프롬프트는 오히려 정확도를 망친다.
Postmortem: TanStack NPM supply-chain compromise
2026년 5월 11일 TanStack의 42개 npm 패키지가 GitHub Actions cache poisoning과 OIDC 토큰 탈취를 조합한 공격으로 악성 버전이 배포됐으며, 공격 벡터와 대응 과정을 상세히 분석한 글이다.