UESecurityCapabilities 位串导致未恢复的 NGAP panic| CVE | CVE-2026-102945 |
| 组件 | OMEC amf — ngap/handler.go::HandlePathSwitchRequest(5G NGAP 路径切换处理) |
| 受影响版本 | < 1.7.1-0.20260725031321-d28042aaaea0(已在 HEAD daed5a2 确认,v3.1.5 中存在) |
| 修复于 | commit d28042aa(Guard against empty UESecurityCapabilities Bytes to avoid index panic,GHSA-v6w5-38cf-pcv8) |
| CWE | CWE-129(数组索引验证不当)、CWE-248(未捕获异常) |
| 影响 | HandlePathSwitchRequest 仅检查 UESecurityCapabilities IE 是否存在,却从不检查其长度,而可扩展的 APER 类型会静默产生空位串。六处未加防护的 Bytes[0] 读取会在未恢复的 goroutine 上触发 panic,并终止 AMF 进程。AMF 是 5G 核心网的控制面入口,因此终止它会使所有用户的移动性管理中断 |
| 向量 | 对端发送的 NGAP Path Switch Request,携带可扩展的零长度 UESecurityCapabilities BIT STRING |
| 触发条件 | Path Switch Request 中 UESecurityCapabilities 存在但 Bytes 为空 → 六处 Bytes[0] 读取 |
存在漏洞的代码仅检查了 nil:
// ngap/handler.go — pre-fix (line 3267)
if uESecurityCapabilities != nil { // presence only
amfUe.UESecurityCapability.SetEA1_128_5G((uESecurityCapabilities.NRencryptionAlgorithms.Value.Bytes[0] & 0x80) >> 7)
... // five more Bytes[0] reads
}
该修复至少需要两个字节,并依据其 CRITICALITY 忽略该 IE:
// fixed (commit d28042aa)
if len(uESecurityCapabilities.NRencryptionAlgorithms.Value.Bytes) < 2 ||
len(uESecurityCapabilities.NRintegrityProtectionAlgorithms.Value.Bytes) < 2 {
ran.Log.Warnln("UESecurityCapabilities bit string too short ... ignoring IE ...")
} else {
... // the six original reads
}
UESecurityCapabilities 被声明为可扩展的 APER BIT STRING
(aper:"sizeExt,sizeLB:16,sizeUB:16")。当对端设置扩展位时,
APER 解码器会丢弃 SIZE(16) 约束,并成功返回一个空的
Bytes 切片。处理程序唯一的防护是对包含该值的 IE 进行
nil 检查,因此全部六次 Bytes[0] 读取(三个加密标志和三个
完整性算法标志)都在零长度切片上执行。Go 会引发
runtime error: index out of range [0] with length 0;该 panic 在 NGAP 处理程序 goroutine 中未被
恢复,并终止整个 AMF。修复方案
检查两个位串是否满足 BIT STRING (SIZE(16,...)) 所要求的最小两字节;
由于该 IE 在 Path Switch Request 中具有 CRITICALITY IGNORE,短值会被记录并忽略,而不是被应用。
| 服务 | 镜像 | 角色 |
|---|---|---|
ps-vuln | cve-2026-102945:vuln | 来自 d28042aa^ 的上游代码块(存在漏洞),使用 Go 1.24 编译 |
ps-fixed | cve-2026-102945:fixed | 来自 d28042aa 的上游代码块(已修复),使用 Go 1.24 编译 |
poc | cve-2026-102945-poc:local | 仅使用标准库的 Python 驱动程序 |
处理程序代码块在对应的两个提交处从 ngap/handler.go 逐字复制;
仅提供了最小桩代码(APER 位串、能力设置器、ran.Log)。
该处理程序被编译成一个二进制文件,作为 HTTP 服务的子进程运行,因此 panic 会以退出码和 Go 堆栈
跟踪的形式被观察到,而不会导致服务崩溃。输入模式:empty(扩展
位 → 零长度 Bytes)和 valid(两个字节,正常解码)。
./run-lab.sh build # builds both sides (golang:1.24-alpine + python3)
./run-lab.sh up # cve102945lab network: ps-vuln / ps-fixed
./run-lab.sh sweep
./run-lab.sh down
poc/poc.py(仅使用标准库):
index out of range panic 非零退出时返回 1;当短 IE 被警告并忽略时返回 0;3 表示无 worker,2 表示不可达/不确定。Bytes[0] 读取 → 未恢复的 panic → 5G 核心网移动性管理丢失。empty 和 valid 两种模式,输出退出码、panic 标志和 stderr 片段(valid 用例证明该修复并非无效)。d28042aa / len(Bytes) >= 2 / CRITICALITY IGNORE 之后执行。一个独立的完整攻击链利用程序位于 exploit/exploit.py:
python3 exploit/exploit.py --host=ps-vuln
# exit 1 on confirmed panic, 0 on a safe target
| 位串 | ps-vuln (d28042aa^) | ps-fixed (d28042aa) |
|---|---|---|
空(Bytes 零长度) | 子进程退出码 2 — panic: index out of range [0] with length 0 | 退出码 0 — WARN: ... bit string too short ... ignoring IE |
| 有效(2 字节) | 退出码 0,EA1..IA3 = 1 | 退出码 0,EA1..IA3 = 1 |
捕获的运行记录:evidence/check-*-run.txt、evidence/exploit-*-run.txt、
evidence/probe-*-run.txt、evidence/mitigation-*-run.txt、
evidence/exploit-standalone-run.txt、evidence/exploit-standalone-fixed-run.txt、
evidence/versions.txt、evidence/upstream-*-block.txt、evidence/0day-sweep.txt。
cve102945lab
网络上运行的有界容器;实验镜像中装有 Go 1.24 工具链。UESecurityCapabilities BIT STRING 的 Path Switch Request。上游防护检查同时检查 NRencryptionAlgorithms 和
NRintegrityProtectionAlgorithms 两个位串,通过一次长度检查覆盖了全部六处索引零读取。
valid 输入在两个构建上都将 EA1..IA3 设为 1,
确认该修复不会禁用合法的能力解码。
本次排查未发现具有相同“仅检查存在性”防护的同类路径。
README.md this write-up
run-lab.sh environment driver (build / up / sweep / down)
Makefile convenience targets
poc/poc.py the PoC (check / exploit / probe / mitigation)
exploit/exploit.py standalone full-chain exploit
lab/main-vuln.go upstream vulnerable block + minimal stubs
lab/main-fixed.go upstream fixed block + minimal stubs
lab/lab.Dockerfile builds both sides from the Go sources
lab/service.py HTTP wrapper (POST /run), child-process isolation
evidence/ captured runs of every mode on both sides
TRACKING.md excluded (working record)
ngap/handler.go,第 3267–3274 行(修复前)