llama.cpp b11871:限制 JSON 嵌套深度防崩溃
原标题:b11871
AI 摘要
llama.cpp 发布 b11871 版本,修复了 chat 接口的 JSON 嵌套深度安全问题:schema 构建器、jinja 引擎和决策代码会递归遍历请求 JSON,嵌套过深会导致 HTTP 线程栈溢出,使 llama-server 崩溃(macOS 上 SIGBUS、Linux 上 SIGSEGV)。现在在遍历前先检查深度,超过 128 层直接返回 400,覆盖 chat 模板输入、/completion 的 json_schema 以及 /v1/systemone 请求体。该版本同时提供 macOS、Linux、Android、Windows 等多平台预编译包。
正文节选
<details open> chat : reject JSON nested more than 128 levels before walking it (#30242) * chat : reject JSON nested more than 128 levels before walking it The schema builder, the jinja engine and the decision code walk request JSON with recursion. A request nested deep enough overflows the stack of the HTTP thread and llama-server dies (SIGBUS on macOS, SIGSEGV on Linux): for a tool schema from a few hundred levels on macOS and about 10000 on Linux. Check the depth first and answer 400 past